From 697078568d2f9fa04b8dc6a8a40d269ad799523e Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 22 Jul 2010 13:47:07 -0500 Subject: [svn-r19126] Description: Bring r19124 from trunk to 1.8 branch: Add some error checking to the process of creating superblock extension. Tested on: FreeBSD/32 6.3 (duty) in debug mode (h5committest performed on trunk) --- configure | 2 +- src/H5Fsuper.c | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/configure b/configure index a55a709..aceee30 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in 19077 2010-07-16 16:41:22Z nfortne2 . +# From configure.in Id: configure.in 19100 2010-07-19 18:38:40Z koziol . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.65 for HDF5 1.8.5-snap5. # diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 4275069..0469f8a 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -189,12 +189,27 @@ H5F_super_ext_create(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_ptr) HDassert(!H5F_addr_defined(f->shared->sblock->ext_addr)); HDassert(ext_ptr); - H5O_loc_reset(ext_ptr); - if(H5O_create(f, dxpl_id, 0, H5P_GROUP_CREATE_DEFAULT, ext_ptr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create superblock extension") + /* Check for older version of superblock format that can't support superblock extensions */ + if(f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) + HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension not permitted with version %u of superblock", f->shared->sblock->super_vers) + else if(H5F_addr_defined(f->shared->sblock->ext_addr)) + HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension already exists?!?!") + else { + /* The superblock extension isn't actually a group, but the + * default group creation list should work fine. + * If we don't supply a size for the object header, HDF5 will + * allocate H5O_MIN_SIZE by default. This is currently + * big enough to hold the biggest possible extension, but should + * be tuned if more information is added to the superblock + * extension. + */ + H5O_loc_reset(ext_ptr); + if(H5O_create(f, dxpl_id, 0, H5P_GROUP_CREATE_DEFAULT, ext_ptr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create superblock extension") - /* Record the address of the superblock extension */ - f->shared->sblock->ext_addr = ext_ptr->addr; + /* Record the address of the superblock extension */ + f->shared->sblock->ext_addr = ext_ptr->addr; + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -- cgit v0.12