[svn-r12801] Description:

Fix several errors in the "latest version" of the object header format
changes and enable the new version when requested now.

    Clean up several confusing or duplicated sections of code.

Tested on:
    Linux/32 2.4 (heping)
    Linux/64 2.4 (mir)
    FreeBSD/32 4.11 (sleipnir)
This commit is contained in:
Quincey Koziol 2006-10-23 05:15:52 -05:00
parent 8ee7c55fea
commit 1202e83013
4 changed files with 484 additions and 341 deletions

795
src/H5O.c

File diff suppressed because it is too large Load Diff

View File

@ -357,7 +357,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
/* Check for magic # on chunks > 0 in later versions of the format */
if(chunkno > 0 && oh->version > H5O_VERSION_1) {
/* Magic number */
if(!HDmemcmp(p, H5O_CHK_MAGIC, (size_t)H5O_SIZEOF_MAGIC))
if(HDmemcmp(p, H5O_CHK_MAGIC, (size_t)H5O_SIZEOF_MAGIC))
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "wrong object header chunk signature")
p += H5O_SIZEOF_MAGIC;
} /* end if */
@ -493,15 +493,18 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
if((oh->nmesgs + skipped_msgs + merged_null_msgs) != nmesgs)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - too few messages")
#ifdef H5O_DEBUG
H5O_assert(oh);
#endif /* H5O_DEBUG */
/* Set return value */
ret_value = oh;
done:
/* Release the [possibly partially initialized] object header on errors */
if(!ret_value && oh) {
if(!ret_value && oh)
if(H5O_dest(f,oh) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "unable to destroy object header data")
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_load() */
@ -543,6 +546,10 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr, H5O_t *
uint8_t *p; /* Pointer to object header prefix buffer */
unsigned u; /* Local index variable */
#ifdef H5O_DEBUG
H5O_assert(oh);
#endif /* H5O_DEBUG */
/* Point to raw data 'image' for first chunk, which has room for the prefix */
p = oh->chunk[0].image;
@ -552,7 +559,7 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t UNUSED addr, H5O_t *
* modified */
if(oh->version > H5O_VERSION_1) {
/* Verify magic number */
HDassert(!HDmemcmp(oh->chunk[0].image, H5O_HDR_MAGIC, H5O_SIZEOF_MAGIC));
HDassert(!HDmemcmp(p, H5O_HDR_MAGIC, H5O_SIZEOF_MAGIC));
p += H5O_SIZEOF_MAGIC;
/* Version */

View File

@ -41,7 +41,7 @@
/* The latest version of the format. Look through the 'flush'
* and 'size' callback for places to change when updating this. */
#define H5O_VERSION_LATEST H5O_VERSION_1
#define H5O_VERSION_LATEST H5O_VERSION_2
/*
* Align messages on 8-byte boundaries because we would like to copy the
@ -332,6 +332,9 @@ H5_DLL void * H5O_read_real(const H5O_loc_t *loc, const H5O_msg_class_t *type,
int sequence, void *mesg, hid_t dxpl_id);
H5_DLL herr_t H5O_free_mesg(H5O_mesg_t *mesg);
H5_DLL void * H5O_free_real(const H5O_msg_class_t *type, void *mesg);
#ifdef H5O_DEBUG
H5_DLL herr_t H5O_assert(const H5O_t *oh);
#endif /* H5O_DEBUG */
H5_DLL herr_t H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int fwidth);
/* Shared object operators */

View File

@ -426,9 +426,9 @@ lifecycle(hid_t fapl)
/* Check that the object header is only one chunk and the space has been allocated correctly */
if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR
#ifdef H5_HAVE_LARGE_HSIZET
if(obj_stat.ohdr.size != 232) TEST_ERROR
if(obj_stat.ohdr.size != 205) TEST_ERROR
#else /* H5_HAVE_LARGE_HSIZET */
if(obj_stat.ohdr.size != 224) TEST_ERROR
if(obj_stat.ohdr.size != 197) TEST_ERROR
#endif /* H5_HAVE_LARGE_HSIZET */
if(obj_stat.ohdr.free != 0) TEST_ERROR
if(obj_stat.ohdr.nmesgs != 6) TEST_ERROR
@ -452,11 +452,11 @@ lifecycle(hid_t fapl)
/* Check that the object header is still one chunk and the space has been allocated correctly */
if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR
#ifdef H5_HAVE_LARGE_HSIZET
if(obj_stat.ohdr.size != 232) TEST_ERROR
if(obj_stat.ohdr.size != 205) TEST_ERROR
#else /* H5_HAVE_LARGE_HSIZET */
if(obj_stat.ohdr.size != 224) TEST_ERROR
if(obj_stat.ohdr.size != 197) TEST_ERROR
#endif /* H5_HAVE_LARGE_HSIZET */
if(obj_stat.ohdr.free != 128) TEST_ERROR
if(obj_stat.ohdr.free != 116) TEST_ERROR
if(obj_stat.ohdr.nmesgs != 3) TEST_ERROR
if(obj_stat.ohdr.nchunks != 1) TEST_ERROR