diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5FDfamily.c | 38 | ||||
-rw-r--r-- | src/H5Fsuper.c | 12 | ||||
-rw-r--r-- | src/H5private.h | 1 |
3 files changed, 23 insertions, 28 deletions
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 88abab3..34360e5 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -613,27 +613,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/, - unsigned char *buf/*out*/) +H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out*/) { H5FD_family_t *file = (H5FD_family_t*)_file; - unsigned char *p = buf; - uint64_t msize; - herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_family_sb_encode, FAIL) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_family_sb_encode) /* Name and version number */ - strncpy(name, "NCSAfami", (size_t)8); + HDstrncpy(name, "NCSAfami", (size_t)8); name[8] = '\0'; - /* copy member file size */ - msize = (uint64_t)file->memb_size; - UINT64ENCODE(p, msize); + /* Store member file size */ + UINT64ENCODE(buf, (uint64_t)file->memb_size); -done: - FUNC_LEAVE_NOAPI(ret_value) -} + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FD_family_sb_encode() */ /*------------------------------------------------------------------------- @@ -660,9 +654,8 @@ static herr_t H5FD_family_sb_decode(H5FD_t *_file, const char UNUSED *name, const unsigned char *buf) { H5FD_family_t *file = (H5FD_family_t*)_file; - uint64_t msize = 0; - char err_msg[128]; - herr_t ret_value=SUCCEED; /* Return value */ + uint64_t msize; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_sb_decode, FAIL) @@ -676,18 +669,19 @@ H5FD_family_sb_decode(H5FD_t *_file, const char UNUSED *name, const unsigned cha if(file->mem_newsize) { file->memb_size = file->mem_newsize; HGOTO_DONE(ret_value) - } + } /* end if */ /* Default - use the saved member size */ - if(file->pmem_size == H5F_FAMILY_DEFAULT) { + if(file->pmem_size == H5F_FAMILY_DEFAULT) file->pmem_size = msize; - } /* Check if member size from file access property is correct */ if(msize != file->pmem_size) { - sprintf(err_msg, "family member size should be %lu", (unsigned long)msize); + char err_msg[128]; + + sprintf(err_msg, "family member size should be %lu, is %lu", (unsigned long)msize, (unsigned long)file->pmem_size); HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, err_msg) - } + } /* end if */ /* Update member file size to the size saved in the superblock. * That's the size intended to be. */ @@ -695,7 +689,7 @@ H5FD_family_sb_decode(H5FD_t *_file, const char UNUSED *name, const unsigned cha done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_family_sb_decode() */ /*------------------------------------------------------------------------- diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 295adca..e24a8b2 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -397,7 +397,6 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc) shared->base_addr = shared->super_addr; } /* end if */ - /* This step is for h5repart tool only. If user wants to change file driver * from family to sec2 while using h5repart, set the driver address to * undefined to let the library ignore the family driver information saved @@ -752,9 +751,6 @@ H5F_write_superblock(H5F_t *f, hid_t dxpl_id) char driver_name[9]; /* Name of driver, for driver info block */ uint8_t *dbuf = p; /* Pointer to beginning of driver info */ - /* Add in the size of the header */ - driver_size += H5F_DRVINFOBLOCK_HDR_SIZE; - /* Encode the driver information block */ *p++ = HDF5_DRIVERINFO_VERSION_0; /* Version */ *p++ = 0; /* reserved */ @@ -762,7 +758,7 @@ H5F_write_superblock(H5F_t *f, hid_t dxpl_id) *p++ = 0; /* reserved */ /* Driver info size, excluding header */ - UINT32ENCODE(p, driver_size - H5F_DRVINFOBLOCK_HDR_SIZE); + UINT32ENCODE(p, driver_size); /* Encode driver-specific data */ if(H5FD_sb_encode(f->shared->lf, driver_name, dbuf + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) @@ -771,10 +767,14 @@ H5F_write_superblock(H5F_t *f, hid_t dxpl_id) /* Store driver name (set in 'H5FD_sb_encode' call above) */ HDmemcpy(dbuf + 8, driver_name, (size_t)8); + /* Advance buffer pointer past name & variable-sized portion of driver info */ + /* (for later use in storing the checksum) */ + p += 8 + driver_size; + /* Update superblock checksum with driver info block checksum */ /* (on superblock versions > 1) */ if(super_vers >= HDF5_SUPERBLOCK_VERSION_2) - chksum = H5_checksum_metadata(dbuf, driver_size, chksum); + chksum = H5_checksum_metadata(dbuf, driver_size + H5F_DRVINFOBLOCK_HDR_SIZE, chksum); } /* end if */ /* Encode the checksum on the superblock (for versions > 1) */ diff --git a/src/H5private.h b/src/H5private.h index 31213c3..757f3b1 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1299,6 +1299,7 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); \ BEGIN_MPE_LOG(func_name) +/* Note: this macro only works when there's _no_ interface initialization routine for the module */ #define FUNC_ENTER_NOAPI_INIT(func_name,err) \ /* Initialize the interface, if appropriate */ \ H5_INTERFACE_INIT(err) \ |