From 050dd023870ac6858eaf55c20c7ffd46e97b1454 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 14 Sep 2015 11:21:31 -0500 Subject: [svn-r27771] Description: Merge in part of Neil's property list fixes: Fix a minor memory leak, add some sanity checks, clean up the code a little, and verify that encoding/ decoding default versions of the property lists works correctly. Tested on: MacOSX/64 10.10.5 (amazon) w/serial (Too minor to require h5committest) --- src/H5Pdapl.c | 2 +- src/H5Pocpl.c | 3 ++ src/H5Pocpypl.c | 8 ++++ test/enc_dec_plist.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 121 insertions(+), 13 deletions(-) diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index 833f3f0..7b5108a 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -283,5 +283,5 @@ H5Pget_chunk_cache(hid_t dapl_id, size_t *rdcc_nslots, size_t *rdcc_nbytes, doub done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pget_chunk_cache */ diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index 08eba3d..1975283 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -1640,6 +1640,9 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) /* Add the filter to the I/O pipeline */ if(H5Z_append(pline, filter.id, filter.flags, filter.cd_nelmts, filter.cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline") + + /* Free cd_values, if it was allocated */ + filter.cd_values = (unsigned *)H5MM_xfree(filter.cd_values); } /* end for */ done: diff --git a/src/H5Pocpypl.c b/src/H5Pocpypl.c index 08db49f..4a47dbc 100644 --- a/src/H5Pocpypl.c +++ b/src/H5Pocpypl.c @@ -296,6 +296,9 @@ H5P__ocpy_merge_comm_dt_list_dec(const void **_pp, void *_value) HDassert(pp); HDassert(*pp); HDassert(dt_list); + + /* Start off with NULL (default value) */ + *dt_list = NULL; /* Decode the string sequence */ len = HDstrlen(*(const char **)pp); @@ -440,6 +443,9 @@ H5P__ocpy_merge_comm_dt_list_cmp(const void *_dt_list1, const void *_dt_list2, /* Walk through the lists, comparing each path. For the lists to be the * same, the paths must be in the same order. */ while(dt_list1 && dt_list2) { + HDassert(dt_list1->path); + HDassert(dt_list2->path); + /* Compare paths */ ret_value = HDstrcmp(dt_list1->path, dt_list2->path); if(ret_value != 0) HGOTO_DONE(ret_value) @@ -602,6 +608,8 @@ H5Padd_merge_committed_dtype_path(hid_t plist_id, const char *path) /* Check parameters */ if(!path) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no path specified") + if(path[0] == '\0') + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "path is empty string") /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c index 4832767..4f0147e 100644 --- a/test/enc_dec_plist.c +++ b/test/enc_dec_plist.c @@ -122,10 +122,18 @@ main(void) printf("Encode/Decode DCPLs\n"); /******* ENCODE/DECODE DCPLS *****/ - TESTING("DCPL Encoding/Decoding"); + TESTING("Default DCPL Encoding/Decoding"); if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(dcpl) < 0) + FAIL_PUTS_ERROR("Default DCPL encoding/decoding failed\n") + + PASSED(); + + TESTING("DCPL Encoding/Decoding"); + if((H5Pset_chunk(dcpl, 2, chunk_size)) < 0) FAIL_STACK_ERROR @@ -161,10 +169,18 @@ main(void) /******* ENCODE/DECODE DAPLS *****/ - TESTING("DAPL Encoding/Decoding"); + TESTING("Default DAPL Encoding/Decoding"); if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(dapl) < 0) + FAIL_PUTS_ERROR("Default DAPL encoding/decoding failed\n") + + PASSED(); + + TESTING("DAPL Encoding/Decoding"); + if((H5Pset_chunk_cache(dapl, nslots, nbytes, w0)) < 0) FAIL_STACK_ERROR @@ -180,10 +196,18 @@ main(void) /******* ENCODE/DECODE OCPLS *****/ - TESTING("OCPL Encoding/Decoding"); + TESTING("Default OCPL Encoding/Decoding"); if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(ocpl) < 0) + FAIL_PUTS_ERROR("Default OCPL encoding/decoding failed\n") + + PASSED(); + + TESTING("OCPL Encoding/Decoding"); + if((H5Pset_attr_creation_order(ocpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) FAIL_STACK_ERROR @@ -205,9 +229,18 @@ main(void) /******* ENCODE/DECODE DXPLS *****/ - TESTING("DXPL Encoding/Decoding"); + TESTING("Default DXPL Encoding/Decoding"); if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(dxpl) < 0) + FAIL_PUTS_ERROR("Default DXPL encoding/decoding failed\n") + + PASSED(); + + TESTING("DXPL Encoding/Decoding"); + if((H5Pset_btree_ratios(dxpl, 0.2f, 0.6f, 0.2f)) < 0) FAIL_STACK_ERROR if((H5Pset_hyper_vector_size(dxpl, 5)) < 0) @@ -241,10 +274,18 @@ main(void) /******* ENCODE/DECODE GCPLS *****/ - TESTING("GCPL Encoding/Decoding"); + TESTING("Default GCPL Encoding/Decoding"); if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(gcpl) < 0) + FAIL_PUTS_ERROR("Default GCPL encoding/decoding failed\n") + + PASSED(); + + TESTING("GCPL Encoding/Decoding"); + if((H5Pset_local_heap_size_hint(gcpl, 256)) < 0) FAIL_STACK_ERROR @@ -273,10 +314,18 @@ main(void) /******* ENCODE/DECODE LCPLS *****/ - TESTING("LCPL Encoding/Decoding"); + TESTING("Default LCPL Encoding/Decoding"); if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(lcpl) < 0) + FAIL_PUTS_ERROR("Default LCPL encoding/decoding failed\n") + + PASSED(); + + TESTING("LCPL Encoding/Decoding"); + if((H5Pset_create_intermediate_group(lcpl, TRUE)) < 0) FAIL_STACK_ERROR @@ -292,10 +341,18 @@ main(void) /******* ENCODE/DECODE LAPLS *****/ - TESTING("LAPL Encoding/Decoding"); + TESTING("Default LAPL Encoding/Decoding"); if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0) FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(lapl) < 0) + FAIL_PUTS_ERROR("Default LAPL encoding/decoding failed\n") + + PASSED(); + + TESTING("LAPL Encoding/Decoding"); + if((H5Pset_nlinks(lapl, (size_t)134)) < 0) FAIL_STACK_ERROR @@ -330,10 +387,18 @@ main(void) /******* ENCODE/DECODE OCPYPLS *****/ - TESTING("OCPYPL Encoding/Decoding"); + TESTING("Default OCPYPL Encoding/Decoding"); if((ocpypl = H5Pcreate(H5P_OBJECT_COPY)) < 0) FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(ocpypl) < 0) + FAIL_PUTS_ERROR("Default OCPYPL encoding/decoding failed\n") + + PASSED(); + + TESTING("OCPYPL Encoding/Decoding"); + if((H5Pset_copy_object(ocpypl, H5O_COPY_EXPAND_EXT_LINK_FLAG)) < 0) FAIL_STACK_ERROR @@ -354,10 +419,18 @@ main(void) /******* ENCODE/DECODE FAPLS *****/ - TESTING("FAPL Encoding/Decoding"); + TESTING("Default FAPL Encoding/Decoding"); if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(fapl) < 0) + FAIL_PUTS_ERROR("Default FAPL encoding/decoding failed\n") + + PASSED(); + + TESTING("FAPL Encoding/Decoding"); + if((H5Pset_family_offset(fapl, 1024)) < 0) FAIL_STACK_ERROR if((H5Pset_meta_block_size(fapl, 2098452)) < 0) @@ -397,11 +470,19 @@ main(void) /******* ENCODE/DECODE FCPLS *****/ - TESTING("FCPL Encoding/Decoding"); + TESTING("Default FCPL Encoding/Decoding"); if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(fcpl) < 0) + FAIL_PUTS_ERROR("Default FCPL encoding/decoding failed\n") + + PASSED(); + + TESTING("FCPL Encoding/Decoding"); + if((H5Pset_userblock(fcpl, 1024) < 0)) FAIL_STACK_ERROR @@ -435,11 +516,19 @@ main(void) /******* ENCODE/DECODE STRCPLS *****/ - TESTING("STRCPL Encoding/Decoding"); + TESTING("Default STRCPL Encoding/Decoding"); if((strcpl = H5Pcreate(H5P_STRING_CREATE)) < 0) FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(strcpl) < 0) + FAIL_PUTS_ERROR("Default STRCPL encoding/decoding failed\n") + + PASSED(); + + TESTING("STRCPL Encoding/Decoding"); + if((H5Pset_char_encoding(strcpl, H5T_CSET_UTF8) < 0)) FAIL_STACK_ERROR @@ -455,11 +544,19 @@ main(void) /******* ENCODE/DECODE ACPLS *****/ - TESTING("ACPL Encoding/Decoding"); + TESTING("Default ACPL Encoding/Decoding"); if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(acpl) < 0) + FAIL_PUTS_ERROR("Default ACPL encoding/decoding failed\n") + + PASSED(); + + TESTING("ACPL Encoding/Decoding"); + if((H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0)) FAIL_STACK_ERROR -- cgit v0.12