diff options
-rw-r--r-- | src/H5Osdspace.c | 4 | ||||
-rw-r--r-- | src/H5S.c | 95 | ||||
-rw-r--r-- | src/H5Spkg.h | 2 | ||||
-rw-r--r-- | src/H5Sprivate.h | 2 | ||||
-rw-r--r-- | src/H5Spublic.h | 2 | ||||
-rw-r--r-- | src/H5Sselect.c | 9 | ||||
-rw-r--r-- | src/H5public.h | 1 | ||||
-rw-r--r-- | test/big.c | 12 | ||||
-rw-r--r-- | test/file_image.c | 15 | ||||
-rw-r--r-- | test/h5test.c | 93 | ||||
-rw-r--r-- | test/h5test.h | 2 |
11 files changed, 134 insertions, 103 deletions
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 0f3eb5d..28021de 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -312,7 +312,7 @@ H5O_sdspace_copy(const void *_mesg, void *_dest) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy extent information */ - if(H5S_extent_copy(dest, mesg, TRUE) < 0) + if(H5S_extent_copy_real(dest, mesg, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent") /* Set return value */ @@ -467,7 +467,7 @@ H5O_sdspace_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "dataspace extent allocation failed") /* Create a copy of the dataspace extent */ - if(H5S_extent_copy(udata->src_space_extent, src_space_extent, TRUE) < 0) + if(H5S_extent_copy_real(udata->src_space_extent, src_space_extent, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent") } /* end if */ @@ -49,11 +49,9 @@ /********************/ /* Local Prototypes */ /********************/ -static herr_t H5S_set_extent_simple (H5S_t *space, unsigned rank, - const hsize_t *dims, const hsize_t *max); static htri_t H5S_is_simple(const H5S_t *sdim); -static herr_t H5S_encode(H5S_t *obj, unsigned char *buf, size_t *nalloc); -static H5S_t *H5S_decode(const unsigned char *buf); +static herr_t H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc); +static H5S_t *H5S_decode(const unsigned char **p); /*********************/ @@ -524,7 +522,40 @@ H5Sextent_copy(hid_t dst_id,hid_t src_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Copy */ - if(H5S_extent_copy(&(dst->extent), &(src->extent), TRUE) < 0) + if(H5S_extent_copy(dst, src) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Sextent_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5S_extent_copy + * + * Purpose: Copies a dataspace extent + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Monday, February 23, 2015 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5S_extent_copy(H5S_t *dst, const H5S_t *src) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(dst); + HDassert(src); + + /* Copy extent */ + if(H5S_extent_copy_real(&(dst->extent), &(src->extent), TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent") /* If the selection is 'all', update the number of elements selected in the @@ -534,12 +565,12 @@ H5Sextent_copy(hid_t dst_id,hid_t src_id) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") done: - FUNC_LEAVE_API(ret_value) -} /* end H5Sextent_copy() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5S_extent_copy() */ /*------------------------------------------------------------------------- - * Function: H5S_extent_copy + * Function: H5S_extent_copy_real * * Purpose: Copies a dataspace extent * @@ -553,7 +584,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_max) +H5S_extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_max) { unsigned u; herr_t ret_value = SUCCEED; /* Return value */ @@ -606,7 +637,7 @@ H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_max) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_extent_copy() */ +} /* end H5S_extent_copy_real() */ /*------------------------------------------------------------------------- @@ -642,7 +673,7 @@ H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the source dataspace's extent */ - if(H5S_extent_copy(&(dst->extent), &(src->extent), copy_max) < 0) + if(H5S_extent_copy_real(&(dst->extent), &(src->extent), copy_max) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent") /* Copy the source dataspace's selection */ @@ -1307,14 +1338,14 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, const hsize_t *max) { unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(rank <= H5S_MAX_RANK); @@ -1520,7 +1551,7 @@ H5Sencode(hid_t obj_id, void *buf, size_t *nalloc) if (NULL==(dspace=(H5S_t *)H5I_object_verify(obj_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_encode(dspace, (unsigned char *)buf, nalloc)<0) + if(H5S_encode(dspace, (unsigned char **)&buf, nalloc)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") done: @@ -1545,7 +1576,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S_encode(H5S_t *obj, unsigned char *buf, size_t *nalloc) +H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc) { size_t extent_size; /* Size of serialized dataspace extent */ hssize_t sselect_size; /* Signed size of serialized dataspace selection */ @@ -1570,28 +1601,28 @@ H5S_encode(H5S_t *obj, unsigned char *buf, size_t *nalloc) /* Verify the size of buffer. If it's not big enough, simply return the * right size without filling the buffer. */ - if(!buf || *nalloc < (extent_size + select_size + 1 + 1 + 1 + 4)) + if(!*p || *nalloc < (extent_size + select_size + 1 + 1 + 1 + 4)) *nalloc = extent_size + select_size + 1 + 1 + 1 + 4; else { /* Encode the type of the information */ - *buf++ = H5O_SDSPACE_ID; + *(*p)++ = H5O_SDSPACE_ID; /* Encode the version of the dataspace information */ - *buf++ = H5S_ENCODE_VERSION; + *(*p)++ = H5S_ENCODE_VERSION; /* Encode the "size of size" information */ - *buf++ = (unsigned char)H5F_SIZEOF_SIZE(f); + *(*p)++ = (unsigned char)H5F_SIZEOF_SIZE(f); /* Encode size of extent information. Pointer is actually moved in this macro. */ - UINT32ENCODE(buf, extent_size); + UINT32ENCODE(*p, extent_size); /* Encode the extent part of dataspace */ - if(H5O_msg_encode(f, H5O_SDSPACE_ID, TRUE, buf, obj) < 0) + if(H5O_msg_encode(f, H5O_SDSPACE_ID, TRUE, *p, obj) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode extent space") - buf += extent_size; + *p += extent_size; /* Encode the selection part of dataspace. */ - if(H5S_SELECT_SERIALIZE(obj, &buf) < 0) + if(H5S_SELECT_SERIALIZE(obj, p) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode select space") } /* end else */ @@ -1632,7 +1663,7 @@ H5Sdecode(const void *buf) if(buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty buffer") - if((ds = H5S_decode((const unsigned char *)buf)) == NULL) + if((ds = H5S_decode((const unsigned char **)&buf)) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, FAIL, "can't decode object") /* Register the type and return the ID */ @@ -1661,7 +1692,7 @@ done: *------------------------------------------------------------------------- */ static H5S_t* -H5S_decode(const unsigned char *buf) +H5S_decode(const unsigned char **p) { H5S_t *ds; H5S_extent_t *extent; @@ -1673,28 +1704,28 @@ H5S_decode(const unsigned char *buf) FUNC_ENTER_NOAPI_NOINIT /* Decode the type of the information */ - if(*buf++ != H5O_SDSPACE_ID) + if(*(*p)++ != H5O_SDSPACE_ID) HGOTO_ERROR(H5E_DATASPACE, H5E_BADMESG, NULL, "not an encoded dataspace") /* Decode the version of the dataspace information */ - if(*buf++ != H5S_ENCODE_VERSION) + if(*(*p)++ != H5S_ENCODE_VERSION) HGOTO_ERROR(H5E_DATASPACE, H5E_VERSION, NULL, "unknown version of encoded dataspace") /* Decode the "size of size" information */ - sizeof_size = *buf++; + sizeof_size = *(*p)++; /* Allocate "fake" file structure */ if(NULL == (f = H5F_fake_alloc(sizeof_size))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate fake file struct") /* Decode size of extent information */ - UINT32DECODE(buf, extent_size); + UINT32DECODE(*p, extent_size); /* Decode the extent part of dataspace */ /* (pass mostly bogus file pointer and bogus DXPL) */ - if((extent = (H5S_extent_t *)H5O_msg_decode(f, H5P_DEFAULT, NULL, H5O_SDSPACE_ID, buf))==NULL) + if((extent = (H5S_extent_t *)H5O_msg_decode(f, H5P_DEFAULT, NULL, H5O_SDSPACE_ID, *p))==NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode object") - buf += extent_size; + *p += extent_size; /* Copy the extent into dataspace structure */ if((ds = H5FL_CALLOC(H5S_t))==NULL) @@ -1710,7 +1741,7 @@ H5S_decode(const unsigned char *buf) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") /* Decode the select part of dataspace. I believe this part always exists. */ - if(H5S_SELECT_DESERIALIZE(&ds, &buf) < 0) + if(H5S_SELECT_DESERIALIZE(&ds, p) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode space selection") /* Set return value */ diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 0f2adf1..933de64 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -245,7 +245,7 @@ H5_DLLVAR const H5S_select_class_t H5S_sel_point[1]; /* Extent functions */ H5_DLL herr_t H5S_extent_release(H5S_extent_t *extent); -H5_DLL herr_t H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src, +H5_DLL herr_t H5S_extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_max); /* Operations on selections */ diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 54c70f0..cccfd6d 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -190,6 +190,8 @@ H5_DLL herr_t H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, H5S_t *ds); H5_DLL H5S_t *H5S_read(const struct H5O_loc_t *loc, hid_t dxpl_id); H5_DLL htri_t H5S_set_extent(H5S_t *space, const hsize_t *size); H5_DLL herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size); +H5_DLL herr_t H5S_set_extent_simple(H5S_t *space, unsigned rank, + const hsize_t *dims, const hsize_t *max); H5_DLL H5S_t *H5S_create(H5S_class_t type); H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]); diff --git a/src/H5Spublic.h b/src/H5Spublic.h index 37d3866..721c4bf 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -25,7 +25,7 @@ /* Define atomic datatypes */ #define H5S_ALL (hid_t)0 -#define H5S_UNLIMITED ((hsize_t)(hssize_t)(-1)) +#define H5S_UNLIMITED HSIZE_UNDEF /* Define user-level maximum number of dimensions */ #define H5S_MAX_RANK 32 diff --git a/src/H5Sselect.c b/src/H5Sselect.c index a9c0aa1..153c691 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -482,9 +482,14 @@ H5S_select_deserialize(H5S_t **space, const uint8_t **p) /* Decode the rank of the point selection */ UINT32DECODE(*p,rank); - if(!*space) + if(!*space) { + hsize_t dims[H5S_MAX_RANK]; + /* Patch the rank of the allocated dataspace */ - tmp_space->extent.rank = rank; + (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0])); + if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions") + } /* end if */ else /* Verify the rank of the provided dataspace */ if(rank != tmp_space->extent.rank) diff --git a/src/H5public.h b/src/H5public.h index e1fdd9e..1c617d1 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -176,6 +176,7 @@ H5_GCC_DIAG_ON(long-long) #else # error "nothing appropriate for hsize_t" #endif +#define HSIZE_UNDEF ((hsize_t)(hssize_t)(-1)) /* * File addresses have their own types. @@ -618,8 +618,8 @@ test_sec2(hid_t fapl) quit: /* End with normal return code */ /* Clean up the test file */ - if(h5_clean_files(FILENAME, fapl)) - HDremove(DNAME); + h5_clean_files(FILENAME, fapl); + HDremove(DNAME); return 0; error: @@ -655,8 +655,8 @@ test_stdio(hid_t fapl) quit: /* End with normal return code */ /* Clean up the test file */ - if(h5_clean_files(FILENAME, fapl)) - HDremove(DNAME); + h5_clean_files(FILENAME, fapl); + HDremove(DNAME); HDfflush(stdout); return 0; @@ -716,8 +716,8 @@ test_family(hid_t fapl) quit: /* End with normal return code */ /* Clean up the test file */ - if(h5_clean_files(FILENAME, fapl)) - HDremove(DNAME); + h5_clean_files(FILENAME, fapl); + HDremove(DNAME); return 0; error: diff --git a/test/file_image.c b/test/file_image.c index 42199cb..d9c782a 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -890,8 +890,7 @@ test_get_file_image(const char * test_banner, VERIFY(err == SUCCEED, "H5Pclose(core_fapl_id) failed."); /* tidy up */ - result = h5_clean_files(FILENAME2, fapl); - VERIFY(result != 0, "h5_clean_files() failed."); + h5_clean_files(FILENAME2, fapl); /* discard the image buffer if it exists */ if(image_ptr != NULL) @@ -1039,8 +1038,7 @@ test_get_file_image_error_rejection(void) VERIFY(err == SUCCEED, "H5Fclose(file_id) failed."); /* tidy up */ - result = h5_clean_files(FILENAME2, fapl_id); - VERIFY(result != 0, "h5_clean_files(1) failed."); + h5_clean_files(FILENAME2, fapl_id); /* discard the image buffer if it exists */ if(image_ptr != NULL) @@ -1145,8 +1143,7 @@ test_get_file_image_error_rejection(void) VERIFY(err == SUCCEED, "H5Fclose(2) failed."); /* tidy up */ - result = h5_clean_files(FILENAME2, fapl_id); - VERIFY(result != 0, "h5_clean_files(2 failed."); + h5_clean_files(FILENAME2, fapl_id); /************************** Test #3 **********************************/ /* set up a split file driver test file, and try to get its image @@ -1208,8 +1205,7 @@ test_get_file_image_error_rejection(void) VERIFY(err == SUCCEED, "H5Fclose(2) failed."); /* tidy up */ - result = h5_clean_files(FILENAME2, fapl_id); - VERIFY(result != 0, "h5_clean_files(2 failed."); + h5_clean_files(FILENAME2, fapl_id); /************************** Test #4 **********************************/ /* set up a family file driver test file, and try to get its image @@ -1269,8 +1265,7 @@ test_get_file_image_error_rejection(void) VERIFY(err == SUCCEED, "H5Fclose(2) failed."); /* tidy up */ - result = h5_clean_files(FILENAME2, fapl_id); - VERIFY(result != 0, "h5_clean_files(2 failed."); + h5_clean_files(FILENAME2, fapl_id); PASSED(); diff --git a/test/h5test.c b/test/h5test.c index 51ec2ca..f936605 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -127,75 +127,68 @@ h5_errors(hid_t estack, void H5_ATTR_UNUSED *client_data) /*------------------------------------------------------------------------- * Function: h5_clean_files * - * Purpose: Cleanup temporary test files. + * Purpose: Cleanup temporary test files (always). * base_name contains the list of test file names. - * The file access property list is also closed. * - * Return: Non-zero if cleanup actions were performed; zero otherwise. + * Return: void * - * Programmer: Quincey Koziol - * September 13, 2015 + * Programmer: Neil Fortner + * June 1, 2015 * *------------------------------------------------------------------------- */ -int +void h5_clean_files(const char *base_name[], hid_t fapl) { - int retval = 0; + int i; - if(GetTestCleanup()) { - int i; - - for(i = 0; base_name[i]; i++) { - char filename[1024]; - char temp[2048]; - hid_t driver; - - if(NULL == h5_fixname(base_name[i], fapl, filename, sizeof(filename))) - continue; + for(i = 0; base_name[i]; i++) { + char filename[1024]; + char temp[2048]; + hid_t driver; - driver = H5Pget_driver(fapl); - - if(driver == H5FD_FAMILY) { - int j; + if(NULL == h5_fixname(base_name[i], fapl, filename, sizeof(filename))) + continue; - for(j = 0; /*void*/; j++) { - HDsnprintf(temp, sizeof temp, filename, j); + driver = H5Pget_driver(fapl); - if(HDaccess(temp, F_OK) < 0) - break; + if(driver == H5FD_FAMILY) { + int j; - HDremove(temp); - } /* end for */ - } else if(driver == H5FD_CORE) { - hbool_t backing; /* Whether the core file has backing store */ + for(j = 0; /*void*/; j++) { + HDsnprintf(temp, sizeof temp, filename, j); - H5Pget_fapl_core(fapl, NULL, &backing); + if(HDaccess(temp, F_OK) < 0) + break; - /* If the file was stored to disk with bacing store, remove it */ - if(backing) - HDremove(filename); - } else if (driver == H5FD_MULTI) { - H5FD_mem_t mt; + HDremove(temp); + } /* end for */ + } else if(driver == H5FD_CORE) { + hbool_t backing; /* Whether the core file has backing store */ - HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); + H5Pget_fapl_core(fapl, NULL, &backing); - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { - HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]); - HDremove(temp); /*don't care if it fails*/ - } /* end for */ - } else { + /* If the file was stored to disk with bacing store, remove it */ + if(backing) HDremove(filename); - } - } /* end for */ + } else if (driver == H5FD_MULTI) { + H5FD_mem_t mt; - retval = 1; - } /* end if */ + HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); + + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { + HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]); + HDremove(temp); /*don't care if it fails*/ + } /* end for */ + } else { + HDremove(filename); + } + } /* end for */ /* Close the FAPL used to access the file */ H5Pclose(fapl); - return retval; + return; } /* end h5_clean_files() */ @@ -218,8 +211,12 @@ h5_cleanup(const char *base_name[], hid_t fapl) { int retval = 0; - /* Clean up the files and the FAPL */ - retval = h5_clean_files(base_name, fapl); + if(GetTestCleanup()) { + /* Clean up files in base_name, and the FAPL */ + h5_clean_files(base_name, fapl); + + retval = 1; + } /* end if */ /* Restore the original error reporting routine */ h5_restore_err(); diff --git a/test/h5test.h b/test/h5test.h index 615ca4f..f949375 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -123,7 +123,7 @@ extern "C" { #endif /* Generally useful testing routines */ -H5TEST_DLL int h5_clean_files(const char *base_name[], hid_t fapl); +H5TEST_DLL void h5_clean_files(const char *base_name[], hid_t fapl); H5TEST_DLL int h5_cleanup(const char *base_name[], hid_t fapl); H5TEST_DLL char *h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size); H5TEST_DLL char *h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size); |