diff options
-rw-r--r-- | c++/test/tcompound.cpp | 34 | ||||
-rw-r--r-- | c++/test/tfilter.cpp | 87 | ||||
-rw-r--r-- | c++/test/tlinks.cpp | 1 | ||||
-rw-r--r-- | c++/test/trefer.cpp | 3 | ||||
-rw-r--r-- | c++/test/ttypes.cpp | 8 | ||||
-rw-r--r-- | c++/test/tvlstr.cpp | 28 | ||||
-rw-r--r-- | src/H5Tconv.c | 581 | ||||
-rw-r--r-- | test/mf.c | 132 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 57 | ||||
-rw-r--r-- | tools/lib/h5diff_dset.c | 251 |
10 files changed, 616 insertions, 566 deletions
diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index fb8bd17..fbb1219 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -115,7 +115,8 @@ static void test_compound_2() const int nelmts = NTESTELEM; const hsize_t four = 4; int i; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; + ArrayType *array_dt = NULL; // Output message about test being performed SUBTEST("Compound Element Reordering"); @@ -138,7 +139,7 @@ static void test_compound_2() memcpy(buf, orig, nelmts*sizeof(src_typ_t)); // Build hdf5 datatypes - ArrayType* array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); + array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); // Create an empty compound datatype CompType st(sizeof(src_typ_t)); @@ -148,6 +149,7 @@ static void test_compound_2() st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT); st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT); array_dt->close(); + delete array_dt; array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -202,6 +204,9 @@ static void test_compound_2() cerr << "test_compound_2 in catch" << endl; issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } + + if(array_dt) + delete array_dt; } // test_compound_2() @@ -235,7 +240,8 @@ static void test_compound_3() int i; const int nelmts = NTESTELEM; const hsize_t four = 4; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; + ArrayType* array_dt = NULL; // Output message about test being performed SUBTEST("Compound Datatype Subset Conversions"); @@ -258,7 +264,7 @@ static void test_compound_3() memcpy(buf, orig, nelmts*sizeof(src_typ_t)); /* Build hdf5 datatypes */ - ArrayType* array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); + array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); // Create an empty compound datatype CompType st(sizeof(src_typ_t)); @@ -268,6 +274,7 @@ static void test_compound_3() st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT); st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT); array_dt->close(); + delete array_dt; array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -319,6 +326,9 @@ static void test_compound_3() cerr << "test_compound_3 in catch" << endl; issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } + + if(array_dt) + delete array_dt; } // test_compound_3() @@ -357,7 +367,8 @@ static void test_compound_4() int i; const int nelmts = NTESTELEM; const hsize_t four = 4; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; + ArrayType* array_dt = NULL; // Output message about test being performed SUBTEST("Compound Element Shrinking & Reordering"); @@ -380,7 +391,7 @@ static void test_compound_4() memcpy(buf, orig, nelmts*sizeof(src_typ_t)); /* Build hdf5 datatypes */ - ArrayType* array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); + array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); // Create an empty compound datatype CompType st(sizeof(src_typ_t)); @@ -390,6 +401,7 @@ static void test_compound_4() st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT); st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT); array_dt->close(); + delete array_dt; array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -446,6 +458,9 @@ static void test_compound_4() cerr << "test_compound_4 in catch" << endl; issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } + + if(array_dt) + delete array_dt; } // test_compound_4() @@ -486,16 +501,18 @@ static void test_compound_5() dst_typ_t *dst; void *buf = calloc(2, sizeof(dst_typ_t)); void *bkg = calloc(2, sizeof(dst_typ_t)); + ArrayType* array_dt = NULL; // Output message about test being performed SUBTEST("Optimized Struct Converter"); try { /* Build datatypes */ - ArrayType* array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims); + array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims); CompType short_array(4*sizeof(short)); short_array.insertMember("_", 0, *array_dt); array_dt->close(); + delete array_dt; CompType int_array(4*sizeof(int)); array_dt = new ArrayType(PredType::NATIVE_INT, 1, dims); @@ -545,6 +562,9 @@ static void test_compound_5() cerr << "test_compound_5 in catch" << endl; issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } + + if(array_dt) + delete array_dt; } // test_compound_5() diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp index e59707a..0dbdf00 100644 --- a/c++/test/tfilter.cpp +++ b/c++/test/tfilter.cpp @@ -174,58 +174,61 @@ void test_szip_filter(H5File& file1) SUBTEST("szip filter (with encoder)"); if ( h5_szip_can_encode() == 1) { - char* tconv_buf = new char [1000]; - try { - const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; - - // Create the data space - DataSpace space1(2, size, NULL); + char* tconv_buf = new char [1000]; - // Create a small conversion buffer to test strip mining (?) - DSetMemXferPropList xfer; - xfer.setBuffer (1000, tconv_buf, NULL); + try { + const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; - // Prepare dataset create property list - DSetCreatPropList dsplist; - dsplist.setChunk(2, chunk_size); + // Create the data space + DataSpace space1(2, size, NULL); - // Set up for szip compression - dsplist.setSzip(szip_options_mask, szip_pixels_per_block); + // Create a small conversion buffer to test strip mining (?) + DSetMemXferPropList xfer; + xfer.setBuffer (1000, tconv_buf, NULL); - // Create a dataset with szip compression - DataSpace space2 (2, size, NULL); - DataSet dataset(file1.createDataSet (DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist)); + // Prepare dataset create property list + DSetCreatPropList dsplist; + dsplist.setChunk(2, chunk_size); - hsize_t i, j, n; - for (i=n=0; i<size[0]; i++) - { - for (j=0; j<size[1]; j++) - { - points[i][j] = (int)n++; - } - } + // Set up for szip compression + dsplist.setSzip(szip_options_mask, szip_pixels_per_block); - // Write to the dataset then read back the values - dataset.write ((void*)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - dataset.read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + // Create a dataset with szip compression + DataSpace space2 (2, size, NULL); + DataSet dataset(file1.createDataSet (DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist)); - // Check that the values read are the same as the values written - for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) + hsize_t i, j, n; + for (i=n=0; i<size[0]; i++) { - int status = check_values (i, j, points[i][j], check[i][j]); - if (status == -1) - throw Exception("test_szip_filter", "Failed in testing szip method"); + for (j=0; j<size[1]; j++) + { + points[i][j] = (int)n++; + } } - dsplist.close(); - PASSED(); - } // end of try - // catch all other exceptions - catch (Exception E) - { - issue_fail_msg("test_szip_filter()", __LINE__, __FILE__, E.getCDetailMsg()); - } + // Write to the dataset then read back the values + dataset.write ((void*)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + + // Check that the values read are the same as the values written + for (i = 0; i < size[0]; i++) + for (j = 0; j < size[1]; j++) + { + int status = check_values (i, j, points[i][j], check[i][j]); + if (status == -1) + throw Exception("test_szip_filter", "Failed in testing szip method"); + } + dsplist.close(); + PASSED(); + } // end of try + + // catch all other exceptions + catch (Exception E) + { + issue_fail_msg("test_szip_filter()", __LINE__, __FILE__, E.getCDetailMsg()); + } + + delete tconv_buf; } // if szip presents else { SKIPPED(); diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index 53a1c8c..e4e691a 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -403,7 +403,6 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) { hsize_t size[1] = {1}; char filename[NAME_BUF_SIZE]; - char* tconv_buf = new char [1000]; // Use the file access template id to create a file access prop. list. FileAccPropList fapl(fapl_id); diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index aeb202a..7f63d33 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -326,6 +326,9 @@ static void test_reference_obj(void) catch (Exception E) { issue_fail_msg("test_reference_obj()", __LINE__, __FILE__, E.getCDetailMsg()); } + + if(file1) + delete file1; } // test_reference_obj() /**************************************************************** diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index ef00c08..b1baa29 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -387,6 +387,7 @@ static void test_named () static hsize_t ds_size[2] = {10, 20}; hsize_t i; unsigned attr_data[10][20]; + DataType *ds_type = NULL; SUBTEST("Named datatypes"); try { @@ -462,12 +463,13 @@ now. // Create a dataset that uses the named type, then get the dataset's // datatype and make sure it's a named type. DataSet dset = file.createDataSet("dset1", another_type, space); - DataType *ds_type = new DataType(dset.getDataType()); + ds_type = new DataType(dset.getDataType()); iscommitted = ds_type->committed(); if (!iscommitted) throw InvalidActionException("IntType::committed()", "1 Dataset type should be named type!"); dset.close(); ds_type->close(); + delete ds_type; // Reopen the dataset and its type, then make sure the type is // a named type. @@ -483,6 +485,7 @@ now. dset = file.createDataSet("dset2", *ds_type, space); ds_type->close(); dset.close(); + delete ds_type; // Reopen the second dataset and make sure the type is shared dset = file.openDataSet("dset2"); @@ -509,6 +512,9 @@ now. catch (Exception E) { issue_fail_msg("test_named", __LINE__, __FILE__, E.getCDetailMsg()); } + + if(ds_type) + delete ds_type; } // test_named diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index 91036f9..73e54e0 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -129,7 +129,6 @@ void test_vlstr_free_custom(void *_mem, void *info) *------------------------------------------------------------------------- */ // String for testing datasets -static char *dynstring_ds_write=NULL; static char stastring_ds_write[1]={'A'}; // Info for a string dataset @@ -138,6 +137,9 @@ const H5std_string DSET1_DATA("String Dataset"); static void test_vlstring_dataset() { + char *dynstring_ds_write = NULL; + char *string_ds_check = NULL; + // Output message about test being performed SUBTEST("VL String on Datasets"); @@ -161,12 +163,12 @@ static void test_vlstring_dataset() dset1.write(DSET1_DATA, vlst); // Read and verify the dataset string as a string of chars. - char *string_ds_check; dset1.read(&string_ds_check, vlst); if(HDstrcmp(string_ds_check, DSET1_DATA.c_str())!=0) TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n",__LINE__, DSET1_DATA.c_str(), string_ds_check); HDfree(string_ds_check); // note: no need for std::string test + string_ds_check = NULL; // Read and verify the dataset string as an std::string. H5std_string read_str; @@ -191,6 +193,7 @@ static void test_vlstring_dataset() if(HDstrcmp(string_ds_check,dynstring_ds_write)!=0) TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n",dynstring_ds_write,string_ds_check); HDfree(string_ds_check); + string_ds_check = NULL; dset1.close(); // Open dataset DSET1_NAME again. @@ -207,6 +210,11 @@ static void test_vlstring_dataset() catch (Exception E) { issue_fail_msg("test_vlstring_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } + + if(dynstring_ds_write) + HDfree(dynstring_ds_write); + if(string_ds_check) + HDfree(string_ds_check); } // test_vlstring_dataset() /*------------------------------------------------------------------------- @@ -231,10 +239,10 @@ static void test_vlstring_array_dataset() // Output message about test being performed SUBTEST("VL String Array on Datasets"); - H5File* file1; + H5File* file1 = NULL; try { // Create file. - file1 = new H5File (FILENAME, H5F_ACC_RDWR); + file1 = new H5File(FILENAME, H5F_ACC_RDWR); // Create dataspace for datasets. hsize_t dims1[] = {SPACE1_DIM1}; @@ -278,8 +286,7 @@ static void test_vlstring_array_dataset() HDmemset(wdata2, 'A', 65533); dataset2.write(&wdata2, vlst); - char *rdata2 = (char*)HDcalloc(65534, sizeof(char)); - HDmemset(rdata2, 0, 65533); + char *rdata2; dataset2.read(&rdata2, vlst); if (HDstrcmp(wdata2, rdata2)!=0) TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, wdata2, rdata2); @@ -302,8 +309,10 @@ static void test_vlstring_array_dataset() catch (Exception E) { issue_fail_msg("test_vlstring_array_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); - delete file1; } + + if(file1) + delete file1; } // end test_vlstring_array_dataset() /*------------------------------------------------------------------------- @@ -482,6 +491,7 @@ static void test_vlstring_type() // Close datatype and file. vlst.close(); file1->close(); + delete file1; // Open file. file1 = new H5File(FILENAME, H5F_ACC_RDWR); @@ -506,8 +516,10 @@ static void test_vlstring_type() catch (Exception E) { issue_fail_msg("test_vlstring_type()", __LINE__, __FILE__, E.getCDetailMsg()); - delete file1; } + + if(file1) + delete file1; } // end test_vlstring_type() /*------------------------------------------------------------------------- diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 9d98e50..927a9dc 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -662,17 +662,16 @@ CI_INC_DST(d_mv) \ \ /* Get the plist structure */ \ - if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) \ - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID"); \ + if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) \ + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID") \ \ /* Get conversion exception callback property */ \ - if (H5P_get(plist,H5D_XFER_CONV_CB_NAME,&cb_struct)<0) \ - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); \ + if(H5P_get(plist, H5D_XFER_CONV_CB_NAME, &cb_struct) < 0) \ + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback") \ \ /* Get source and destination datatypes */ \ - if (NULL==(st=(H5T_t*)H5I_object(src_id)) || NULL==(dt=(H5T_t*)H5I_object(dst_id))) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ - "unable to dereference datatype object ID") \ + if(NULL == (st = (H5T_t *)H5I_object(src_id)) || NULL == (dt = (H5T_t *)H5I_object(dst_id))) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to dereference datatype object ID") \ \ /* Get source & destination precisions into a variable */ \ tclass = st->shared->type; \ @@ -1041,9 +1040,8 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, switch(cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset) @@ -1055,7 +1053,7 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, !((H5T_ORDER_BE == src->shared->u.atomic.order && H5T_ORDER_LE == dst->shared->u.atomic.order) || (H5T_ORDER_LE == src->shared->u.atomic.order && H5T_ORDER_BE == dst->shared->u.atomic.order))) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") - if (src->shared->size != 1 && src->shared->size != 2 && src->shared->size != 4 && + if(src->shared->size != 1 && src->shared->size != 2 && src->shared->size != 4 && src->shared->size != 8 && src->shared->size != 16) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") switch(src->shared->type) { @@ -1085,14 +1083,14 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, case H5T_CONV_CONV: /* The conversion */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Check for "no op" reference conversion */ if(src->shared->type == H5T_REFERENCE) { /* Sanity check */ - HDassert(dst->shared->type == H5T_REFERENCE); + if(dst->shared->type != H5T_REFERENCE) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_REFERENCE datatype") /* Check if we are on a little-endian machine (the order that * the addresses in the file must be) and just get out now, there @@ -1452,7 +1450,7 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Capability query */ if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset || !((H5T_ORDER_BE == src->shared->u.atomic.order && @@ -1487,9 +1485,8 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* The conversion */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if(NULL == (src = (H5T_t *)H5I_object(src_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") buf_stride = buf_stride ? buf_stride : src->shared->size; md = src->shared->size / 2; @@ -1535,7 +1532,7 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, void UNUSED *background, hid_t dxpl_id) { uint8_t *buf = (uint8_t*)_buf; - H5T_t *src = NULL, *dst = NULL; /*source and dest data types */ + H5T_t *src = NULL, *dst = NULL; /*source and dest datatypes */ int direction; /*direction of traversal */ size_t elmtno; /*element number */ size_t olap; /*num overlapping elements */ @@ -1558,7 +1555,7 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Capability query */ if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_ORDER_LE != src->shared->u.atomic.order && H5T_ORDER_BE != src->shared->u.atomic.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") @@ -1572,10 +1569,9 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, break; case H5T_CONV_CONV: - /* Get the data types */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + /* Get the datatypes */ + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* * Do we process the values from beginning to end or vice versa? Also, @@ -1777,24 +1773,26 @@ H5T_conv_struct_free(H5T_conv_struct_t *priv) hid_t *src_memb_id = priv->src_memb_id, *dst_memb_id = priv->dst_memb_id; unsigned i; - int status; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_conv_struct_free) - for (i=0; i<priv->src_nmembs; i++) - if (src2dst[i] >= 0) { + for(i = 0; i < priv->src_nmembs; i++) + if(src2dst[i] >= 0) { + int status; + status = H5I_dec_ref(src_memb_id[i]); HDassert(status >= 0); status = H5I_dec_ref(dst_memb_id[src2dst[i]]); HDassert(status >= 0); - } + } /* end if */ H5MM_xfree(src2dst); H5MM_xfree(src_memb_id); H5MM_xfree(dst_memb_id); H5MM_xfree(priv->memb_path); - FUNC_LEAVE_NOAPI((H5T_conv_struct_t *)H5MM_xfree(priv)); -} + + FUNC_LEAVE_NOAPI((H5T_conv_struct_t *)H5MM_xfree(priv)) +} /* end H5T_conv_struct_free() */ /*------------------------------------------------------------------------- @@ -1852,9 +1850,7 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) int *src2dst = NULL; unsigned src_nmembs, dst_nmembs; unsigned i, j; - H5T_t *type = NULL; - hid_t tid; - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_conv_struct_init) @@ -1900,9 +1896,12 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) } /* end if */ } /* end for */ if(src2dst[i] >= 0) { + hid_t tid; + H5T_t *type; + type = H5T_copy(src->shared->u.compnd.memb[i].type, H5T_COPY_ALL); tid = H5I_register(H5I_DATATYPE, type, FALSE); - HDassert(tid>=0); + HDassert(tid >= 0); priv->src_memb_id[i] = tid; type = H5T_copy(dst->shared->u.compnd.memb[src2dst[i]].type, H5T_COPY_ALL); @@ -1933,7 +1932,7 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) H5T_path_t *tpath = H5T_path_find(src->shared->u.compnd.memb[i].type, dst->shared->u.compnd.memb[src2dst[i]].type, NULL, NULL, dxpl_id, FALSE); if(NULL == (priv->memb_path[i] = tpath)) { - cdata->priv = priv = H5T_conv_struct_free(priv); + cdata->priv = H5T_conv_struct_free(priv); HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert member datatype") } /* end if */ } /* end if */ @@ -1959,8 +1958,8 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) * the end of src. */ if(priv->subset_info.subset == H5T_SUBSET_SRC) - priv->subset_info.copy_size = src->shared->u.compnd.memb[src_nmembs-1].offset - + src->shared->u.compnd.memb[src_nmembs-1].size; + priv->subset_info.copy_size = src->shared->u.compnd.memb[src_nmembs - 1].offset + + src->shared->u.compnd.memb[src_nmembs - 1].size; } else if(dst_nmembs < src_nmembs) { priv->subset_info.subset = H5T_SUBSET_DST; for(i = 0; i < dst_nmembs; i++) { @@ -2075,23 +2074,23 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, { uint8_t *buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ uint8_t *bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ - uint8_t *xbuf=buf, *xbkg=bkg; /*temp pointers into buf and bkg*/ + uint8_t *xbuf = buf, *xbkg = bkg; /*temp pointers into buf and bkg*/ H5T_t *src = NULL; /*source datatype */ H5T_t *dst = NULL; /*destination datatype */ int *src2dst = NULL; /*maps src member to dst member */ H5T_cmemb_t *src_memb = NULL; /*source struct member descript.*/ H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */ size_t offset; /*byte offset wrt struct */ - size_t src_delta; /*source stride */ + size_t src_delta; /*source stride */ size_t elmtno; - unsigned u; /*counters */ - int i; /*counters */ + unsigned u; /*counters */ + int i; /*counters */ H5T_conv_struct_t *priv = (H5T_conv_struct_t *)(cdata->priv); - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_struct, FAIL) - switch (cdata->command) { + switch(cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the @@ -2099,35 +2098,35 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * otherwise initialize the `priv' field of `cdata' with information * that remains (almost) constant for this conversion path. */ - if (NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); - assert (H5T_COMPOUND==src->shared->type); - assert (H5T_COMPOUND==dst->shared->type); + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") + if(H5T_COMPOUND != src->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") + if(H5T_COMPOUND != dst->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") - if (H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data"); + if(H5T_conv_struct_init(src, dst, cdata, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") break; case H5T_CONV_FREE: /* * Free the private conversion data. */ - cdata->priv = priv = H5T_conv_struct_free(priv); + cdata->priv = H5T_conv_struct_free(priv); break; case H5T_CONV_CONV: /* * Conversion. */ - if (NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); - assert (priv); - assert (bkg && cdata->need_bkg); + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") + HDassert(priv); + HDassert(bkg && cdata->need_bkg); - if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data"); + if(cdata->recalc && H5T_conv_struct_init(src, dst, cdata, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") /* * Insure that members are sorted. @@ -2139,7 +2138,7 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Direction of conversion and striding through background. */ - if (buf_stride) { + if(buf_stride) { src_delta = buf_stride; if(!bkg_stride) bkg_stride = dst->shared->size; @@ -2156,7 +2155,7 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end else */ /* Conversion loop... */ - for (elmtno=0; elmtno<nelmts; elmtno++) { + for(elmtno = 0; elmtno < nelmts; elmtno++) { /* * For each source member which will be present in the * destination, convert the member to the destination type unless @@ -2165,8 +2164,9 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * data point as small as possible with all the free space on the * right side. */ - for (u=0, offset=0; u<src->shared->u.compnd.nmembs; u++) { - if (src2dst[u]<0) continue; /*subsetting*/ + for(u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { + if(src2dst[u] < 0) + continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + u; dst_memb = dst->shared->u.compnd.memb + src2dst[u]; @@ -2176,15 +2176,16 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, (size_t)1, (size_t)0, (size_t)0, /*no striding (packed array)*/ xbuf + src_memb->offset, xbkg + dst_memb->offset, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") HDmemmove(xbuf + offset, xbuf + src_memb->offset, dst_memb->size); offset += dst_memb->size; - } else { + } /* end if */ + else { HDmemmove (xbuf+offset, xbuf+src_memb->offset, src_memb->size); offset += src_memb->size; - } - } + } /* end else */ + } /* end for */ /* * For each source member which will be present in the @@ -2193,8 +2194,9 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * yet). Then copy the member to the destination offset in the * background buffer. */ - for (i=src->shared->u.compnd.nmembs-1; i>=0; --i) { - if (src2dst[i]<0) continue; /*subsetting*/ + for(i = src->shared->u.compnd.nmembs - 1; i >= 0; --i) { + if(src2dst[i] < 0) + continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + i; dst_memb = dst->shared->u.compnd.memb + src2dst[i]; @@ -2205,43 +2207,44 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, (size_t)1, (size_t)0, (size_t)0, /*no striding (packed array)*/ xbuf + offset, xbkg + dst_memb->offset, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member"); - } else + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") + } /* end if */ + else offset -= dst_memb->size; HDmemmove(xbkg + dst_memb->offset, xbuf + offset, dst_memb->size); - } - assert (0==offset); + } /* end for */ + HDassert(0 == offset); /* * Update pointers */ xbuf += src_delta; xbkg += bkg_stride; - } + } /* end for */ /* If the bkg_stride was set to -(dst->shared->size), make it positive now */ - if(buf_stride==0 && dst->shared->size>src->shared->size) - bkg_stride=dst->shared->size; + if(buf_stride == 0 && dst->shared->size > src->shared->size) + bkg_stride = dst->shared->size; /* * Copy the background buffer back into the in-place conversion * buffer. */ - for (xbuf=buf, xbkg=bkg, elmtno=0; elmtno<nelmts; elmtno++) { + for(xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbuf, xbkg, dst->shared->size); xbuf += buf_stride ? buf_stride : dst->shared->size; xbkg += bkg_stride; - } + } /* end for */ break; default: /* Some other command we don't know about yet.*/ - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); - } + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5T_conv_struct() */ /*------------------------------------------------------------------------- @@ -2337,7 +2340,7 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, FUNC_ENTER_NOAPI(H5T_conv_struct_opt, FAIL) - switch (cdata->command) { + switch(cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the @@ -2347,8 +2350,10 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - HDassert(H5T_COMPOUND == src->shared->type); - HDassert(H5T_COMPOUND == dst->shared->type); + if(H5T_COMPOUND != src->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") + if(H5T_COMPOUND != dst->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") /* Initialize data which is relatively constant */ if(H5T_conv_struct_init(src, dst, cdata, dxpl_id) < 0) @@ -2383,7 +2388,7 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, if(dst_memb->size > src_memb->size) { offset -= src_memb->size; if(dst_memb->size > src->shared->size-offset) { - cdata->priv = priv = H5T_conv_struct_free(priv); + cdata->priv = H5T_conv_struct_free(priv); HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "convertion is unsupported by this function") } /* end if */ } /* end if */ @@ -2395,8 +2400,7 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, /* * Free the private conversion data. */ - priv = (H5T_conv_struct_t *)(cdata->priv); - cdata->priv = priv = H5T_conv_struct_free(priv); + cdata->priv = H5T_conv_struct_free((H5T_conv_struct_t *)(cdata->priv)); break; case H5T_CONV_CONV: @@ -2410,8 +2414,8 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, if(cdata->recalc && H5T_conv_struct_init(src, dst, cdata, dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") priv = (H5T_conv_struct_t *)(cdata->priv); - src2dst = priv->src2dst; HDassert(priv); + src2dst = priv->src2dst; HDassert(bkg && cdata->need_bkg); /* @@ -2558,20 +2562,20 @@ done: static herr_t H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) { - H5T_enum_struct_t *priv=NULL; /*private conversion data */ + H5T_enum_struct_t *priv = NULL; /*private conversion data */ int n; /*src value cast as native int */ int domain[2] = {0, 0}; /*min and max source values */ - int *map=NULL; /*map from src value to dst idx */ + int *map = NULL; /*map from src value to dst idx */ unsigned length; /*nelmts in map array */ unsigned i, j; /*counters */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_conv_enum_init) cdata->need_bkg = H5T_BKG_NO; - if (NULL==(priv=(H5T_enum_struct_t *)(cdata->priv=H5MM_calloc(sizeof(*priv))))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - if (0==src->shared->u.enumer.nmembs) + if(NULL == (priv = (H5T_enum_struct_t *)(cdata->priv = H5MM_calloc(sizeof(*priv))))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if(0 == src->shared->u.enumer.nmembs) HGOTO_DONE(SUCCEED); /* @@ -2581,18 +2585,18 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) */ H5T_sort_name(src, NULL); H5T_sort_name(dst, NULL); - if (NULL==(priv->src2dst=(int *)H5MM_malloc(src->shared->u.enumer.nmembs*sizeof(int)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");; - for (i=0, j=0; - i<src->shared->u.enumer.nmembs && j<dst->shared->u.enumer.nmembs; + if(NULL == (priv->src2dst = (int *)H5MM_malloc(src->shared->u.enumer.nmembs * sizeof(int)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + for(i = 0, j = 0; + i < src->shared->u.enumer.nmembs && j < dst->shared->u.enumer.nmembs; i++, j++) { - while (j<dst->shared->u.enumer.nmembs && + while(j < dst->shared->u.enumer.nmembs && HDstrcmp(src->shared->u.enumer.name[i], dst->shared->u.enumer.name[j])) j++; - if (j>=dst->shared->u.enumer.nmembs) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source type is not a subset of destination type"); + if(j >= dst->shared->u.enumer.nmembs) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source type is not a subset of destination type") priv->src2dst[i] = j; - } + } /* end for */ /* * The conversion function will use an O(log N) lookup method for each @@ -2634,7 +2638,7 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) priv->base = domain[0]; priv->length = length; if (NULL==(map=(int *)H5MM_malloc(length*sizeof(int)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") for (i=0; i<length; i++) map[i] = -1; /*entry unused*/ for (i=0; i<src->shared->u.enumer.nmembs; i++) { @@ -2701,20 +2705,20 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, void UNUSED *bkg, hid_t UNUSED dxpl_id) { uint8_t *buf = (uint8_t*)_buf; /*cast for pointer arithmetic */ - H5T_t *src=NULL, *dst=NULL; /*src and dst datatypes */ - uint8_t *s=NULL, *d=NULL; /*src and dst BUF pointers */ + H5T_t *src = NULL, *dst = NULL; /*src and dst datatypes */ + uint8_t *s = NULL, *d = NULL; /*src and dst BUF pointers */ int src_delta, dst_delta; /*conversion strides */ int n; /*src value cast as native int */ - size_t i; /*counters */ H5T_enum_struct_t *priv = (H5T_enum_struct_t*)(cdata->priv); H5P_genplist_t *plist; /*property list pointer */ H5T_conv_cb_t cb_struct; /*conversion callback structure */ H5T_conv_ret_t except_ret; /*return of callback function */ - herr_t ret_value=SUCCEED; /* Return value */ + size_t i; /*counters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_enum, FAIL) - switch (cdata->command) { + switch(cdata->command) { case H5T_CONV_INIT: /* * Determine if this conversion function applies to the conversion @@ -2722,13 +2726,15 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * the `priv' field of `cdata' with information about the underlying * integer conversion. */ - if (NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); - assert (H5T_ENUM==src->shared->type); - assert (H5T_ENUM==dst->shared->type); - if (H5T_conv_enum_init(src, dst, cdata)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize private data"); + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") + if(H5T_ENUM != src->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") + if(H5T_ENUM != dst->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") + + if(H5T_conv_enum_init(src, dst, cdata) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize private data") break; case H5T_CONV_FREE: @@ -2747,26 +2753,28 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, break; case H5T_CONV_CONV: - if (NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); - assert (H5T_ENUM==src->shared->type); - assert (H5T_ENUM==dst->shared->type); + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if(H5T_ENUM != src->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") + if(H5T_ENUM != dst->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") /* priv->src2dst map was computed for certain sort keys. Make sure those same * sort keys are used here during conversion. See H5T_conv_enum_init(). But * we actually don't care about the source type's order when doing the O(1) * conversion algorithm, which is turned on by non-zero priv->length */ H5T_sort_name(dst, NULL); - if (!priv->length) H5T_sort_value(src, NULL); + if(!priv->length) + H5T_sort_value(src, NULL); /* * Direction of conversion. */ - if (buf_stride) { + if(buf_stride) { src_delta = dst_delta = (int)buf_stride; s = d = buf; - } else if (dst->shared->size <= src->shared->size) { + } else if(dst->shared->size <= src->shared->size) { src_delta = (int)src->shared->size; /*overflow shouldn't be possible*/ dst_delta = (int)dst->shared->size; /*overflow shouldn't be possible*/ s = d = buf; @@ -2778,25 +2786,24 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID"); + if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID") /* Get conversion exception callback property */ - if (H5P_get(plist,H5D_XFER_CONV_CB_NAME,&cb_struct)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); + if(H5P_get(plist, H5D_XFER_CONV_CB_NAME, &cb_struct) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback") - for (i=0; i<nelmts; i++, s+=src_delta, d+=dst_delta) { - if (priv->length) { + for(i = 0; i < nelmts; i++, s += src_delta, d += dst_delta) { + if(priv->length) { /* Use O(1) lookup */ - if (1==src->shared->size) { + if(1 == src->shared->size) n = *((signed char*)s); - } else if (sizeof(short)==src->shared->size) { + else if(sizeof(short) == src->shared->size) n = *((short*)s); - } else { + else n = *((int*)s); - } n -= priv->base; - if (n<0 || n>=priv->length || priv->src2dst[n]<0) { + if(n < 0 || n >= priv->length || priv->src2dst[n] < 0) { /*overflow*/ except_ret = H5T_CONV_UNHANDLED; if(cb_struct.func) { /*If user's exception handler is present, use it*/ @@ -2818,19 +2825,19 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, int lt = 0; int rt = src->shared->u.enumer.nmembs; int md, cmp; - while (lt<rt) { - md = (lt+rt)/2; - cmp = HDmemcmp(s, src->shared->u.enumer.value+md*src->shared->size, + + while(lt < rt) { + md = (lt + rt) / 2; + cmp = HDmemcmp(s, src->shared->u.enumer.value + md * src->shared->size, src->shared->size); - if (cmp<0) { + if(cmp < 0) rt = md; - } else if (cmp>0) { - lt = md+1; - } else { + else if(cmp > 0) + lt = md + 1; + else break; - } - } - if (lt>=rt) { + } /* end while */ + if(lt >= rt) { except_ret = H5T_CONV_UNHANDLED; if(cb_struct.func) { /*If user's exception handler is present, use it*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, @@ -2841,23 +2848,24 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HDmemset(d, 0xff, dst->shared->size); } else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - } else { + } /* end if */ + else { HDmemcpy(d, dst->shared->u.enumer.value+priv->src2dst[md]*dst->shared->size, dst->shared->size); - } + } /* end else */ } } break; default: /* Some other command we don't know about yet.*/ - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); - } + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5T_conv_enum() */ /*------------------------------------------------------------------------- @@ -2930,7 +2938,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, FUNC_ENTER_NOAPI(H5T_conv_vlen, FAIL) - switch (cdata->command) { + switch(cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the @@ -2940,9 +2948,11 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * conversion path. */ if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - HDassert(H5T_VLEN == src->shared->type); - HDassert(H5T_VLEN == dst->shared->type); + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") + if(H5T_VLEN != src->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_VLEN datatype") + if(H5T_VLEN != dst->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_VLEN datatype") /* Variable-length types don't need a background buffer */ cdata->need_bkg = H5T_BKG_NO; @@ -3331,8 +3341,8 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, break; default: /* Some other command we don't know about yet.*/ - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); - } /* end switch */ + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") + } /* end switch */ done: /* Release the background buffer, if we have one */ @@ -3340,7 +3350,7 @@ done: bkg_buf = H5FL_BLK_FREE(array_seq, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_conv_array() */ +} /* end H5T_conv_array() */ /*------------------------------------------------------------------------- @@ -3396,19 +3406,16 @@ H5T_conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, FUNC_ENTER_NOAPI(H5T_conv_i_i, FAIL) - switch (cdata->command) { + switch(cdata->command) { case H5T_CONV_INIT: - if (NULL==(src=(H5T_t *)H5I_object(src_id)) || - NULL==(dst=(H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); - if (H5T_ORDER_LE!=src->shared->u.atomic.order && - H5T_ORDER_BE!=src->shared->u.atomic.order) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (H5T_ORDER_LE!=dst->shared->u.atomic.order && - H5T_ORDER_BE!=dst->shared->u.atomic.order) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (dst->shared->size>sizeof dbuf) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if(H5T_ORDER_LE != src->shared->u.atomic.order && H5T_ORDER_BE != src->shared->u.atomic.order) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") + if(H5T_ORDER_LE != dst->shared->u.atomic.order && H5T_ORDER_BE != dst->shared->u.atomic.order) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") + if(dst->shared->size > sizeof dbuf) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large") cdata->need_bkg = H5T_BKG_NO; break; @@ -3417,9 +3424,8 @@ H5T_conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if (NULL==(src=(H5T_t *)H5I_object(src_id)) || - NULL==(dst=(H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* * Do we process the values from beginning to end or vice versa? Also, @@ -3441,18 +3447,18 @@ H5T_conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, double olap_d = HDceil((double)(src->shared->size)/ (double)(dst->shared->size-src->shared->size)); olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src->shared->size; - dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size; + sp = (uint8_t*)buf + (nelmts - 1) * src->shared->size; + dp = (uint8_t*)buf + (nelmts - 1) * dst->shared->size; direction = -1; } /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID"); + if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID") /* Get conversion exception callback property */ - if (H5P_get(plist,H5D_XFER_CONV_CB_NAME,&cb_struct)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); + if(H5P_get(plist,H5D_XFER_CONV_CB_NAME, &cb_struct) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ src_rev = (uint8_t*)H5MM_calloc(src->shared->size); @@ -3741,14 +3747,14 @@ H5T_conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, break; default: - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); - } + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") + } /* end switch */ done: if(src_rev) H5MM_free(src_rev); FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5T_conv_i_i() */ /*------------------------------------------------------------------------- @@ -3783,7 +3789,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, +H5T_conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t dxpl_id) { @@ -3799,44 +3805,43 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t olap; /*num overlapping elements */ ssize_t bitno = 0; /*bit number */ uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ - uint8_t *src_rev=NULL; /*order-reversed source buffer */ + uint8_t *src_rev = NULL; /*order-reversed source buffer */ uint8_t dbuf[64]; /*temp destination buffer */ uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ /* Conversion-related variables */ hssize_t expo; /*exponent */ hssize_t expo_max; /*maximum possible dst exponent */ - size_t msize=0; /*useful size of mantissa in src*/ + size_t msize = 0; /*useful size of mantissa in src*/ size_t mpos; /*offset to useful mant is src */ hssize_t sign; /*source sign bit value */ size_t mrsh; /*amount to right shift mantissa*/ - hbool_t carry=0; /*carry after rounding mantissa */ + hbool_t carry = 0; /*carry after rounding mantissa */ size_t i; /*miscellaneous counters */ size_t implied; /*destination implied bits */ - hbool_t denormalized=FALSE; /*is either source or destination denormalized?*/ + hbool_t denormalized = FALSE; /*is either source or destination denormalized?*/ H5P_genplist_t *plist; /*property list pointer */ - H5T_conv_cb_t cb_struct={NULL, NULL}; /*conversion callback structure */ + H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ H5T_conv_ret_t except_ret; /*return of callback function */ hbool_t reverse; /*if reverse the order of destination */ - herr_t ret_value=SUCCEED; /*return value */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI(H5T_conv_f_f, FAIL) - switch (cdata->command) { + switch(cdata->command) { case H5T_CONV_INIT: - if (NULL==(src_p=(H5T_t *)H5I_object(src_id)) || - NULL==(dst_p=(H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); + if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; - if (H5T_ORDER_LE!=src.order && H5T_ORDER_BE!=src.order && H5T_ORDER_VAX!=src.order) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (H5T_ORDER_LE!=dst.order && H5T_ORDER_BE!=dst.order && H5T_ORDER_VAX!=dst.order) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (dst_p->shared->size>sizeof(dbuf)) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); - if (8*sizeof(expo)-1<src.u.f.esize || 8*sizeof(expo)-1<dst.u.f.esize) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large"); + if(H5T_ORDER_LE != src.order && H5T_ORDER_BE != src.order && H5T_ORDER_VAX != src.order) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") + if(H5T_ORDER_LE != dst.order && H5T_ORDER_BE != dst.order && H5T_ORDER_VAX != dst.order) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") + if(dst_p->shared->size > sizeof(dbuf)) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large") + if(8 * sizeof(expo) - 1 < src.u.f.esize || 8 * sizeof(expo) - 1 < dst.u.f.esize) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large") cdata->need_bkg = H5T_BKG_NO; break; @@ -3845,9 +3850,8 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if (NULL==(src_p=(H5T_t *)H5I_object(src_id)) || - NULL==(dst_p=(H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); + if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; expo_max = ((hssize_t)1 << dst.u.f.esize) - 1; @@ -3878,11 +3882,11 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID"); + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID") /* Get conversion exception callback property */ - if (H5P_get(plist,H5D_XFER_CONV_CB_NAME,&cb_struct)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); + if(H5P_get(plist,H5D_XFER_CONV_CB_NAME, &cb_struct) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); @@ -4319,15 +4323,15 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, break; default: - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); - } + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") + } /* end switch */ done: if(src_rev) H5MM_free(src_rev); FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5T_conv_f_f() */ /*------------------------------------------------------------------------- @@ -4365,22 +4369,21 @@ H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, FUNC_ENTER_NOAPI(H5T_conv_s_s, FAIL) - switch (cdata->command) { + switch(cdata->command) { case H5T_CONV_INIT: - if (NULL==(src=(H5T_t *)H5I_object(src_id)) || - NULL==(dst=(H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); - if (8*src->shared->size != src->shared->u.atomic.prec || 8*dst->shared->size != dst->shared->u.atomic.prec) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision"); - if (0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad offset"); - if (H5T_CSET_ASCII != src->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 != src->shared->u.atomic.u.s.cset) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad source character set"); - if (H5T_CSET_ASCII != dst->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 != dst->shared->u.atomic.u.s.cset) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad destination character set"); - if (src->shared->u.atomic.u.s.pad<0 || src->shared->u.atomic.u.s.pad>=H5T_NPAD || - dst->shared->u.atomic.u.s.pad<0 || dst->shared->u.atomic.u.s.pad>=H5T_NPAD) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character padding"); + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if(8 * src->shared->size != src->shared->u.atomic.prec || 8 * dst->shared->size != dst->shared->u.atomic.prec) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision") + if(0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad offset") + if(H5T_CSET_ASCII != src->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 != src->shared->u.atomic.u.s.cset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad source character set") + if(H5T_CSET_ASCII != dst->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 != dst->shared->u.atomic.u.s.cset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad destination character set") + if(src->shared->u.atomic.u.s.pad < 0 || src->shared->u.atomic.u.s.pad >= H5T_NPAD || + dst->shared->u.atomic.u.s.pad < 0 || dst->shared->u.atomic.u.s.pad >= H5T_NPAD) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character padding") cdata->need_bkg = H5T_BKG_NO; break; @@ -4389,9 +4392,8 @@ H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if (NULL==(src=(H5T_t *)H5I_object(src_id)) || - NULL==(dst=(H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); + if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* * Do we process the values from beginning to end or vice versa? Also, @@ -4422,22 +4424,22 @@ H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* Allocate the overlap buffer */ - if (NULL==(dbuf=(uint8_t *)H5MM_malloc(dst->shared->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for string conversion"); + if(NULL == (dbuf = (uint8_t *)H5MM_malloc(dst->shared->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for string conversion") /* The conversion loop. */ - for (elmtno=0; elmtno<nelmts; elmtno++) { + for(elmtno = 0; elmtno < nelmts; elmtno++) { /* * If the source and destination buffers overlap then use a * temporary buffer for the destination. */ - if (direction>0) { + if(direction > 0) { s = sp; - d = elmtno<olap ? dbuf : dp; + d = elmtno < olap ? dbuf : dp; } else { s = sp; - d = elmtno+olap >= nelmts ? dbuf : dp; + d = elmtno + olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ @@ -4453,7 +4455,7 @@ H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, #endif /* Copy characters from source to destination */ - switch (src->shared->u.atomic.u.s.pad) { + switch(src->shared->u.atomic.u.s.pad) { case H5T_STR_NULLTERM: for (nchars=0; nchars<dst->shared->size && nchars<src->shared->size && s[nchars]; @@ -4493,24 +4495,24 @@ H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: case H5T_STR_ERROR: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source string padding method not supported"); - } + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source string padding method not supported") + } /* end switch */ /* Terminate or pad the destination */ - switch (dst->shared->u.atomic.u.s.pad) { + switch(dst->shared->u.atomic.u.s.pad) { case H5T_STR_NULLTERM: - while (nchars<dst->shared->size) + while(nchars < dst->shared->size) d[nchars++] = '\0'; - d[dst->shared->size-1] = '\0'; + d[dst->shared->size - 1] = '\0'; break; case H5T_STR_NULLPAD: - while (nchars<dst->shared->size) + while(nchars < dst->shared->size) d[nchars++] = '\0'; break; case H5T_STR_SPACEPAD: - while (nchars<dst->shared->size) + while(nchars < dst->shared->size) d[nchars++] = ' '; break; @@ -4528,8 +4530,8 @@ H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: case H5T_STR_ERROR: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination string padding method not supported"); - } + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination string padding method not supported") + } /* end switch */ /* * If we used a temporary buffer for the destination then we @@ -4544,17 +4546,18 @@ H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, sp += direction * src->shared->size; dp += direction * dst->shared->size; } - } + } /* end for */ break; default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown converson command"); - } + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown converson command") + } /* end switch */ done: H5MM_xfree(dbuf); + FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5T_conv_s_s() */ /*------------------------------------------------------------------------- @@ -9714,7 +9717,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, +H5T_conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t dxpl_id) { @@ -9750,19 +9753,18 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, FUNC_ENTER_NOAPI(H5T_conv_f_i, FAIL) - switch (cdata->command) { + switch(cdata->command) { case H5T_CONV_INIT: - if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) || - NULL==(dst_p=(H5T_t*)H5I_object(dst_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); + if(NULL == (src_p = (H5T_t*)H5I_object(src_id)) || NULL == (dst_p = (H5T_t*)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; - if (H5T_ORDER_LE!=src.order && H5T_ORDER_BE!=src.order && H5T_ORDER_VAX!=src.order) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (dst_p->shared->size>sizeof(dbuf)) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); - if (8*sizeof(expo)-1<src.u.f.esize) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large"); + if(H5T_ORDER_LE != src.order && H5T_ORDER_BE != src.order && H5T_ORDER_VAX != src.order) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") + if(dst_p->shared->size > sizeof(dbuf)) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large") + if(8 * sizeof(expo) - 1 < src.u.f.esize) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large") cdata->need_bkg = H5T_BKG_NO; break; @@ -9771,9 +9773,8 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) || - NULL==(dst_p=(H5T_t*)H5I_object(dst_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); + if(NULL == (src_p = (H5T_t*)H5I_object(src_id)) || NULL == (dst_p = (H5T_t*)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -9782,7 +9783,7 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src_p->shared->size==dst_p->shared->size || buf_stride) { + if(src_p->shared->size==dst_p->shared->size || buf_stride) { sp = dp = (uint8_t*)buf; direction = 1; olap = nelmts; @@ -9809,11 +9810,11 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Get the plist structure. Do I need to close it? */ if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID"); + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID") /* Get conversion exception callback property */ if(H5P_get(plist, H5D_XFER_CONV_CB_NAME, &cb_struct) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); @@ -10265,16 +10266,17 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, break; default: - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); - } + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") + } /* end switch */ done: if(int_buf) H5MM_xfree(int_buf); if(src_rev) H5MM_free(src_rev); + FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5T_conv_f_i() */ /*------------------------------------------------------------------------- @@ -10302,7 +10304,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, +H5T_conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t dxpl_id) { @@ -10317,7 +10319,7 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t tsize; /*type size for swapping bytes */ size_t olap; /*num overlapping elements */ uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ - uint8_t *src_rev=NULL; /*order-reversed source buffer */ + uint8_t *src_rev = NULL; /*order-reversed source buffer */ uint8_t dbuf[64]; /*temp destination buffer */ uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ @@ -10327,32 +10329,31 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t sign; /*source sign bit value */ hbool_t is_max_neg; /*source is maximal negative value*/ hbool_t do_round; /*whether there is roundup */ - uint8_t *int_buf=NULL; /*buffer for temporary value */ + uint8_t *int_buf = NULL; /*buffer for temporary value */ size_t buf_size; /*buffer size for temporary value */ size_t i; /*miscellaneous counters */ size_t first; /*first bit(MSB) in an integer */ ssize_t sfirst; /*a signed version of `first' */ H5P_genplist_t *plist; /*Property list pointer */ - H5T_conv_cb_t cb_struct={NULL, NULL}; /*conversion callback structure */ + H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ H5T_conv_ret_t except_ret; /*return of callback function */ hbool_t reverse; /*if reverse the order of destination */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_conv_i_f, FAIL) - switch (cdata->command) { + switch(cdata->command) { case H5T_CONV_INIT: - if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) || - NULL==(dst_p=(H5T_t*)H5I_object(dst_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); + if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; - if (H5T_ORDER_LE!=dst.order && H5T_ORDER_BE!=dst.order && H5T_ORDER_VAX!=dst.order) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (dst_p->shared->size>sizeof(dbuf)) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); - if (8*sizeof(expo)-1<src.u.f.esize) - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large"); + if(H5T_ORDER_LE != dst.order && H5T_ORDER_BE != dst.order && H5T_ORDER_VAX != dst.order) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") + if(dst_p->shared->size > sizeof(dbuf)) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large") + if(8 * sizeof(expo) - 1 < src.u.f.esize) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large") cdata->need_bkg = H5T_BKG_NO; break; @@ -10361,9 +10362,8 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) || - NULL==(dst_p=(H5T_t*)H5I_object(dst_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); + if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -10399,11 +10399,11 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID"); + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find property list for ID") /* Get conversion exception callback property */ - if (H5P_get(plist,H5D_XFER_CONV_CB_NAME,&cb_struct)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); + if(H5P_get(plist,H5D_XFER_CONV_CB_NAME, &cb_struct) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); @@ -10696,16 +10696,17 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, break; default: - HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); - } + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") + } /* end switch */ done: if(int_buf) H5MM_xfree(int_buf); if(src_rev) H5MM_free(src_rev); + FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5T_conv_i_f() */ /*------------------------------------------------------------------------- @@ -178,7 +178,7 @@ static unsigned test_mf_eoa(const char *env_h5_drvr, hid_t fapl) { hid_t file = -1; /* File ID */ - hid_t fapl_new; /* copy of fapl */ + hid_t fapl_new = -1; /* copy of fapl */ char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ h5_stat_size_t file_size, new_file_size; /* file size */ @@ -277,9 +277,12 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != file_size) + if(new_file_size != file_size) TEST_ERROR + if(H5Pclose(fapl_new) < 0) + FAIL_STACK_ERROR + PASSED() } /* end if */ else { @@ -291,6 +294,7 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) error: H5E_BEGIN_TRY { + H5Pclose(fapl_new); H5Fclose(file); } H5E_END_TRY; return(1); @@ -317,7 +321,7 @@ static unsigned test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) { hid_t file = -1; /* File ID */ - hid_t fapl_new; /* copy of fapl */ + hid_t fapl_new = -1; /* copy of fapl */ char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ h5_stat_size_t file_size, new_file_size; /* file size */ @@ -403,8 +407,10 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) /* nothing should be changed in meta_aggr */ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size); - if (new_ma_addr != ma_addr) TEST_ERROR - if (new_ma_size != ma_size) TEST_ERROR + if(new_ma_addr != ma_addr) + TEST_ERROR + if(new_ma_size != ma_size) + TEST_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -414,7 +420,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != file_size) + if(new_file_size != file_size) TEST_ERROR PASSED() @@ -462,7 +468,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != (file_size+TEST_BLOCK_SIZE30)) + if(new_file_size != (file_size + TEST_BLOCK_SIZE30)) TEST_ERROR PASSED() @@ -506,7 +512,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != (file_size+TEST_BLOCK_SIZE30)) + if(new_file_size != (file_size + TEST_BLOCK_SIZE30)) TEST_ERROR PASSED() @@ -538,8 +544,10 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) /* nothing should be changed in meta_aggr */ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size); - if (new_ma_addr != ma_addr) TEST_ERROR - if (new_ma_size != ma_size) TEST_ERROR + if(new_ma_addr != ma_addr) + TEST_ERROR + if(new_ma_size != ma_size) + TEST_ERROR if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -549,9 +557,12 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != (file_size+10)) + if(new_file_size != (file_size + 10)) TEST_ERROR + if(H5Pclose(fapl_new) < 0) + FAIL_STACK_ERROR + PASSED() } /* end if */ else { @@ -563,6 +574,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) error: H5E_BEGIN_TRY { + H5Pclose(fapl_new); H5Fclose(file); } H5E_END_TRY; return(1); @@ -585,7 +597,7 @@ static unsigned test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) { hid_t file = -1; /* File ID */ - hid_t fapl_new; /* copy of fapl */ + hid_t fapl_new = -1; /* copy of fapl */ char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ h5_stat_size_t file_size, new_file_size; /* File size */ @@ -621,8 +633,10 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Turn off using meta/small data aggregator */ - H5Pset_meta_block_size(fapl_new, (hsize_t)0); - H5Pset_small_data_block_size(fapl_new, (hsize_t)0); + if(H5Pset_meta_block_size(fapl_new, (hsize_t)0) < 0) + FAIL_STACK_ERROR + if(H5Pset_small_data_block_size(fapl_new, (hsize_t)0) < 0) + FAIL_STACK_ERROR /* Re-open the file with meta/small data setting */ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) @@ -652,7 +666,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != (file_size+TEST_BLOCK_SIZE30)) + if(new_file_size != (file_size + TEST_BLOCK_SIZE30)) TEST_ERROR /* Re-open the file */ @@ -682,7 +696,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != (file_size+TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50)) + if(new_file_size != (file_size + TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50)) TEST_ERROR PASSED() @@ -715,12 +729,12 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) type = H5FD_MEM_SUPER; addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30); - if (addr < (haddr_t)file_size) + if(addr < (haddr_t)file_size) TEST_ERROR /* nothing should be changed in meta_aggr */ H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size); - if (new_ma_addr != ma_addr) + if(new_ma_addr != ma_addr) TEST_ERROR extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)addr, (hsize_t)(TEST_BLOCK_SIZE30-10), (hsize_t)(TEST_BLOCK_SIZE50)); @@ -742,9 +756,12 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != file_size+TEST_BLOCK_SIZE30) + if(new_file_size != file_size + TEST_BLOCK_SIZE30) TEST_ERROR + if(H5Pclose(fapl_new) < 0) + FAIL_STACK_ERROR + PASSED() } /* end if */ else { @@ -756,6 +773,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) error: H5E_BEGIN_TRY { + H5Pclose(fapl_new); H5Fclose(file); } H5E_END_TRY; return(1); @@ -947,7 +965,7 @@ static unsigned test_mf_fs_start(hid_t fapl) { hid_t file = -1; /* File ID */ - hid_t fapl_new; /* copy of fapl */ + hid_t fapl_new = -1; /* copy of fapl */ char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ h5_stat_size_t file_size, new_file_size; /* file size */ @@ -1010,15 +1028,19 @@ test_mf_fs_start(hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != file_size) + if(new_file_size != file_size) TEST_ERROR + if(H5Pclose(fapl_new) < 0) + FAIL_STACK_ERROR + PASSED() return(0); error: H5E_BEGIN_TRY { + H5Pclose(fapl_new); H5Fclose(file); } H5E_END_TRY; return(1); @@ -1054,7 +1076,7 @@ static unsigned test_mf_fs_alloc_free(hid_t fapl) { hid_t file = -1; /* File ID */ - hid_t fapl_new; /* copy of fapl */ + hid_t fapl_new = -1; /* copy of fapl */ char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ h5_stat_size_t file_size, new_file_size; /* file size */ @@ -1343,15 +1365,19 @@ test_mf_fs_alloc_free(hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != file_size) + if(new_file_size != file_size) TEST_ERROR + if(H5Pclose(fapl_new) < 0) + FAIL_STACK_ERROR + PASSED() return(0); error: H5E_BEGIN_TRY { + H5Pclose(fapl_new); H5Fclose(file); } H5E_END_TRY; return(1); @@ -1399,7 +1425,7 @@ static unsigned test_mf_fs_extend(hid_t fapl) { hid_t file = -1; /* File ID */ - hid_t fapl_new; /* copy of fapl */ + hid_t fapl_new = -1; /* copy of fapl */ char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ h5_stat_size_t file_size, new_file_size; /* file size */ @@ -1889,15 +1915,19 @@ test_mf_fs_extend(hid_t fapl) TEST_ERROR /* Verify the file is the correct size */ - if (new_file_size != file_size) + if(new_file_size != file_size) TEST_ERROR + if(H5Pclose(fapl_new) < 0) + FAIL_STACK_ERROR + PASSED() return(0); error: H5E_BEGIN_TRY { + H5Pclose(fapl_new); H5Fclose(file); } H5E_END_TRY; return(1); @@ -6635,7 +6665,7 @@ error: HDmemset(memb_name, 0, sizeof memb_name); \ HDmemset(memb_addr, 0, sizeof memb_addr); \ HDmemset(sv, 0, sizeof sv); \ - for (mt = 0; mt < H5FD_MEM_NTYPES; mt++) { \ + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { \ memb_map[mt] = H5FD_MEM_SUPER; \ memb_fapl[mt] = H5P_DEFAULT; \ } \ @@ -6670,20 +6700,21 @@ error: static unsigned test_mf_fs_drivers(hid_t fapl) { - hid_t fcpl; /* file creation property list */ - hid_t fapl_new; /* copy of file access property list */ - hid_t fapl2; /* copy of file access property list */ + hid_t fcpl = -1; /* file creation property list */ + hid_t fapl_new = -1; /* copy of file access property list */ + hid_t fapl2 = -1; /* copy of file access property list */ hbool_t new_format; /* To use new library format or not */ unsigned ret = 0; /* return value */ H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; /* Memory usage map */ hid_t memb_fapl[H5FD_MEM_NTYPES]; /* Member access properties */ - char sv[H5FD_MEM_NTYPES][500]; /* Name generators */ + char sv[H5FD_MEM_NTYPES][64]; /* Name generators */ const char *memb_name[H5FD_MEM_NTYPES]; /* Name generators */ haddr_t memb_addr[H5FD_MEM_NTYPES]; /* Member starting address */ /* Create a non-standard file-creation template */ - fcpl = H5Pcreate(H5P_FILE_CREATE); + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR if(H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0) < 0) TEST_ERROR @@ -6784,14 +6815,19 @@ test_mf_fs_drivers(hid_t fapl) } /* end for new_format */ - if (H5Pclose(fcpl) < 0) + if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - if (H5Pclose(fapl2) < 0) + if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR return(ret); error: + H5E_BEGIN_TRY { + H5Pclose(fcpl); + H5Pclose(fapl2); + H5Pclose(fapl_new); + } H5E_END_TRY; return(1); } /* test_mf_fs_drivers() */ @@ -6804,7 +6840,7 @@ static unsigned test_filespace_strategy_threshold(hid_t fapl_new) { hid_t file = -1; /* File ID */ - hid_t fcpl; /* File creation property list template */ + hid_t fcpl = -1; /* File creation property list template */ char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5FD_mem_t type; /* File allocation type */ @@ -6922,7 +6958,10 @@ test_filespace_strategy_threshold(hid_t fapl_new) TEST_ERROR break; + case H5F_FILE_SPACE_DEFAULT: + case H5F_FILE_SPACE_NTYPES: default: + TEST_ERROR break; } /* end switch */ @@ -6941,6 +6980,7 @@ test_filespace_strategy_threshold(hid_t fapl_new) error: H5E_BEGIN_TRY { + H5Pclose(fcpl); H5Fclose(file); } H5E_END_TRY; return(1); @@ -6954,7 +6994,7 @@ static unsigned test_filespace_gone(hid_t fapl_new) { hid_t file = -1; /* File ID */ - hid_t fcpl; /* File creation propertly list template */ + hid_t fcpl = -1; /* File creation propertly list template */ char filename[FILENAME_LEN]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ H5FD_mem_t type; /* File allocation type */ @@ -7074,6 +7114,7 @@ test_filespace_gone(hid_t fapl_new) error: H5E_BEGIN_TRY { + H5Pclose(fcpl); H5Fclose(file); } H5E_END_TRY; return(1); @@ -7085,14 +7126,14 @@ error: static unsigned test_filespace_drivers(hid_t fapl) { - hid_t fapl_new; /* copy of file access property list */ - hid_t fapl2; /* copy of file access property list */ + hid_t fapl_new = -1; /* copy of file access property list */ + hid_t fapl2 = -1; /* copy of file access property list */ hbool_t new_format; /* Using library new format or not */ unsigned ret = 0; /* return value */ H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; /* Memory usage map */ hid_t memb_fapl[H5FD_MEM_NTYPES]; /* Member access properties */ - char sv[H5FD_MEM_NTYPES][500]; /* Name generators */ + char sv[H5FD_MEM_NTYPES][64]; /* Name generators */ const char *memb_name[H5FD_MEM_NTYPES]; /* Name generators */ haddr_t memb_addr[H5FD_MEM_NTYPES]; /* Member starting address */ @@ -7201,6 +7242,10 @@ test_filespace_drivers(hid_t fapl) return(ret); error: + H5E_BEGIN_TRY { + H5Pclose(fapl_new); + H5Pclose(fapl2); + } H5E_END_TRY; return(1); } /* test_filespace_drivers() */ @@ -7259,10 +7304,9 @@ main(void) nerrors += test_mf_aggr_absorb(env_h5_drvr, fapl); /* Tests for alignment */ - for(curr_test = TEST_NORMAL; curr_test < TEST_NTESTS; curr_test++) { + for(curr_test = TEST_NORMAL; curr_test < TEST_NTESTS; H5_INC_ENUM(test_type_t, curr_test)) { switch(curr_test) { - case TEST_NORMAL: /* set alignment = 1024 */ if(H5Pset_alignment(new_fapl, (hsize_t)0, (hsize_t)TEST_ALIGN1024) < 0) TEST_ERROR @@ -7273,6 +7317,7 @@ main(void) TEST_ERROR break; + case TEST_NTESTS: default: TEST_ERROR; break; @@ -7294,7 +7339,7 @@ main(void) /* tests for file space management */ nerrors += test_filespace_drivers(fapl); - if (H5Pclose(new_fapl) < 0) + if(H5Pclose(new_fapl) < 0) FAIL_STACK_ERROR h5_cleanup(FILENAME, fapl); @@ -7302,13 +7347,14 @@ main(void) goto error; puts("All free-space manager tests for file memory passed."); - return (0); + return(0); error: puts("*** TESTS FAILED ***"); H5E_BEGIN_TRY { H5Pclose(fapl); + H5Pclose(new_fapl); } H5E_END_TRY; - return (1); + return(1); } /* main() */ diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 7d2c929..f849697 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -543,23 +543,23 @@ int do_copy_objects(hid_t fidin, trav_table_t *travt, pack_opt_t *options) /* repack options */ { - hid_t grp_in=-1; /* group ID */ - hid_t grp_out=-1; /* group ID */ - hid_t dset_in=-1; /* read dataset ID */ - hid_t dset_out=-1; /* write dataset ID */ - hid_t gcpl_in=-1; /* group creation property list */ - hid_t gcpl_out=-1; /* group creation property list */ - hid_t type_in=-1; /* named type ID */ - hid_t type_out=-1; /* named type ID */ - hid_t dcpl_id=-1; /* dataset creation property list ID */ - hid_t dcpl_out=-1; /* dataset creation property list ID */ - hid_t f_space_id=-1; /* file space ID */ - hid_t ftype_id=-1; /* file type ID */ - hid_t wtype_id=-1; /* read/write type ID */ - named_dt_t *named_dt_head=NULL; /* Pointer to the stack of named datatypes copied */ + hid_t grp_in = -1; /* group ID */ + hid_t grp_out = -1; /* group ID */ + hid_t dset_in = -1; /* read dataset ID */ + hid_t dset_out = -1; /* write dataset ID */ + hid_t gcpl_in = -1; /* group creation property list */ + hid_t gcpl_out = -1; /* group creation property list */ + hid_t type_in = -1; /* named type ID */ + hid_t type_out = -1; /* named type ID */ + hid_t dcpl_id = -1; /* dataset creation property list ID */ + hid_t dcpl_out = -1; /* dataset creation property list ID */ + hid_t f_space_id = -1; /* file space ID */ + hid_t ftype_id = -1; /* file type ID */ + hid_t wtype_id = -1; /* read/write type ID */ + named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */ size_t msize; /* size of type */ hsize_t nelmts; /* number of elements in dataset */ - H5D_space_status_t *space_status; /* determines whether space has been allocated for the dataset */ + H5D_space_status_t space_status; /* determines whether space has been allocated for the dataset */ int rank; /* rank of dataset */ hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ hsize_t dsize_in; /* input dataset size before filter */ @@ -748,14 +748,12 @@ int do_copy_objects(hid_t fidin, if(H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0) goto error; - if(H5Dget_space_status(dset_in, &space_status) <0) + if(H5Dget_space_status(dset_in, &space_status) < 0) goto error; nelmts = 1; - for ( j = 0; j < rank; j++) - { + for(j = 0; j < rank; j++) nelmts *= dims[j]; - } /* wtype_id will have already been set if using a named dtype */ if(!is_named) { @@ -839,20 +837,25 @@ int do_copy_objects(hid_t fidin, * read/write *------------------------------------------------------------------------- */ - if (nelmts>0 && space_status!=H5D_SPACE_STATUS_NOT_ALLOCATED) + if(nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) { - size_t need = (size_t)(nelmts*msize); /* bytes needed */ + size_t need = (size_t)(nelmts * msize); /* bytes needed */ /* have to read the whole dataset if there is only one element in the dataset */ - if ( need < H5TOOLS_MALLOCSIZE ) + if(need < H5TOOLS_MALLOCSIZE) buf = HDmalloc(need); - if (buf != NULL ) - { - if (H5Dread(dset_in,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0) + if(buf != NULL) { + if(H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; - if (H5Dwrite(dset_out,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0) + if(H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; + + /* Check if we have VL data in the dataset's + * datatype that must be reclaimed */ + if(TRUE == H5Tdetect_class(wtype_id, H5T_VLEN)) + if(H5Dvlen_reclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0) + goto error; } else /* possibly not enough memory, read/write by hyperslabs */ { @@ -1370,7 +1373,7 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size) } /* end while */ /* Update size of userblock left to transfer */ - size -= nread; + size = size - (hsize_t)nread; } /* end while */ done: diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index 8e25b6d..0f482b6 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -329,100 +329,88 @@ hsize_t diff_datasetid( hid_t did1, * only attempt to compare if possible *------------------------------------------------------------------------- */ - if (can_compare ) /* it is possible to compare */ + if(can_compare) /* it is possible to compare */ { + unsigned int vl_data = 0; /*contains VL datatypes */ /*------------------------------------------------------------------------- * get number of elements *------------------------------------------------------------------------- */ nelmts1 = 1; - for (i = 0; i < rank1; i++) - { + for(i = 0; i < rank1; i++) nelmts1 *= dims1[i]; - } nelmts2 = 1; - for (i = 0; i < rank2; i++) - { + for(i = 0; i < rank2; i++) nelmts2 *= dims2[i]; - } - assert(nelmts1==nelmts2); + HDassert(nelmts1 == nelmts2); /*------------------------------------------------------------------------- * "upgrade" the smaller memory size *------------------------------------------------------------------------- */ - if ( m_size1 != m_size2 ) - { - if ( m_size1 < m_size2 ) - { + if(m_size1 != m_size2) { + if(m_size1 < m_size2) { H5Tclose(m_tid1); - if ((m_tid1=h5tools_get_native_type(f_tid2)) < 0) + if((m_tid1 = h5tools_get_native_type(f_tid2)) < 0) goto error; - m_size1 = H5Tget_size( m_tid1 ); - } - else - { + m_size1 = H5Tget_size(m_tid1); + } /* end if */ + else { H5Tclose(m_tid2); - if ((m_tid2=h5tools_get_native_type(f_tid1)) < 0) + if((m_tid2 = h5tools_get_native_type(f_tid1)) < 0) goto error; - m_size2 = H5Tget_size( m_tid2 ); - } - } - assert(m_size1==m_size2); + m_size2 = H5Tget_size(m_tid2); + } /* end else */ + } /* end if */ + HDassert(m_size1 == m_size2); /* print names */ - if (obj1_name) { - name1=diff_basename(obj1_name); - } - if (obj2_name) { - name2=diff_basename(obj2_name); - } + if(obj1_name) + name1 = diff_basename(obj1_name); + if(obj2_name) + name2 = diff_basename(obj2_name); + /* check if we have VL data in the dataset's datatype */ + if(TRUE == H5Tdetect_class(m_tid1, H5T_VLEN)) + vl_data = TRUE; + /*------------------------------------------------------------------------- * read/compare *------------------------------------------------------------------------- */ - need = (size_t)(nelmts1*m_size1); /* bytes needed */ - if ( need < H5TOOLS_MALLOCSIZE) - { + need = (size_t)(nelmts1 * m_size1); /* bytes needed */ + if(need < H5TOOLS_MALLOCSIZE) { buf1 = HDmalloc(need); buf2 = HDmalloc(need); - } + } /* end if */ - if ( buf1!=NULL && buf2!=NULL) - { - if ( H5Dread(did1,m_tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf1) < 0 ) + if(buf1 != NULL && buf2 != NULL) { + if(H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0) goto error; - if ( H5Dread(did2,m_tid2,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf2) < 0 ) + if(H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0) goto error; /* array diff */ - nfound = diff_array(buf1, - buf2, - nelmts1, - (hsize_t)0, - rank1, - dims1, - options, - name1, - name2, - m_tid1, - did1, - did2); - } - + nfound = diff_array(buf1, buf2, nelmts1, (hsize_t)0, rank1, dims1, + options, name1, name2, m_tid1, did1, did2); + + /* reclaim any VL memory, if necessary */ + if(vl_data) { + H5Dvlen_reclaim(m_tid1, sid1, H5P_DEFAULT, buf1); + H5Dvlen_reclaim(m_tid2, sid2, H5P_DEFAULT, buf2); + } /* end if */ + } /* end if */ else /* possibly not enough memory, read/compare by hyperslabs */ - { size_t p_type_nbytes = m_size1; /*size of memory type */ hsize_t p_nelmts = nelmts1; /*total selected elmts */ @@ -442,25 +430,21 @@ hsize_t diff_datasetid( hid_t did1, hsize_t hs_nelmts; /*elements in request */ hsize_t zero[8]; /*vector of zeros */ - /* check if we have VL data in the dataset's datatype */ - if (H5Tdetect_class(m_tid1, H5T_VLEN) == TRUE) - vl_data = TRUE; - - /* - * determine the strip mine size and allocate a buffer. The strip mine is - * a hyperslab whose size is manageable. - */ + /* + * determine the strip mine size and allocate a buffer. The strip mine is + * a hyperslab whose size is manageable. + */ sm_nbytes = p_type_nbytes; - for (i = rank1; i > 0; --i) - { + for(i = rank1; i > 0; --i) { hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; - if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */ + + if(size == 0) /* datum size > H5TOOLS_BUFSIZE */ size = 1; sm_size[i - 1] = MIN(dims1[i - 1], size); sm_nbytes *= sm_size[i - 1]; assert(sm_nbytes > 0); - } + } /* end for */ /* malloc return code should be verified. * If fail, need to handle the error. @@ -481,63 +465,43 @@ hsize_t diff_datasetid( hid_t did1, memset(hs_offset, 0, sizeof hs_offset); memset(zero, 0, sizeof zero); - for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) - { + for(elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) { /* calculate the hyperslab size */ - if (rank1 > 0) - { - for (i = 0, hs_nelmts = 1; i < rank1; i++) - { + if(rank1 > 0) { + for(i = 0, hs_nelmts = 1; i < rank1; i++) { hs_size[i] = MIN(dims1[i] - hs_offset[i], sm_size[i]); hs_nelmts *= hs_size[i]; - } - if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) + } /* end for */ + if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) goto error; - if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) + if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) goto error; - if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0) + if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0) goto error; - } + } /* end if */ else - { - H5Sselect_all(sid1); - H5Sselect_all(sid2); - H5Sselect_all(sm_space); hs_nelmts = 1; - } /* rank */ - if ( H5Dread(did1,m_tid1,sm_space,sid1,H5P_DEFAULT,sm_buf1) < 0 ) + if(H5Dread(did1,m_tid1,sm_space,sid1,H5P_DEFAULT,sm_buf1) < 0) goto error; - if ( H5Dread(did2,m_tid2,sm_space,sid2,H5P_DEFAULT,sm_buf2) < 0 ) + if(H5Dread(did2,m_tid2,sm_space,sid2,H5P_DEFAULT,sm_buf2) < 0) goto error; /* get array differences. in the case of hyperslab read, increment the number of differences found in each hyperslab and pass the position at the beggining for printing */ - nfound += diff_array(sm_buf1, - sm_buf2, - hs_nelmts, - elmtno, - rank1, - dims1, - options, - name1, - name2, - m_tid1, - did1, - did2); + nfound += diff_array(sm_buf1, sm_buf2, hs_nelmts, elmtno, rank1, + dims1, options, name1, name2, m_tid1, did1, did2); /* reclaim any VL memory, if necessary */ - if(vl_data) - { + if(vl_data) { H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf1); H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf2); - } + } /* end if */ /* calculate the next hyperslab offset */ - for (i = rank1, carry = 1; i > 0 && carry; --i) - { + for(i = rank1, carry = 1; i > 0 && carry; --i) { hs_offset[i - 1] += hs_size[i - 1]; - if (hs_offset[i - 1] == dims1[i - 1]) + if(hs_offset[i - 1] == dims1[i - 1]) hs_offset[i - 1] = 0; else carry = 0; @@ -545,60 +509,53 @@ hsize_t diff_datasetid( hid_t did1, } /* elmtno */ H5Sclose(sm_space); - } /* hyperslab read */ - }/*can_compare*/ - - /*------------------------------------------------------------------------- - * compare attributes - * the if condition refers to cases when the dataset is a referenced object - *------------------------------------------------------------------------- - */ - - if (obj1_name) - { - nfound += diff_attr(did1,did2,obj1_name,obj2_name,options); - } + } /* hyperslab read */ + } /*can_compare*/ - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * compare attributes + * the if condition refers to cases when the dataset is a referenced object + *------------------------------------------------------------------------- + */ + if(obj1_name) + nfound += diff_attr(did1,did2,obj1_name,obj2_name,options); - /* free */ - if (buf1!=NULL) - { - free(buf1); - buf1=NULL; - } - if (buf2!=NULL) - { - free(buf2); - buf2=NULL; - } - if (sm_buf1!=NULL) - { - free(sm_buf1); - sm_buf1=NULL; - } - if (sm_buf2!=NULL) - { - free(sm_buf2); - sm_buf2=NULL; - } + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + + /* free */ + if(buf1 != NULL) { + free(buf1); + buf1 = NULL; + } /* end if */ + if(buf2 != NULL) { + free(buf2); + buf2 = NULL; + } /* end if */ + if(sm_buf1 != NULL) { + free(sm_buf1); + sm_buf1 = NULL; + } /* end if */ + if(sm_buf2 != NULL) { + free(sm_buf2); + sm_buf2 = NULL; + } /* end if */ - H5E_BEGIN_TRY { - H5Sclose(sid1); - H5Sclose(sid2); - H5Tclose(f_tid1); - H5Tclose(f_tid2); - H5Tclose(m_tid1); - H5Tclose(m_tid2); - } H5E_END_TRY; + H5E_BEGIN_TRY { + H5Sclose(sid1); + H5Sclose(sid2); + H5Tclose(f_tid1); + H5Tclose(f_tid2); + H5Tclose(m_tid1); + H5Tclose(m_tid2); + } H5E_END_TRY; - return nfound; + return nfound; error: - options->err_stat=1; + options->err_stat=1; /* free */ if (buf1!=NULL) |