mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-30 15:32:37 +08:00
[svn-r16308] Purpose: Fix problem with H5Tpack
Description: If a compound type was packed except for some extra space at the end, H5Tpack would not modify the type and the extra space would remain. Changed H5T_is_packed to fix this behaviour. Tested: jam, smirom (h5committest - linew down)
This commit is contained in:
parent
a365f0e6aa
commit
6564dbcfaa
@ -141,40 +141,42 @@ Bug Fixes since HDF5-1.8.0 release
|
|||||||
|
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
- Fixed a bug where H5Tpack wouldn't remove trailing space from an
|
||||||
|
otherwise packed compound type. (NAF - 2009/01/14)
|
||||||
- Fixed up some old v2 btree assertions that get run in debug mode that
|
- Fixed up some old v2 btree assertions that get run in debug mode that
|
||||||
were previously failing on compilation, and removed some of the
|
were previously failing on compilation, and removed some of the
|
||||||
more heavily outdated and non-rewritable ones. (MAM - 2008/12/15)
|
more heavily outdated and non-rewritable ones. (MAM - 2008/12/15)
|
||||||
- Fixed a bug that could cause problems when "automatically" unmounting
|
- Fixed a bug that could cause problems when "automatically" unmounting
|
||||||
multiple files. (NAF - 2008/11/17)
|
multiple files. (NAF - 2008/11/17)
|
||||||
- H5Ovisit and H5Ovisit_by_name will now properly terminate when the
|
- H5Ovisit and H5Ovisit_by_name will now properly terminate when the
|
||||||
callback function returns a positive value on the starting object.
|
callback function returns a positive value on the starting object.
|
||||||
(NAF - 2008/11/03)
|
(NAF - 2008/11/03)
|
||||||
- Fixed an error where a null message could be created that was larger
|
- Fixed an error where a null message could be created that was larger
|
||||||
than could be written to the file. (NAF - 2008/10/23)
|
than could be written to the file. (NAF - 2008/10/23)
|
||||||
- Corrected error with family/split/multi VFD not updating driver info
|
- Corrected error with family/split/multi VFD not updating driver info
|
||||||
when "latest" version of the file format used. (QAK - 2008/10/14)
|
when "latest" version of the file format used. (QAK - 2008/10/14)
|
||||||
- Corrected alignment+threshold errors to work correctly when metadata
|
- Corrected alignment+threshold errors to work correctly when metadata
|
||||||
aggregation is enabled. (QAK - 2008/10/06)
|
aggregation is enabled. (QAK - 2008/10/06)
|
||||||
- Changed H5Fget_obj_count and H5Fget_obj_ids to ignore objects registered
|
- Changed H5Fget_obj_count and H5Fget_obj_ids to ignore objects registered
|
||||||
by the library for internal library use. (NAF - 2008/10/06)
|
by the library for internal library use. (NAF - 2008/10/06)
|
||||||
- Fixed potential memory leak during compound conversion.
|
- Fixed potential memory leak during compound conversion.
|
||||||
(NAF - 2008/10/06)
|
(NAF - 2008/10/06)
|
||||||
- Changed the return value of H5Fget_obj_count from INT to SSIZE_T. Also
|
- Changed the return value of H5Fget_obj_count from INT to SSIZE_T. Also
|
||||||
changed the return value of H5Fget_obj_ids from HERR_T to SSIZE_T and
|
changed the return value of H5Fget_obj_ids from HERR_T to SSIZE_T and
|
||||||
the type of the parameter MAX_OBJS from INT to SIZE_T. (SLU - 2008/09/26)
|
the type of the parameter MAX_OBJS from INT to SIZE_T. (SLU - 2008/09/26)
|
||||||
- Fixed an issue that could cause data to be improperly overwritten
|
- Fixed an issue that could cause data to be improperly overwritten
|
||||||
during compound type conversion. (NAF - 2008/09/19)
|
during compound type conversion. (NAF - 2008/09/19)
|
||||||
- Fixed pointer alignment violations that could occur during vlen
|
- Fixed pointer alignment violations that could occur during vlen
|
||||||
conversion. (NAF - 2008/09/16)
|
conversion. (NAF - 2008/09/16)
|
||||||
- Fixed problem where library could cause a segmentation fault when
|
- Fixed problem where library could cause a segmentation fault when
|
||||||
an invalid location ID was given to H5Giterate(). (QAK - 2008/08/19)
|
an invalid location ID was given to H5Giterate(). (QAK - 2008/08/19)
|
||||||
- Fixed improper shutdown when objects have reference count > 1. The
|
- Fixed improper shutdown when objects have reference count > 1. The
|
||||||
library now tracks reference count due to the application separately
|
library now tracks reference count due to the application separately
|
||||||
from that due to internal library routines. (NAF - 2008/08/19)
|
from that due to internal library routines. (NAF - 2008/08/19)
|
||||||
- Fixed assertion failure caused by incorrect array datatype version.
|
- Fixed assertion failure caused by incorrect array datatype version.
|
||||||
(NAF - 2008/08/08)
|
(NAF - 2008/08/08)
|
||||||
- Fixed an issue where mount point traversal would fail when using
|
- Fixed an issue where mount point traversal would fail when using
|
||||||
multiple handles for the child. (NAF - 2008/08/07)
|
multiple handles for the child. (NAF - 2008/08/07)
|
||||||
- Fixed an issue where mount points were inaccessible when using multiple
|
- Fixed an issue where mount points were inaccessible when using multiple
|
||||||
file handles for the parent. The mount table is now in the shared
|
file handles for the parent. The mount table is now in the shared
|
||||||
file structure (the parent pointer is still in the top structure).
|
file structure (the parent pointer is still in the top structure).
|
||||||
|
@ -631,8 +631,13 @@ H5T_is_packed(const H5T_t *dt)
|
|||||||
dt = dt->shared->parent;
|
dt = dt->shared->parent;
|
||||||
|
|
||||||
/* If this is a compound datatype, check if it is packed */
|
/* If this is a compound datatype, check if it is packed */
|
||||||
if(dt->shared->type == H5T_COMPOUND)
|
if(dt->shared->type == H5T_COMPOUND) {
|
||||||
ret_value = (htri_t)dt->shared->u.compnd.packed;
|
H5T_compnd_t *compnd = &(dt->shared->u.compnd); /* Convenience pointer to compound info */
|
||||||
|
ret_value = (htri_t)(compnd->packed
|
||||||
|
&& compnd->memb[compnd->nmembs - 1].offset
|
||||||
|
+ compnd->memb[compnd->nmembs - 1].size
|
||||||
|
== dt->shared->size);
|
||||||
|
}
|
||||||
|
|
||||||
FUNC_LEAVE_NOAPI(ret_value)
|
FUNC_LEAVE_NOAPI(ret_value)
|
||||||
} /* end H5T_is_packed() */
|
} /* end H5T_is_packed() */
|
||||||
|
126
test/dtypes.c
126
test/dtypes.c
@ -2958,8 +2958,6 @@ test_compound_16(void)
|
|||||||
} cmpd_struct;
|
} cmpd_struct;
|
||||||
|
|
||||||
cmpd_struct wdata1 = {1254, 5471};
|
cmpd_struct wdata1 = {1254, 5471};
|
||||||
cmpd_struct rdata;
|
|
||||||
int wdata2[2] = {1, 2};
|
|
||||||
int obj_count;
|
int obj_count;
|
||||||
hid_t file;
|
hid_t file;
|
||||||
hid_t cmpd_m_tid, cmpd_f_tid, int_id;
|
hid_t cmpd_m_tid, cmpd_f_tid, int_id;
|
||||||
@ -3024,6 +3022,129 @@ error:
|
|||||||
return 1;
|
return 1;
|
||||||
} /* end test_compound_16() */
|
} /* end test_compound_16() */
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* Function: test_compound_17
|
||||||
|
*
|
||||||
|
* Purpose: Tests that compound types are packed correctly when they
|
||||||
|
* only have extra space at the end. The compounds are
|
||||||
|
* "hidden" inside arrays to make sure that they are still
|
||||||
|
* detected correctly.
|
||||||
|
*
|
||||||
|
* Return: Success: 0
|
||||||
|
*
|
||||||
|
* Failure: number of errors
|
||||||
|
*
|
||||||
|
* Programmer: Neil Fortner
|
||||||
|
* Tuesday, January 13, 2009
|
||||||
|
*
|
||||||
|
* Modifications:
|
||||||
|
*
|
||||||
|
*-------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
test_compound_17(void)
|
||||||
|
{
|
||||||
|
hid_t file;
|
||||||
|
hid_t cmpd_int, arr_int, cmpd_ext, arr_ext, tmp_dt;
|
||||||
|
hsize_t dims[1] = {2};
|
||||||
|
char filename[1024];
|
||||||
|
|
||||||
|
TESTING("that H5Tpack removes trailing bytes");
|
||||||
|
|
||||||
|
/* Create inner compound datatype. This type will be "packed" according
|
||||||
|
* to the internal field, but will have trailing space at the end. */
|
||||||
|
if((cmpd_int = H5Tcreate(H5T_COMPOUND, 4)) < 0) TEST_ERROR
|
||||||
|
if(H5Tinsert(cmpd_int, "c", 0, H5T_NATIVE_CHAR) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Create inner array datatype */
|
||||||
|
if((arr_int = H5Tarray_create2(cmpd_int, 1, dims)) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Create outer compound datatype. This type will be truly packed, with no
|
||||||
|
* trailing space. However, the internal compound contained within is not
|
||||||
|
* packed. */
|
||||||
|
if((cmpd_ext = H5Tcreate(H5T_COMPOUND, 8)) < 0) TEST_ERROR
|
||||||
|
if(H5Tinsert(cmpd_ext, "arr", 0, arr_int) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Create outer array datatype */
|
||||||
|
if((arr_ext = H5Tarray_create2(cmpd_ext, 1, dims)) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Try packing the internal array. Size should be 2 after packing. */
|
||||||
|
if((tmp_dt = H5Tcopy(arr_int)) < 0) TEST_ERROR
|
||||||
|
if(H5Tpack(tmp_dt) < 0) TEST_ERROR
|
||||||
|
if(2 != H5Tget_size(tmp_dt)) {
|
||||||
|
H5_FAILED(); AT();
|
||||||
|
printf(" Size after packing: %d; expected: 2\n", H5Tget_size(tmp_dt));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if(H5Tclose(tmp_dt) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Try packing the external array. Size should be 4 after packing. */
|
||||||
|
if((tmp_dt = H5Tcopy(arr_ext)) < 0) TEST_ERROR
|
||||||
|
if(H5Tpack(tmp_dt) < 0) TEST_ERROR
|
||||||
|
if(4 != H5Tget_size(tmp_dt)) {
|
||||||
|
H5_FAILED(); AT();
|
||||||
|
printf(" Size after packing: %d; expected: 4\n", H5Tget_size(tmp_dt));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if(H5Tclose(tmp_dt) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Now we will commit arr_int and arr_ext to a file, and verify that they
|
||||||
|
* are still packed correctly after opening them from the file */
|
||||||
|
/* Create File */
|
||||||
|
h5_fixname(FILENAME[3], H5P_DEFAULT, filename, sizeof filename);
|
||||||
|
if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Commit the datatypes. Note that they are still unpacked. */
|
||||||
|
if(H5Tcommit2(file, "arr_int", arr_int, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
|
||||||
|
if(H5Tcommit2(file, "arr_ext", arr_ext, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Close IDs */
|
||||||
|
if(H5Tclose(cmpd_int) < 0) TEST_ERROR
|
||||||
|
if(H5Tclose(arr_int) < 0) TEST_ERROR
|
||||||
|
if(H5Tclose(cmpd_ext) < 0) TEST_ERROR
|
||||||
|
if(H5Tclose(arr_ext) < 0) TEST_ERROR
|
||||||
|
if(H5Fclose(file) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Reopen file */
|
||||||
|
if((file = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Open committed array datatypes */
|
||||||
|
if((arr_int = H5Topen2(file, "arr_int", H5P_DEFAULT)) < 0) TEST_ERROR
|
||||||
|
if((arr_ext = H5Topen2(file, "arr_ext", H5P_DEFAULT)) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Try packing the internal array. Size should be 2 after packing. */
|
||||||
|
if((tmp_dt = H5Tcopy(arr_int)) < 0) TEST_ERROR
|
||||||
|
if(H5Tpack(tmp_dt) < 0) TEST_ERROR
|
||||||
|
if(2 != H5Tget_size(tmp_dt)) {
|
||||||
|
H5_FAILED(); AT();
|
||||||
|
printf(" Size after packing: %d; expected: 2\n", H5Tget_size(tmp_dt));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if(H5Tclose(tmp_dt) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Try packing the external array. Size should be 4 after packing. */
|
||||||
|
if((tmp_dt = H5Tcopy(arr_ext)) < 0) TEST_ERROR
|
||||||
|
if(H5Tpack(tmp_dt) < 0) TEST_ERROR
|
||||||
|
if(4 != H5Tget_size(tmp_dt)) {
|
||||||
|
H5_FAILED(); AT();
|
||||||
|
printf(" Size after packing: %d; expected: 4\n", H5Tget_size(tmp_dt));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if(H5Tclose(tmp_dt) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
/* Close IDs */
|
||||||
|
if(H5Tclose(arr_int) < 0) TEST_ERROR
|
||||||
|
if(H5Tclose(arr_ext) < 0) TEST_ERROR
|
||||||
|
if(H5Fclose(file) < 0) TEST_ERROR
|
||||||
|
|
||||||
|
PASSED();
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
return 1;
|
||||||
|
} /* end test_compound_17() */
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
* Function: test_query
|
* Function: test_query
|
||||||
@ -5719,6 +5840,7 @@ main(void)
|
|||||||
nerrors += test_compound_14();
|
nerrors += test_compound_14();
|
||||||
nerrors += test_compound_15();
|
nerrors += test_compound_15();
|
||||||
nerrors += test_compound_16();
|
nerrors += test_compound_16();
|
||||||
|
nerrors += test_compound_17();
|
||||||
nerrors += test_conv_enum_1();
|
nerrors += test_conv_enum_1();
|
||||||
nerrors += test_conv_enum_2();
|
nerrors += test_conv_enum_2();
|
||||||
nerrors += test_conv_bitfield();
|
nerrors += test_conv_bitfield();
|
||||||
|
Loading…
Reference in New Issue
Block a user