From 6a2c50b10af4bc88e4b1a1a95cb3f9be813d61f2 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 5 Mar 2012 09:19:02 -0500 Subject: [svn-r22025] Cleanup compiler warnings. Add HD prefix to tools library based tests. Cleaned allocation/free in tests. Tested: local linux/ h5committetest --- hl/test/test_ds.c | 1237 ++++++++++++++++++++++------------- hl/test/test_image.c | 76 +-- hl/test/test_lite.c | 202 +++--- hl/test/test_packet.c | 14 +- hl/test/test_table.c | 62 +- test/big.c | 578 ++++++++-------- test/tmisc.c | 85 ++- tools/h5dump/h5dump.c | 54 +- tools/h5ls/h5ls.c | 1411 +++++++--------------------------------- tools/h5repack/h5repack_main.c | 28 +- tools/lib/h5tools_dump.c | 16 - tools/lib/h5tools_str.c | 9 +- tools/lib/h5trav.c | 6 +- 13 files changed, 1606 insertions(+), 2172 deletions(-) diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index 1bf268e..149a0fd 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -219,9 +219,9 @@ static hid_t create_test_file(const char *fileext) { char filename[65]; - strcpy(filename, FILENAME); - strcat(filename, fileext); - strcat(filename, FILEEXT); + HDstrcpy(filename, FILENAME); + HDstrcat(filename, fileext); + HDstrcat(filename, FILEEXT); return H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); } @@ -229,9 +229,9 @@ static hid_t open_test_file(const char *fileext) { char filename[65]; - strcpy(filename, FILENAME); - strcat(filename, fileext); - strcat(filename, FILEEXT); + HDstrcpy(filename, FILENAME); + HDstrcat(filename, fileext); + HDstrcat(filename, FILEEXT); return H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); } @@ -260,8 +260,8 @@ herr_t create_char_dataset(hid_t fid, const char *dsidx, int fulldims) char s33_wbuf[DIM3_SIZE] = {6,6,6,12,12,12,53,53,53,120,120,120}; char name[32]; - strcpy(name, DATASET_NAME); - strcat(name, dsidx); + HDstrcpy(name, DATASET_NAME); + HDstrcat(name, dsidx); /* make a dataset */ if(H5LTmake_dataset_char(fid, name, rank, dims, buf) >= 0) { if(fulldims==0) { @@ -313,8 +313,8 @@ herr_t create_short_dataset(hid_t fid, const char *dsidx, int fulldims) short s33_wbuf[DIM3_SIZE] = {6,6,6,12,12,12,53,53,53,140,140,140}; char name[32]; - strcpy(name, DATASET_NAME); - strcat(name, dsidx); + HDstrcpy(name, DATASET_NAME); + HDstrcat(name, dsidx); /* make a dataset */ if(H5LTmake_dataset_short(fid, name, rank, dims, buf) >= 0) { @@ -362,8 +362,8 @@ herr_t create_int_dataset(hid_t fid, const char *dsidx, int fulldims) int s22_wbuf[DIM2_SIZE] = {5,10,50,300}; char name[32]; - strcpy(name, DATASET_NAME); - strcat(name, dsidx); + HDstrcpy(name, DATASET_NAME); + HDstrcat(name, dsidx); /* make a dataset */ if(H5LTmake_dataset_int(fid, name, rank, dims, buf) >= 0) { @@ -415,7 +415,7 @@ herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int long s44_wbuf[DIM4_SIZE] = {280,280}; char name[32]; - strcpy(name, dsname); + HDstrcpy(name, dsname); /* make a dataset */ if(H5LTmake_dataset_long(fid, name, rank, dims, buf) >= 0) { @@ -470,8 +470,8 @@ herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims) float s22_wbuf[DIM2_SIZE] = {5,10,50,300}; char name[32]; - strcpy(name, DATASET_NAME); - strcat(name, dsidx); + HDstrcpy(name, DATASET_NAME); + HDstrcat(name, dsidx); /* make a dataset */ if(H5LTmake_dataset_float(fid, name, rank, dims, buf) >= 0) { @@ -505,15 +505,15 @@ herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ { char name[32]; - strcpy(name, DS_1_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_1_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_11_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_11_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; @@ -530,23 +530,23 @@ herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ { char name[32]; - strcpy(name, DS_2_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_2_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the second dimension */ if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_21_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_21_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } if(s2_wbuf!=NULL) { - strcpy(name, DS_22_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_22_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; @@ -563,31 +563,31 @@ herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ { char name[32]; - strcpy(name, DS_3_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_3_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_31_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_31_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } if(s2_wbuf!=NULL) { - strcpy(name, DS_32_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_32_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } if(s3_wbuf!=NULL) { - strcpy(name, DS_33_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_33_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s3_wbuf) < 0) return FAIL; @@ -604,15 +604,15 @@ herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize { char name[32]; - strcpy(name, DS_1_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_1_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_11_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_11_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; @@ -629,24 +629,24 @@ herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize { char name[32]; - strcpy(name, DS_2_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_2_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the second dimension */ if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_21_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_21_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } if(s2_wbuf!=NULL) { - strcpy(name, DS_22_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_22_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; @@ -663,32 +663,32 @@ herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize { char name[32]; - strcpy(name, DS_3_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_3_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_31_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_31_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } if(s2_wbuf!=NULL) { - strcpy(name, DS_32_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_32_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } if(s3_wbuf!=NULL) { - strcpy(name, DS_33_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_33_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s3_wbuf) < 0) return FAIL; @@ -705,16 +705,16 @@ herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t { char name[32]; - strcpy(name, DS_1_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_1_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_11_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_11_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; @@ -731,24 +731,24 @@ herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t { char name[32]; - strcpy(name, DS_2_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_2_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the second dimension */ if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_21_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_21_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } if(s2_wbuf!=NULL) { - strcpy(name, DS_22_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_22_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; @@ -765,32 +765,32 @@ herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t { char name[32]; - strcpy(name, DS_3_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_3_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_31_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_31_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } if(s2_wbuf!=NULL) { - strcpy(name, DS_32_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_32_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } if(s3_wbuf!=NULL) { - strcpy(name, DS_33_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_33_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s3_wbuf) < 0) return FAIL; @@ -807,16 +807,16 @@ herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ { char name[32]; - strcpy(name, DS_1_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_1_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_11_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_11_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; @@ -833,24 +833,24 @@ herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ { char name[32]; - strcpy(name, DS_2_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_2_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the second dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_21_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_21_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } if(s2_wbuf!=NULL) { - strcpy(name, DS_22_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_22_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; @@ -867,32 +867,32 @@ herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ { char name[32]; - strcpy(name, DS_3_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_3_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_31_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_31_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } if(s2_wbuf!=NULL) { - strcpy(name, DS_32_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_32_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } if(s3_wbuf!=NULL) { - strcpy(name, DS_33_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_33_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0) return FAIL; @@ -909,40 +909,40 @@ herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_ { char name[32]; - strcpy(name, DS_4_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_4_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_41_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_41_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } if(s2_wbuf!=NULL) { - strcpy(name, DS_42_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_42_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } if(s3_wbuf!=NULL) { - strcpy(name, DS_43_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_43_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0) return FAIL; } if(s4_wbuf!=NULL) { - strcpy(name, DS_44_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_44_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s4_wbuf) < 0) return FAIL; @@ -959,16 +959,16 @@ herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize { char name[32]; - strcpy(name, DS_1_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_1_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_11_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_11_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the first dimension */ if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; @@ -985,24 +985,24 @@ herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize { char name[32]; - strcpy(name, DS_2_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_2_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the second dimension */ if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_21_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_21_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } if(s2_wbuf!=NULL) { - strcpy(name, DS_22_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_22_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; @@ -1019,32 +1019,32 @@ herr_t create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize { char name[32]; - strcpy(name, DS_3_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_3_NAME); + HDstrcat(name, dsidx); /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0) return FAIL; if(s1_wbuf!=NULL) { - strcpy(name, DS_31_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_31_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0) return FAIL; } if(s2_wbuf!=NULL) { - strcpy(name, DS_32_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_32_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0) return FAIL; } if(s3_wbuf!=NULL) { - strcpy(name, DS_33_NAME); - strcat(name, dsidx); + HDstrcpy(name, DS_33_NAME); + HDstrcat(name, dsidx); /* make a DS dataset with an alternate scale for the second dimension */ if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s3_wbuf) < 0) return FAIL; @@ -1127,13 +1127,13 @@ herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *sc if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) { if(H5DSis_attached(did, dsid, idx) == 1) { if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) > 0) { - name_out = (char*)malloc(name_len * sizeof (char)); + name_out = (char*)HDmalloc(name_len * sizeof (char)); if(name_out != NULL) { if(H5DSget_scale_name(dsid, name_out, (size_t)name_len) >= 0) { - if(strcmp(scalename,name_out)==0) { + if(HDstrcmp(scalename,name_out)==0) { ret_value = SUCCEED; } - free(name_out); + HDfree(name_out); name_out=NULL; } } @@ -1262,7 +1262,7 @@ static int test_detachscales(void) goto out; } /* Check that attribute "DIMENSION_LIST" doesn't exist anymore */ - if(H5Aexists(did, DIMENSION_LIST)!= 0) + if(H5Aexists(did, DIMENSION_LIST)!= 0) goto out; if(H5Dclose(did) < 0) goto out; @@ -1294,8 +1294,8 @@ static int test_char_attachscales(const char *fileext) hid_t did = -1; char dsname[32]; char scalename[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "ac"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "ac"); TESTING2("test_char_attachscales"); @@ -1307,18 +1307,18 @@ static int test_char_attachscales(const char *fileext) goto out; if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "ac"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "ac"); if(test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; - strcpy(scalename, DS_2_NAME); - strcat(scalename, "ac"); + HDstrcpy(scalename, DS_2_NAME); + HDstrcat(scalename, "ac"); if(test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; - strcpy(scalename, DS_3_NAME); - strcat(scalename, "ac"); + HDstrcpy(scalename, DS_3_NAME); + HDstrcat(scalename, "ac"); if(test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; @@ -1350,8 +1350,8 @@ static int test_short_attachscales(const char *fileext) hid_t did = -1; char dsname[32]; char scalename[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "as"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "as"); TESTING2("test_short_attachscales"); @@ -1363,48 +1363,48 @@ static int test_short_attachscales(const char *fileext) goto out; if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "as"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "as"); if(test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; - strcpy(scalename, DS_11_NAME); - strcat(scalename, "as"); + HDstrcpy(scalename, DS_11_NAME); + HDstrcat(scalename, "as"); if(test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; - strcpy(scalename, DS_2_NAME); - strcat(scalename, "as"); + HDstrcpy(scalename, DS_2_NAME); + HDstrcat(scalename, "as"); if(test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; - strcpy(scalename, DS_21_NAME); - strcat(scalename, "as"); + HDstrcpy(scalename, DS_21_NAME); + HDstrcat(scalename, "as"); if(test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; - strcpy(scalename, DS_22_NAME); - strcat(scalename, "as"); + HDstrcpy(scalename, DS_22_NAME); + HDstrcat(scalename, "as"); if(test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; - strcpy(scalename, DS_3_NAME); - strcat(scalename, "as"); + HDstrcpy(scalename, DS_3_NAME); + HDstrcat(scalename, "as"); if(test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; - strcpy(scalename, DS_31_NAME); - strcat(scalename, "as"); + HDstrcpy(scalename, DS_31_NAME); + HDstrcat(scalename, "as"); if(test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; - strcpy(scalename, DS_32_NAME); - strcat(scalename, "as"); + HDstrcpy(scalename, DS_32_NAME); + HDstrcat(scalename, "as"); if(test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; - strcpy(scalename, DS_33_NAME); - strcat(scalename, "as"); + HDstrcpy(scalename, DS_33_NAME); + HDstrcat(scalename, "as"); if(test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; @@ -1436,8 +1436,8 @@ static int test_int_attachscales(const char *fileext) hid_t did = -1; char dsname[32]; char scalename[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "a"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "a"); TESTING2("test_int_attachscales"); @@ -1449,28 +1449,28 @@ static int test_int_attachscales(const char *fileext) goto out; if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "a"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "a"); if(test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; - strcpy(scalename, DS_11_NAME); - strcat(scalename, "a"); + HDstrcpy(scalename, DS_11_NAME); + HDstrcat(scalename, "a"); if(test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; - strcpy(scalename, DS_2_NAME); - strcat(scalename, "a"); + HDstrcpy(scalename, DS_2_NAME); + HDstrcat(scalename, "a"); if(test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; - strcpy(scalename, DS_21_NAME); - strcat(scalename, "a"); + HDstrcpy(scalename, DS_21_NAME); + HDstrcat(scalename, "a"); if(test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; - strcpy(scalename, DS_22_NAME); - strcat(scalename, "a"); + HDstrcpy(scalename, DS_22_NAME); + HDstrcat(scalename, "a"); if(test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; @@ -1502,8 +1502,8 @@ static int test_long_attachscales(const char *fileext) hid_t did = -1; char dsname[32]; char scalename[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "al"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "al"); TESTING2("test_long_attachscales"); @@ -1515,23 +1515,23 @@ static int test_long_attachscales(const char *fileext) goto out; if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "al"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "al"); if(test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; - strcpy(scalename, DS_2_NAME); - strcat(scalename, "al"); + HDstrcpy(scalename, DS_2_NAME); + HDstrcat(scalename, "al"); if(test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; - strcpy(scalename, DS_3_NAME); - strcat(scalename, "al"); + HDstrcpy(scalename, DS_3_NAME); + HDstrcat(scalename, "al"); if(test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; - strcpy(scalename, DS_4_NAME); - strcat(scalename, "al"); + HDstrcpy(scalename, DS_4_NAME); + HDstrcat(scalename, "al"); if(test_attach_scale(fid, did, scalename, DIM3) < 0) goto out; @@ -1563,8 +1563,8 @@ static int test_duplicatelong_attachscales(const char *fileext) hid_t did = -1; char dsname[32]; char scalename[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "al2"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "al2"); TESTING2("test_duplicatelong_attachscales"); @@ -1576,23 +1576,23 @@ static int test_duplicatelong_attachscales(const char *fileext) goto out; if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "al"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "al"); if(test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; - strcpy(scalename, DS_2_NAME); - strcat(scalename, "al"); + HDstrcpy(scalename, DS_2_NAME); + HDstrcat(scalename, "al"); if(test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; - strcpy(scalename, DS_3_NAME); - strcat(scalename, "al"); + HDstrcpy(scalename, DS_3_NAME); + HDstrcat(scalename, "al"); if(test_attach_scale(fid, did, scalename, DIM2) < 0) goto out; - strcpy(scalename, DS_4_NAME); - strcat(scalename, "al"); + HDstrcpy(scalename, DS_4_NAME); + HDstrcat(scalename, "al"); if(test_attach_scale(fid, did, scalename, DIM3) < 0) goto out; @@ -1624,8 +1624,8 @@ static int test_float_attachscales(const char *fileext) hid_t did = -1; char dsname[32]; char scalename[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "af"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "af"); TESTING2("test_float_attachscales"); @@ -1637,28 +1637,28 @@ static int test_float_attachscales(const char *fileext) goto out; if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "af"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "af"); if(test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; - strcpy(scalename, DS_11_NAME); - strcat(scalename, "af"); + HDstrcpy(scalename, DS_11_NAME); + HDstrcat(scalename, "af"); if(test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; - strcpy(scalename, DS_2_NAME); - strcat(scalename, "af"); + HDstrcpy(scalename, DS_2_NAME); + HDstrcat(scalename, "af"); if(test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; - strcpy(scalename, DS_21_NAME); - strcat(scalename, "af"); + HDstrcpy(scalename, DS_21_NAME); + HDstrcat(scalename, "af"); if(test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; - strcpy(scalename, DS_22_NAME); - strcat(scalename, "af"); + HDstrcpy(scalename, DS_22_NAME); + HDstrcat(scalename, "af"); if(test_attach_scale(fid, did, scalename, DIM1) < 0) goto out; @@ -1691,8 +1691,8 @@ static int test_numberofscales(const char *fileext) int nscales; /* number of scales in DIM */ char dsname[32]; char scalename[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "a"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "a"); TESTING2("test_numberofscales"); @@ -1718,8 +1718,8 @@ static int test_numberofscales(const char *fileext) else goto out; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "b"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "b"); /* make a dataset */ if(create_int_dataset(fid, "b", 1) < 0) @@ -1727,8 +1727,8 @@ static int test_numberofscales(const char *fileext) /* make a DS dataset for the first dimension */ if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "b"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "b"); if(test_attach_scale(fid, did, scalename, DIM0) < 0) goto out; @@ -1772,38 +1772,38 @@ static int test_char_scalenames(const char *fileext) { char dsname[32]; char scalename[32]; char name[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "ac"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "ac"); if((fid = open_test_file(fileext)) < 0) goto out; TESTING2("set char scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "ac"); - strcpy(name, SCALE_1_NAME); - strcat(name, "ac"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "ac"); + HDstrcpy(name, SCALE_1_NAME); + HDstrcat(name, "ac"); if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - strcpy(scalename, DS_2_NAME); - strcat(scalename, "ac"); - strcpy(name, SCALE_2_NAME); - strcat(name, "ac"); + HDstrcpy(scalename, DS_2_NAME); + HDstrcat(scalename, "ac"); + HDstrcpy(name, SCALE_2_NAME); + HDstrcat(name, "ac"); if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - strcpy(scalename, DS_3_NAME); - strcat(scalename, "ac"); - strcpy(name, SCALE_3_NAME); - strcat(name, "ac"); + HDstrcpy(scalename, DS_3_NAME); + HDstrcat(scalename, "ac"); + HDstrcpy(name, SCALE_3_NAME); + HDstrcat(name, "ac"); if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; @@ -1838,98 +1838,98 @@ static int test_short_scalenames(const char *fileext) { char dsname[32]; char scalename[32]; char name[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "as"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "as"); if((fid = open_test_file(fileext)) < 0) goto out; TESTING2("set short scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "as"); - strcpy(name, SCALE_1_NAME); - strcat(name, "as"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "as"); + HDstrcpy(name, SCALE_1_NAME); + HDstrcat(name, "as"); if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - strcpy(scalename, DS_11_NAME); - strcat(scalename, "as"); - strcpy(name, SCALE_11_NAME); - strcat(name, "as"); + HDstrcpy(scalename, DS_11_NAME); + HDstrcat(scalename, "as"); + HDstrcpy(name, SCALE_11_NAME); + HDstrcat(name, "as"); if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - strcpy(scalename, DS_2_NAME); - strcat(scalename, "as"); - strcpy(name, SCALE_2_NAME); - strcat(name, "as"); + HDstrcpy(scalename, DS_2_NAME); + HDstrcat(scalename, "as"); + HDstrcpy(name, SCALE_2_NAME); + HDstrcat(name, "as"); if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - strcpy(scalename, DS_21_NAME); - strcat(scalename, "as"); - strcpy(name, SCALE_21_NAME); - strcat(name, "as"); + HDstrcpy(scalename, DS_21_NAME); + HDstrcat(scalename, "as"); + HDstrcpy(name, SCALE_21_NAME); + HDstrcat(name, "as"); if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - strcpy(scalename, DS_22_NAME); - strcat(scalename, "as"); - strcpy(name, SCALE_22_NAME); - strcat(name, "as"); + HDstrcpy(scalename, DS_22_NAME); + HDstrcat(scalename, "as"); + HDstrcpy(name, SCALE_22_NAME); + HDstrcat(name, "as"); if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - strcpy(scalename, DS_3_NAME); - strcat(scalename, "as"); - strcpy(name, SCALE_3_NAME); - strcat(name, "as"); + HDstrcpy(scalename, DS_3_NAME); + HDstrcat(scalename, "as"); + HDstrcpy(name, SCALE_3_NAME); + HDstrcat(name, "as"); if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - strcpy(scalename, DS_31_NAME); - strcat(scalename, "as"); - strcpy(name, SCALE_31_NAME); - strcat(name, "as"); + HDstrcpy(scalename, DS_31_NAME); + HDstrcat(scalename, "as"); + HDstrcpy(name, SCALE_31_NAME); + HDstrcat(name, "as"); if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - strcpy(scalename, DS_32_NAME); - strcat(scalename, "as"); - strcpy(name, SCALE_32_NAME); - strcat(name, "as"); + HDstrcpy(scalename, DS_32_NAME); + HDstrcat(scalename, "as"); + HDstrcpy(name, SCALE_32_NAME); + HDstrcat(name, "as"); if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - strcpy(scalename, DS_33_NAME); - strcat(scalename, "as"); - strcpy(name, SCALE_33_NAME); - strcat(name, "as"); + HDstrcpy(scalename, DS_33_NAME); + HDstrcat(scalename, "as"); + HDstrcpy(name, SCALE_33_NAME); + HDstrcat(name, "as"); if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; @@ -1964,58 +1964,58 @@ static int test_int_scalenames(const char *fileext) { char dsname[32]; char scalename[32]; char name[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "a"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "a"); if((fid = open_test_file(fileext)) < 0) goto out; TESTING2("set int scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "a"); - strcpy(name, SCALE_1_NAME); - strcat(name, "a"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "a"); + HDstrcpy(name, SCALE_1_NAME); + HDstrcat(name, "a"); if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - strcpy(scalename, DS_11_NAME); - strcat(scalename, "a"); - strcpy(name, SCALE_11_NAME); - strcat(name, "a"); + HDstrcpy(scalename, DS_11_NAME); + HDstrcat(scalename, "a"); + HDstrcpy(name, SCALE_11_NAME); + HDstrcat(name, "a"); if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - strcpy(scalename, DS_2_NAME); - strcat(scalename, "a"); - strcpy(name, SCALE_2_NAME); - strcat(name, "a"); + HDstrcpy(scalename, DS_2_NAME); + HDstrcat(scalename, "a"); + HDstrcpy(name, SCALE_2_NAME); + HDstrcat(name, "a"); if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - strcpy(scalename, DS_21_NAME); - strcat(scalename, "a"); - strcpy(name, SCALE_21_NAME); - strcat(name, "a"); + HDstrcpy(scalename, DS_21_NAME); + HDstrcat(scalename, "a"); + HDstrcpy(name, SCALE_21_NAME); + HDstrcat(name, "a"); if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - strcpy(scalename, DS_22_NAME); - strcat(scalename, "a"); - strcpy(name, SCALE_22_NAME); - strcat(name, "a"); + HDstrcpy(scalename, DS_22_NAME); + HDstrcat(scalename, "a"); + HDstrcpy(name, SCALE_22_NAME); + HDstrcat(name, "a"); if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; @@ -2050,48 +2050,48 @@ static int test_long_scalenames(const char *fileext) { char dsname[32]; char scalename[32]; char name[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "al"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "al"); if((fid = open_test_file(fileext)) < 0) goto out; TESTING2("set long scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "al"); - strcpy(name, SCALE_1_NAME); - strcat(name, "al"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "al"); + HDstrcpy(name, SCALE_1_NAME); + HDstrcat(name, "al"); if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - strcpy(scalename, DS_2_NAME); - strcat(scalename, "al"); - strcpy(name, SCALE_2_NAME); - strcat(name, "al"); + HDstrcpy(scalename, DS_2_NAME); + HDstrcat(scalename, "al"); + HDstrcpy(name, SCALE_2_NAME); + HDstrcat(name, "al"); if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - strcpy(scalename, DS_3_NAME); - strcat(scalename, "al"); - strcpy(name, SCALE_3_NAME); - strcat(name, "al"); + HDstrcpy(scalename, DS_3_NAME); + HDstrcat(scalename, "al"); + HDstrcpy(name, SCALE_3_NAME); + HDstrcat(name, "al"); if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - strcpy(scalename, DS_4_NAME); - strcat(scalename, "al"); - strcpy(name, SCALE_4_NAME); - strcat(name, "al"); + HDstrcpy(scalename, DS_4_NAME); + HDstrcat(scalename, "al"); + HDstrcpy(name, SCALE_4_NAME); + HDstrcat(name, "al"); if(test_set_scalename(fid, did, scalename, name, DIM3) < 0) goto out; @@ -2126,48 +2126,48 @@ static int test_samelong_scalenames(const char *fileext) { char dsname[32]; char scalename[32]; char name[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "al2"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "al2"); if((fid = open_test_file(fileext)) < 0) goto out; TESTING2("set same long scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "al"); - strcpy(name, DS_1_NAME); - strcat(name, "al"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "al"); + HDstrcpy(name, DS_1_NAME); + HDstrcat(name, "al"); if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - strcpy(scalename, DS_2_NAME); - strcat(scalename, "al"); - strcpy(name, DS_2_NAME); - strcat(name, "al"); + HDstrcpy(scalename, DS_2_NAME); + HDstrcat(scalename, "al"); + HDstrcpy(name, DS_2_NAME); + HDstrcat(name, "al"); if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - strcpy(scalename, DS_3_NAME); - strcat(scalename, "al"); - strcpy(name, DS_3_NAME); - strcat(name, "al"); + HDstrcpy(scalename, DS_3_NAME); + HDstrcat(scalename, "al"); + HDstrcpy(name, DS_3_NAME); + HDstrcat(name, "al"); if(test_set_scalename(fid, did, scalename, name, DIM2) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0) goto out; - strcpy(scalename, DS_4_NAME); - strcat(scalename, "al"); - strcpy(name, DS_4_NAME); - strcat(name, "al"); + HDstrcpy(scalename, DS_4_NAME); + HDstrcat(scalename, "al"); + HDstrcpy(name, DS_4_NAME); + HDstrcat(name, "al"); if(test_set_scalename(fid, did, scalename, name, DIM3) < 0) goto out; @@ -2202,58 +2202,58 @@ static int test_float_scalenames(const char *fileext) { char dsname[32]; char scalename[32]; char name[32]; - strcpy(dsname, DATASET_NAME); - strcat(dsname, "af"); + HDstrcpy(dsname, DATASET_NAME); + HDstrcat(dsname, "af"); if((fid = open_test_file(fileext)) < 0) goto out; TESTING2("set float scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { - strcpy(scalename, DS_1_NAME); - strcat(scalename, "af"); - strcpy(name, SCALE_1_NAME); - strcat(name, "af"); + HDstrcpy(scalename, DS_1_NAME); + HDstrcat(scalename, "af"); + HDstrcpy(name, SCALE_1_NAME); + HDstrcat(name, "af"); if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - strcpy(scalename, DS_11_NAME); - strcat(scalename, "af"); - strcpy(name, SCALE_11_NAME); - strcat(name, "af"); + HDstrcpy(scalename, DS_11_NAME); + HDstrcat(scalename, "af"); + HDstrcpy(name, SCALE_11_NAME); + HDstrcat(name, "af"); if(test_set_scalename(fid, did, scalename, name, DIM0) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0) goto out; - strcpy(scalename, DS_2_NAME); - strcat(scalename, "af"); - strcpy(name, SCALE_2_NAME); - strcat(name, "af"); + HDstrcpy(scalename, DS_2_NAME); + HDstrcat(scalename, "af"); + HDstrcpy(name, SCALE_2_NAME); + HDstrcat(name, "af"); if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - strcpy(scalename, DS_21_NAME); - strcat(scalename, "af"); - strcpy(name, SCALE_21_NAME); - strcat(name, "af"); + HDstrcpy(scalename, DS_21_NAME); + HDstrcat(scalename, "af"); + HDstrcpy(name, SCALE_21_NAME); + HDstrcat(name, "af"); if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0) goto out; - strcpy(scalename, DS_22_NAME); - strcat(scalename, "af"); - strcpy(name, SCALE_22_NAME); - strcat(name, "af"); + HDstrcpy(scalename, DS_22_NAME); + HDstrcat(scalename, "af"); + HDstrcpy(name, SCALE_22_NAME); + HDstrcat(name, "af"); if(test_set_scalename(fid, did, scalename, name, DIM1) < 0) goto out; @@ -2293,10 +2293,10 @@ static int test_foreign_scaleattached(const char *fileforeign) /* compose the name of the file to open, using the srcdir, if appropriate */ if (srcdir) { - strcpy(filename,srcdir); - strcat(filename,"/"); + HDstrcpy(filename,srcdir); + HDstrcat(filename,"/"); } - strcat(filename, fileforeign); + HDstrcat(filename, fileforeign); TESTING2("test_foreign_scaleattached"); @@ -2537,22 +2537,46 @@ static int test_simple(void) goto out; + + /*------------------------------------------------------------------------- + * H5DSdetach_scale + *------------------------------------------------------------------------- + */ + TESTING2("detach scales "); + + + /*------------------------------------------------------------------------- + * create datasets: one "data" dataset and 4 dimension scales + *------------------------------------------------------------------------- + */ + + /* make a dataset */ if(H5LTmake_dataset_int(fid, "dset_c", rank, dims, buf) < 0) goto out; + /* make a DS dataset for the first dimension */ if(H5LTmake_dataset_int(fid, "ds_c_1", rankds, s1_dim, s1_wbuf) < 0) goto out; + /* make a DS dataset for the second dimension */ if(H5LTmake_dataset_int(fid, "ds_c_2", rankds, s2_dim, s2_wbuf) < 0) goto out; + /* make a DS dataset with an alternate scale for the 2nd dimension */ if(H5LTmake_dataset_int(fid, "ds_c_21", rankds, s2_dim, s2_wbuf) < 0) goto out; + /* make a DS dataset with an alternate scale for the 2nd dimension */ if(H5LTmake_dataset_int(fid, "ds_c_22", rankds, s2_dim, s2_wbuf) < 0) goto out; + + /*------------------------------------------------------------------------- + * attach the scales to "dset_c" + *------------------------------------------------------------------------- + */ + if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) goto out; if((dsid = H5Dopen2(fid,"ds_c_1", H5P_DEFAULT)) < 0) @@ -2590,14 +2614,20 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; + /*------------------------------------------------------------------------- + * verify if "dset_c" has dimension scales + *------------------------------------------------------------------------- + */ + if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) goto out; + /* verify that "dset_c" has 1 dimension scale at DIM 0 */ if((nscales = H5DSget_num_scales(did, 0)) < 0) goto out; if(nscales != 1) goto out; - + /* verify that "dset_c" has 3 dimension scales at DIM 1 */ if((nscales = H5DSget_num_scales(did, 1)) < 0) goto out; @@ -2607,21 +2637,39 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; + /*------------------------------------------------------------------------- + * detach the "ds_c_21" dimension scale to "dset_c" + *------------------------------------------------------------------------- + */ + + /* get the dataset id for "dset_c" */ if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) goto out; + + /* get the DS dataset id */ if((dsid = H5Dopen2(fid,"ds_c_21", H5P_DEFAULT)) < 0) goto out; + + /* detach the "ds_c_21" dimension scale to "dset_c" in DIM 1 */ if(H5DSdetach_scale(did, dsid, 1) < 0) goto out; + /* close DS id */ if(H5Dclose(dsid) < 0) goto out; + /* close dataset ID of "dset_c" */ if(H5Dclose(did) < 0) goto out; + /*------------------------------------------------------------------------- + * "dset_c" must have now 2 dimension scales at DIM 1 + *------------------------------------------------------------------------- + */ + if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) goto out; + /* verify that "dset_c" has 2 dimension scales at DIM 1 */ if((nscales = H5DSget_num_scales(did, 1)) < 0) goto out; @@ -2631,21 +2679,39 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; + /*------------------------------------------------------------------------- + * detach the "ds_c_22" dimension scale to "dset_c" + *------------------------------------------------------------------------- + */ + + /* get the dataset id for "dset_c" */ if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) goto out; + + /* get the DS dataset id */ if((dsid = H5Dopen2(fid,"ds_c_22", H5P_DEFAULT)) < 0) goto out; + + /* detach the "ds_c_22" dimension scale to "dset_c" in DIM 1 */ if(H5DSdetach_scale(did, dsid, 1) < 0) goto out; + /* close DS id */ if(H5Dclose(dsid) < 0) goto out; + /* close dataset ID of "dset_c" */ if(H5Dclose(did) < 0) goto out; + /*------------------------------------------------------------------------- + * "dset_c" must have now 1 dimension scale at DIM 1 + *------------------------------------------------------------------------- + */ + if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) goto out; + /* verify that "dset_c" has 1 dimension scale at DIM 1 */ if((nscales = H5DSget_num_scales(did, 1)) < 0) goto out; @@ -2655,21 +2721,39 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; + /*------------------------------------------------------------------------- + * detach the "ds_c_2" dimension scale to "dset_c" + *------------------------------------------------------------------------- + */ + + /* get the dataset id for "dset_c" */ if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) goto out; + + /* get the DS dataset id */ if((dsid = H5Dopen2(fid,"ds_c_2", H5P_DEFAULT)) < 0) goto out; + + /* detach the "ds_c_2" dimension scale to "dset_c" in DIM 1 */ if(H5DSdetach_scale(did, dsid, 1) < 0) goto out; + /* close DS id */ if(H5Dclose(dsid) < 0) goto out; + /* close dataset ID of "dset_c" */ if(H5Dclose(did) < 0) goto out; + /*------------------------------------------------------------------------- + * "dset_c" must have now 0 dimension scales at DIM 1 + *------------------------------------------------------------------------- + */ + if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0) goto out; + /* verify that "dset_c" has 1 dimension scale at DIM 1 */ if((nscales = H5DSget_num_scales(did, 1)) < 0) goto out; @@ -2679,12 +2763,22 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; + + /*------------------------------------------------------------------------- + * create 3 datasets: 1 "data" dataset and 2 dimension scales + *------------------------------------------------------------------------- + */ if(H5LTmake_dataset_int(fid,"dset_d",rank,dims,NULL) < 0) goto out; if(H5LTmake_dataset_int(fid,"ds_d_1",rankds,s1_dim,NULL) < 0) goto out; if(H5LTmake_dataset_int(fid,"ds_d_2",rankds,s2_dim,NULL) < 0) goto out; + + /*------------------------------------------------------------------------- + * attach them + *------------------------------------------------------------------------- + */ if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0) goto out; if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0) @@ -2706,6 +2800,11 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; + /*------------------------------------------------------------------------- + * verify + *------------------------------------------------------------------------- + */ + if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0) goto out; if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0) @@ -2725,90 +2824,169 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; + + /*------------------------------------------------------------------------- + * detach + *------------------------------------------------------------------------- + */ + + /* get the dataset id for "dset_d" */ if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0) goto out; + + /* get the DS dataset id */ if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0) goto out; + + /* detach the dimension scale to "dset_d" in DIM 0 */ if(H5DSdetach_scale(did,dsid,DIM0) < 0) goto out; + + /* verify attach, it must return 0 for no attach */ if(H5DSis_attached(did,dsid,DIM0)!=0) goto out; + + /* close DS id */ if(H5Dclose(dsid) < 0) goto out; + /* close dataset ID of "dset_d" */ if(H5Dclose(did) < 0) goto out; + /*------------------------------------------------------------------------- + * attach again + *------------------------------------------------------------------------- + */ + + /* get the dataset id for "dset_d" */ if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0) goto out; + + /* get the DS dataset id */ if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0) goto out; + + /* attach "ds_d_1" again in DIM 0 */ if(H5DSattach_scale(did,dsid,DIM0) < 0) goto out; + + /* verify attach, it must return 1 for attach */ if(H5DSis_attached(did,dsid,DIM0)!=1) goto out; + + /* verify that "ds_d_1" has only 1 scale at DIM0 */ if((nscales = H5DSget_num_scales(did,DIM0)) < 0) goto out; if(nscales != 1) goto out; + /* close DS id */ if(H5Dclose(dsid) < 0) goto out; + /* close dataset ID of "dset_d" */ if(H5Dclose(did) < 0) goto out; + /*------------------------------------------------------------------------- + * detach/detach + *------------------------------------------------------------------------- + */ + + /* get the dataset id for "dset_d" */ if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0) goto out; + + /* get the DS dataset id */ if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0) goto out; + + /* detach the "ds_d_2" dimension scale to "dset_d" in DIM 1 */ if(H5DSdetach_scale(did,dsid,DIM1) < 0) goto out; + + /* detach again, it should fail */ if(H5DSdetach_scale(did,dsid,DIM1)==SUCCEED) goto out; + + /* verify attach, it must return 0 for no attach */ if(H5DSis_attached(did,dsid,DIM1)!=0) goto out; + + /* verify that "ds_d_1" has no scale at DIM1 */ if((nscales = H5DSget_num_scales(did,DIM1)) < 0) goto out; if(nscales != 0) goto out; + /* close DS id */ if(H5Dclose(dsid) < 0) goto out; + /* close dataset ID of "dset_d" */ if(H5Dclose(did) < 0) goto out; + /*------------------------------------------------------------------------- + * attach twice + *------------------------------------------------------------------------- + */ + + /* get the dataset id for "dset_d" */ if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0) goto out; + + /* get the DS dataset id */ if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0) goto out; + + /* attach "ds_d_2" in DIM 1 */ if(H5DSattach_scale(did,dsid,DIM1) < 0) goto out; + + /* verify attach, it must return 1 for attach */ if(H5DSis_attached(did,dsid,DIM1)!=1) goto out; + + /* verify that "ds_d_2" has only 1 scale at DIM1 */ if((nscales = H5DSget_num_scales(did,DIM0)) < 0) goto out; if(nscales != 1) goto out; + /* attach "ds_d_2" again in DIM 1 */ if(H5DSattach_scale(did,dsid,DIM1) < 0) goto out; + + /* verify attach, it must return 1 for attach */ if(H5DSis_attached(did,dsid,DIM1)!=1) goto out; + + /* verify that "ds_d_2" has only 1 scale at DIM1 */ if((nscales = H5DSget_num_scales(did,DIM0)) < 0) goto out; if(nscales != 1) goto out; + /* close DS id */ if(H5Dclose(dsid) < 0) goto out; + /* close dataset ID of "dset_d" */ if(H5Dclose(did) < 0) goto out; + /*------------------------------------------------------------------------- + * create 10 datasets: 5 "data" dataset and 5 dimension scales + *------------------------------------------------------------------------- + */ + + /* create a group */ if((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; + + /* create the data space for the dataset */ if((sid = H5Screate_simple(rank,dims,NULL)) < 0) goto out; for(i = 0; i < 5; i++) { @@ -2825,6 +3003,12 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; } + + /*------------------------------------------------------------------------- + * attach for DIM 0 + *------------------------------------------------------------------------- + */ + for(i = 0; i < 5; i++) { sprintf(dname, "dset_%d", i); if((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0) @@ -2841,6 +3025,12 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; } + + /*------------------------------------------------------------------------- + * dettach for DIM0 + *------------------------------------------------------------------------- + */ + for(i = 0; i < 5; i++) { sprintf(dname, "dset_%d", i); if((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0) @@ -2857,13 +3047,18 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; } - for(i=0; i<5; i++) - { + + + /*------------------------------------------------------------------------- + * attach again for DIM0 + *------------------------------------------------------------------------- + */ + + for(i=0; i<5; i++) { sprintf(dname,"dset_%d",i); if((did = H5Dopen2(gid,dname, H5P_DEFAULT)) < 0) goto out; - for(j=0; j<5; j++) - { + for(j=0; j<5; j++) { sprintf(sname,"ds_%d",j); if((dsid = H5Dopen2(gid,sname, H5P_DEFAULT)) < 0) goto out; @@ -2875,16 +3070,30 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; } + + /* close */ if(H5Sclose(sid) < 0) goto out; if(H5Gclose(gid) < 0) goto out; + + + /*------------------------------------------------------------------------- + * create a dataset and attach only to 1 dimension + *------------------------------------------------------------------------- + */ + + /* make a dataset */ if(H5LTmake_dataset_int(fid,"dset_e",rank,dims,NULL) < 0) goto out; + + /* make a scale */ if(H5LTmake_dataset_int(fid,"ds_e_1",rankds,s1_dim,NULL) < 0) goto out; + + /* attach the DS to dimension 1 */ if((did = H5Dopen2(fid,"dset_e", H5P_DEFAULT)) < 0) goto out; if((dsid = H5Dopen2(fid,"ds_e_1", H5P_DEFAULT)) < 0) @@ -2893,15 +3102,15 @@ static int test_simple(void) goto out; if(H5DSis_attached(did,dsid,DIM1)<=0) goto out; - for(i=0; i 4 ) + if ( HDstrlen( buffer ) > 4 ) { - fclose(file); + HDfclose(file); return -1; } if (sscanf(buffer, "%u", &nentries) != 1) { - fclose(file); + HDfclose(file); return -1; } /* ensure there are a sensible number of colors in the palette */ if ((nentries > 256) || (nentries > palette_size)) { - fclose(file); + HDfclose(file); return(-1); } @@ -905,7 +905,7 @@ static int read_palette(const char* fname, /* extract the red, green and blue color components. */ if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3) { - fclose(file); + HDfclose(file); return -1; } /* store this palette entry */ @@ -915,7 +915,7 @@ static int read_palette(const char* fname, } /* close file */ - fclose(file); + HDfclose(file); return nentries; } diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c index d5382eb..18ebec2 100644 --- a/hl/test/test_lite.c +++ b/hl/test/test_lite.c @@ -367,7 +367,7 @@ static int test_dsets( void ) if ( H5LTread_dataset_string(file_id,DSET7_NAME,data_string_out) < 0 ) goto out; - if ( strcmp(data_string_in,data_string_out) != 0 ) + if ( HDstrcmp(data_string_in,data_string_out) != 0 ) goto out; @@ -536,7 +536,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) if ( H5LTget_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_out ) < 0 ) return -1; - if ( strcmp( attr_str_in, attr_str_out ) != 0 ) + if ( HDstrcmp( attr_str_in, attr_str_out ) != 0 ) { return -1; } @@ -1015,25 +1015,25 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) TESTING("H5LTget_attribute_info"); - dims_out = (hsize_t*) malloc( sizeof(hsize_t) * rank_out ); + if(NULL==(dims_out = (hsize_t*) HDmalloc( sizeof(hsize_t) * rank_out ))) return -1; - if ( H5LTget_attribute_info( loc_id, obj_name, ATTR2_NAME, dims_out, &type_class, - &type_size) < 0 ) + if ( H5LTget_attribute_info( loc_id, obj_name, ATTR2_NAME, dims_out, &type_class, &type_size) < 0 ) { + HDfree( dims_out ); return -1; - - for (i = 0; i < rank_out; i++) - { + } + + for (i = 0; i < rank_out; i++) { if ( dims_out[i] != 5 ) { + HDfree( dims_out ); return -1; } } if ( type_class != H5T_INTEGER ) { + HDfree( dims_out ); return -1; } - - if ( dims_out ) - free( dims_out ); + HDfree( dims_out ); PASSED(); @@ -1066,12 +1066,18 @@ static int test_integers(void) if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) goto out; - dt_str = (char*)calloc(str_len, sizeof(char)); - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) + + if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + goto out; + if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + HDfree(dt_str); goto out; - if(strcmp(dt_str, "H5T_STD_I8BE")) + } + if(HDstrcmp(dt_str, "H5T_STD_I8BE")) { + HDfree(dt_str); goto out; - free(dt_str); + } + HDfree(dt_str); if(H5Tclose(dtype)<0) goto out; @@ -1117,12 +1123,18 @@ static int test_fps(void) if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) goto out; - dt_str = (char*)calloc(str_len, sizeof(char)); - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) + + if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + goto out; + if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + HDfree(dt_str); goto out; - if(strcmp(dt_str, "H5T_IEEE_F32BE")) + } + if(HDstrcmp(dt_str, "H5T_IEEE_F32BE")) { + HDfree(dt_str); goto out; - free(dt_str); + } + HDfree(dt_str); if(H5Tclose(dtype)<0) goto out; @@ -1180,14 +1192,18 @@ static int test_strings(void) if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) goto out; - dt_str = (char*)calloc(str_len, sizeof(char)); - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) + if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) goto out; - if(strcmp(dt_str, "H5T_STRING {\n STRSIZE 13;\n STRPAD H5T_STR_NULLTERM;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) { + if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + HDfree(dt_str); + goto out; + } + if(HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE 13;\n STRPAD H5T_STR_NULLTERM;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) { printf("dt=\n%s\n", dt_str); + HDfree(dt_str); goto out; } - free(dt_str); + HDfree(dt_str); if(H5Tclose(dtype)<0) goto out; @@ -1208,14 +1224,18 @@ static int test_strings(void) if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) goto out; - dt_str = (char*)calloc(str_len, sizeof(char)); - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) + if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) goto out; - if(strcmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) { + if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + HDfree(dt_str); + goto out; + } + if(HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) { printf("dt=\n%s\n", dt_str); + HDfree(dt_str); goto out; } - free(dt_str); + HDfree(dt_str); if(H5Tclose(dtype)<0) goto out; @@ -1257,14 +1277,18 @@ static int test_opaques(void) if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) goto out; - dt_str = (char*)calloc(str_len, sizeof(char)); - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) + if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) goto out; - if(strcmp(dt_str, "H5T_OPAQUE {\n OPQ_SIZE 19;\n OPQ_TAG \"This is a tag for opaque type\";\n }")) { + if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + HDfree(dt_str); + goto out; + } + if(HDstrcmp(dt_str, "H5T_OPAQUE {\n OPQ_SIZE 19;\n OPQ_TAG \"This is a tag for opaque type\";\n }")) { printf("dt=\n%s\n", dt_str); + HDfree(dt_str); goto out; } - free(dt_str); + HDfree(dt_str); if(H5Tclose(dtype)<0) goto out; @@ -1311,7 +1335,7 @@ static int test_enums(void) if(H5Tenum_nameof(dtype, &value1, name1, size)<0) goto out; - if(strcmp(name1, "BLUE")) + if(HDstrcmp(name1, "BLUE")) goto out; if(H5Tenum_valueof(dtype, name2, &value2)<0) @@ -1328,16 +1352,20 @@ static int test_enums(void) if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) goto out; - dt_str = (char*)calloc(str_len, sizeof(char)); - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) + if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + goto out; + if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + HDfree(dt_str); goto out; - if(strcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) { + } + if(HDstrcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) { printf("dt=\n%s\n", dt_str); + HDfree(dt_str); goto out; } - free(dt_str); + HDfree(dt_str); if(H5Tclose(dtype)<0) goto out; @@ -1385,14 +1413,18 @@ static int test_variables(void) if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) goto out; - dt_str = (char*)calloc(str_len, sizeof(char)); - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) + if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + goto out; + if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + HDfree(dt_str); goto out; - if(strcmp(dt_str, "H5T_VLEN {\n H5T_VLEN {\n H5T_STD_I32BE\n }\n }")) { + } + if(HDstrcmp(dt_str, "H5T_VLEN {\n H5T_VLEN {\n H5T_STD_I32BE\n }\n }")) { printf("dt=\n%s\n", dt_str); + HDfree(dt_str); goto out; } - free(dt_str); + HDfree(dt_str); if(H5Tclose(dtype)<0) goto out; @@ -1440,15 +1472,19 @@ static int test_arrays(void) if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) goto out; - dt_str = (char*)calloc(str_len, sizeof(char)); - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) + if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + goto out; + if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + HDfree(dt_str); goto out; - if(strcmp(dt_str, "H5T_ARRAY {\n [5][7][13] H5T_ARRAY {\n [17][19] H5T_COMPOUND {\n H5T_STD_I8BE \"arr_compound_1\" : 0;\n H5T_STD_I32BE \"arr_compound_2\" : 1;\n }\n }\n }")) { + } + if(HDstrcmp(dt_str, "H5T_ARRAY {\n [5][7][13] H5T_ARRAY {\n [17][19] H5T_COMPOUND {\n H5T_STD_I8BE \"arr_compound_1\" : 0;\n H5T_STD_I32BE \"arr_compound_2\" : 1;\n }\n }\n }")) { printf("dt=\n%s\n", dt_str); + HDfree(dt_str); goto out; } - free(dt_str); + HDfree(dt_str); if(H5Tclose(dtype)<0) goto out; @@ -1492,14 +1528,18 @@ static int test_compounds(void) if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) goto out; - dt_str = (char*)calloc(str_len, sizeof(char)); - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) + if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + goto out; + if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + HDfree(dt_str); goto out; - if(strcmp(dt_str, "H5T_COMPOUND {\n H5T_STD_I16BE \"one_field\" : 2;\n H5T_STD_U8LE \"two_field\" : 6;\n }")) { + } + if(HDstrcmp(dt_str, "H5T_COMPOUND {\n H5T_STD_I16BE \"one_field\" : 2;\n H5T_STD_U8LE \"two_field\" : 6;\n }")) { printf("dt=\n%s\n", dt_str); + HDfree(dt_str); goto out; } - free(dt_str); + HDfree(dt_str); if(H5Tclose(dtype)<0) goto out; @@ -1509,9 +1549,11 @@ static int test_compounds(void) if((memb_name = H5Tget_member_name(dtype, 1)) == NULL) goto out; - if(strcmp(memb_name, "i16_field")) + if(HDstrcmp(memb_name, "i16_field")) { + HDfree(memb_name); goto out; - free(memb_name); + } + HDfree(memb_name); if((memb_class = H5Tget_member_class(dtype, 2))<0) goto out; @@ -1575,17 +1617,22 @@ static int test_compound_bug(void) if((memb_name = H5Tget_member_name(dtype, 2)) == NULL) goto out; - if(strcmp(memb_name, "sub")) + if(HDstrcmp(memb_name, "sub")) { + HDfree(memb_name); goto out; - free(memb_name); + } + HDfree(memb_name); if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) goto out; - dt_str = (char*)calloc(str_len, sizeof(char)); - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) + if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) + goto out; + if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + HDfree(dt_str); goto out; - free(dt_str); + } + HDfree(dt_str); if(H5Tclose(dtype)<0) goto out; @@ -1607,18 +1654,23 @@ static int test_compound_bug(void) if((memb_name = H5Tget_member_name(dtype, 1)) == NULL) goto out; - if(strcmp(memb_name, "desc_________________________________________________________________________________________")) + if(HDstrcmp(memb_name, "desc_________________________________________________________________________________________")) { + HDfree(memb_name); goto out; - free(memb_name); + } + HDfree(memb_name); if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0) goto out; - dt_str = (char*)calloc(str_len, sizeof(char)); - if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) + if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char)))) goto out; + if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) { + HDfree(dt_str); + goto out; + } - free(dt_str); + HDfree(dt_str); if(H5Tclose(dtype)<0) goto out; @@ -1650,13 +1702,13 @@ static int test_complicated_compound(void) /* compose the name of the file to open, using the srcdir, if appropriate */ if(srcdir) { - strcpy(filename, srcdir); - strcat(filename, "/"); + HDstrcpy(filename, srcdir); + HDstrcat(filename, "/"); } - strcat(filename, INPUT_FILE); + HDstrcat(filename, INPUT_FILE); /* Open input file */ - fp = fopen(filename, "r"); + fp = HDfopen(filename, "r"); if(fp == NULL) { printf( "Could not find file %s. Try set $srcdir \n", filename); goto out; @@ -1666,23 +1718,23 @@ static int test_complicated_compound(void) * Library has convenient function getline() but isn't available on * all machines. */ - if((line = (char*)calloc(size, sizeof(char)))==NULL) + if((line = (char*)HDcalloc(size, sizeof(char)))==NULL) goto out; - if(fgets(line, (int)size, fp)==NULL) + if(HDfgets(line, (int)size, fp)==NULL) goto out; - while(strlen(line)==size-1) { + while(HDstrlen(line)==size-1) { size *= 2; if(line) - free(line); - if((line = (char*)calloc(size, sizeof(char)))==NULL) + HDfree(line); + if((line = (char*)HDcalloc(size, sizeof(char)))==NULL) goto out; - if(fseek(fp, 0L, SEEK_SET)!=0) + if(HDfseek(fp, 0L, SEEK_SET)!=0) goto out; - if(fgets(line, (int)size, fp)==NULL) + if(HDfgets(line, (int)size, fp)==NULL) goto out; } - fclose(fp); + HDfclose(fp); fp = NULL; if((dtype = H5LTtext_to_dtype(line, H5LT_DDL))<0) @@ -1700,7 +1752,7 @@ static int test_complicated_compound(void) goto out; if(line) - free(line); + HDfree(line); PASSED(); return 0; @@ -1708,9 +1760,9 @@ static int test_complicated_compound(void) out: if(line) - free(line); + HDfree(line); if(fp) - fclose(fp); + HDfclose(fp); H5_FAILED(); return -1; diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c index 3c258c1..9d3074d 100644 --- a/hl/test/test_packet.c +++ b/hl/test/test_packet.c @@ -72,7 +72,7 @@ static particle_t testPart[NRECORDS] = { */ static int cmp_par(size_t i, size_t j, particle_t *rbuf, particle_t *wbuf ) { - if ( ( strcmp( rbuf[i].name, wbuf[j].name ) != 0 ) || + if ( ( HDstrcmp( rbuf[i].name, wbuf[j].name ) != 0 ) || rbuf[i].lati != wbuf[j].lati || rbuf[i].longi != wbuf[j].longi || rbuf[i].pressure != wbuf[j].pressure || @@ -127,7 +127,7 @@ static int create_hl_table(hid_t fid) /* Define field information */ const char *field_names[NFIELDS] = - { "Name","Latitude", "Longitude", "Pressure", "Temperature" }; + { "Name","Latitude", "Longitude", "Pressure", "Temperature" }; hid_t field_type[NFIELDS]; hid_t string_type; hsize_t chunk_size = 10; @@ -182,7 +182,7 @@ static int test_create_close(hid_t fid) /* Create a datatype for the particle struct */ part_t = make_particle_type(); - assert(part_t != -1); + HDassert(part_t != -1); /* Create the table */ table = H5PTcreate_fl(fid, PT_NAME, part_t, (hsize_t)100, -1); @@ -460,7 +460,7 @@ static int test_big_table(hid_t fid) /* Create a datatype for the particle struct */ part_t = make_particle_type(); - assert(part_t != -1); + HDassert(part_t != -1); /* Create a new table */ table = H5PTcreate_fl(fid, "Packet Test Dataset2", part_t, (hsize_t)33, -1); @@ -712,7 +712,7 @@ static int test_opaque(hid_t fid) if ((part_t = H5Tcreate (H5T_OPAQUE, sizeof(particle_t) )) < 0 ) return -1; - assert(part_t != -1); + HDassert(part_t != -1); /* Tag the opaque datatype */ if ( H5Tset_tag(part_t, "Opaque Particle" ) < 0) @@ -787,7 +787,7 @@ test_compress(void) /* Create a datatype for the particle struct */ part_t = make_particle_type(); - assert(part_t != -1); + HDassert(part_t != -1); /* Create a new table with compression level 8 */ table = H5PTcreate_fl(fid1, "Compressed Test Dataset", part_t, (hsize_t)80, 8); @@ -1059,7 +1059,7 @@ int main(void) /* create a file using default properties */ fid=H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - puts("Testing packet table"); + HDputs("Testing packet table"); /* run tests */ if ( test_packet_table(fid) < 0) diff --git a/hl/test/test_table.c b/hl/test/test_table.c index a3d5f77..7107ab3 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -130,16 +130,16 @@ static hid_t h5file_open(const char *fname, unsigned flags) /* compose the name of the file to open, using the srcdir, if appropriate */ if (srcdir) { - strcpy(data_file,srcdir); - strcat(data_file,"/"); + HDstrcpy(data_file,srcdir); + HDstrcat(data_file,"/"); } - strcat(data_file,fname); + HDstrcat(data_file,fname); /* open */ if ((fid = H5Fopen(data_file,flags,H5P_DEFAULT))<0) { - fprintf(stderr,"Error: Cannot open file <%s>\n",data_file ); - exit(1); + HDfprintf(stderr,"Error: Cannot open file <%s>\n",data_file ); + HDexit(1); } return fid; @@ -151,16 +151,16 @@ static hid_t h5file_open(const char *fname, unsigned flags) */ static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf ) { - if ( ( strcmp( rbuf[i].name, wbuf[j].name ) != 0 ) || + if ( ( HDstrcmp( rbuf[i].name, wbuf[j].name ) != 0 ) || rbuf[i].lati != wbuf[j].lati || rbuf[i].longi != wbuf[j].longi || rbuf[i].pressure != wbuf[j].pressure || rbuf[i].temperature != wbuf[j].temperature ) { - fprintf(stderr,"read and write buffers have differences\n"); - fprintf(stderr,"%s %ld %f %f %d\n", + HDfprintf(stderr,"read and write buffers have differences\n"); + HDfprintf(stderr,"%s %ld %f %f %d\n", rbuf[i].name,rbuf[i].longi,rbuf[i].pressure,rbuf[i].temperature,rbuf[i].lati); - fprintf(stderr,"%s %ld %f %f %d\n", + HDfprintf(stderr,"%s %ld %f %f %d\n", wbuf[j].name,wbuf[j].longi,wbuf[j].pressure,wbuf[j].temperature,wbuf[j].lati); return -1; } @@ -504,9 +504,9 @@ static int test_table(hid_t fid, int do_write) *------------------------------------------------------------------------- */ if(do_write) - strcpy(tname,"table2"); + HDstrcpy(tname,"table2"); else - strcpy(tname,"table1"); + HDstrcpy(tname,"table1"); rstart=0; rrecords=8; @@ -654,7 +654,7 @@ static int test_table(hid_t fid, int do_write) wbufd[i].longi = wbuf[i].longi; wbufd[i].pressure = wbuf[i].pressure; wbufd[i].temperature = wbuf[i].temperature; - strcpy(wbufd[i].name, wbuf[i].name ); + HDstrcpy(wbufd[i].name, wbuf[i].name ); } @@ -1036,9 +1036,9 @@ static int test_table(hid_t fid, int do_write) rbuf[i].longi != position_in[i-NRECORDS_ADD+1].longi || rbuf[i].pressure != pressure_in[i-NRECORDS_ADD+1] ) { - fprintf(stderr,"%ld %f %d\n", + HDfprintf(stderr,"%ld %f %d\n", rbuf[i].longi,rbuf[i].pressure,rbuf[i].lati); - fprintf(stderr,"%ld %f %d\n", + HDfprintf(stderr,"%ld %f %d\n", position_in[i].longi,pressure_in[i],position_in[i].lati); goto out; } @@ -1153,7 +1153,7 @@ static int test_table(hid_t fid, int do_write) /* Compare the extracted table with the initial values */ for( i = 0; i < NRECORDS; i++ ) { - if ( ( strcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) || + if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) || namepre_out[i].pressure != namepre_in[i].pressure ) { goto out; } @@ -1162,7 +1162,7 @@ static int test_table(hid_t fid, int do_write) /* reset buffer */ for( i = 0; i < NRECORDS; i++ ) { - strcpy( namepre_out[i].name, "\0" ); + HDstrcpy( namepre_out[i].name, "\0" ); namepre_out[i].pressure = -1; } @@ -1182,7 +1182,7 @@ static int test_table(hid_t fid, int do_write) for( i = 0; i < 3; i++ ) { hsize_t iistart = start; - if ( ( strcmp( namepre_out[i].name, namepre_in[iistart+i].name ) != 0 ) || + if ( ( HDstrcmp( namepre_out[i].name, namepre_in[iistart+i].name ) != 0 ) || namepre_out[i].pressure != namepre_in[iistart+i].pressure ) { goto out; } @@ -1360,7 +1360,7 @@ static int test_table(hid_t fid, int do_write) /* compare the extracted table with the initial values */ for( i = 0; i < NRECORDS; i++ ) { - if ( ( strcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) || + if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) || namepre_out[i].pressure != namepre_in[i].pressure ) { goto out; } @@ -1369,7 +1369,7 @@ static int test_table(hid_t fid, int do_write) /* reset buffer */ for( i = 0; i < NRECORDS; i++ ) { - strcpy( namepre_out[i].name, "\0" ); + HDstrcpy( namepre_out[i].name, "\0" ); namepre_out[i].pressure = -1; } @@ -1391,7 +1391,7 @@ static int test_table(hid_t fid, int do_write) for( i = 0; i < 3; i++ ) { int iistart = (int) start; - if ( ( strcmp( namepre_out[i].name, wbuf[iistart+i].name ) != 0 ) || + if ( ( HDstrcmp( namepre_out[i].name, wbuf[iistart+i].name ) != 0 ) || namepre_out[i].pressure != wbuf[iistart+i].pressure ) { goto out; } @@ -1432,7 +1432,7 @@ static int test_table(hid_t fid, int do_write) /* compare the extracted table with the original array */ for( i = 0; i < NRECORDS; i++ ) { - if ( ( strcmp( rbuf2[i].name, wbuf[i].name ) != 0 ) || + if ( ( HDstrcmp( rbuf2[i].name, wbuf[i].name ) != 0 ) || rbuf2[i].lati != wbuf[i].lati || rbuf2[i].longi != wbuf[i].longi || rbuf2[i].pressure != wbuf[i].pressure || @@ -1473,7 +1473,7 @@ static int test_table(hid_t fid, int do_write) /* compare the extracted table with the original array */ for( i = 0; i < NRECORDS; i++ ) { - if ( ( strcmp( rbuf3[i].name, wbuf[i].name ) != 0 ) || + if ( ( HDstrcmp( rbuf3[i].name, wbuf[i].name ) != 0 ) || rbuf3[i].lati != wbuf[i].lati || rbuf3[i].longi != wbuf[i].longi || rbuf3[i].temperature != wbuf[i].temperature ) { @@ -1518,10 +1518,10 @@ static int test_table(hid_t fid, int do_write) TESTING2("getting field info"); /* alocate */ - names_out = (char**) malloc( sizeof(char*) * (size_t)NFIELDS ); + names_out = (char**) HDmalloc( sizeof(char*) * (size_t)NFIELDS ); for ( i = 0; i < NFIELDS; i++) { - names_out[i] = (char*) malloc( sizeof(char) * 255 ); + names_out[i] = (char*) HDmalloc( sizeof(char) * 255 ); } /* Get field info */ @@ -1530,7 +1530,7 @@ static int test_table(hid_t fid, int do_write) for ( i = 0; i < NFIELDS; i++) { - if ( (strcmp( field_names[i], names_out[i] ) != 0)) { + if ( (HDstrcmp( field_names[i], names_out[i] ) != 0)) { goto out; } } @@ -1538,9 +1538,9 @@ static int test_table(hid_t fid, int do_write) /* release */ for ( i = 0; i < NFIELDS; i++) { - free ( names_out[i] ); + HDfree ( names_out[i] ); } - free ( names_out ); + HDfree ( names_out ); PASSED(); @@ -1573,7 +1573,7 @@ int main(void) /* create a file using default properties */ fid=H5Fcreate("test_table.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT); - puts("Testing table with file creation mode (read/write in native architecture):"); + HDputs("Testing table with file creation mode (read/write in native architecture):"); /* test, do write */ if (test_table(fid,1)<0) @@ -1586,7 +1586,7 @@ int main(void) * test2: open a file written in test1 on a big-endian machine *------------------------------------------------------------------------- */ - puts("Testing table with file open mode (read big-endian data):"); + HDputs("Testing table with file open mode (read big-endian data):"); fid=h5file_open(TEST_FILE_BE,flags); @@ -1601,7 +1601,7 @@ int main(void) * test3: open a file written in test1 on a little-endian machine *------------------------------------------------------------------------- */ - puts("Testing table with file open mode (read little-endian data):"); + HDputs("Testing table with file open mode (read little-endian data):"); fid=h5file_open(TEST_FILE_LE,flags); @@ -1616,7 +1616,7 @@ int main(void) * test4: open a file written in test1 on the Cray T3 machine *------------------------------------------------------------------------- */ - puts("Testing table with file open mode (read Cray data):"); + HDputs("Testing table with file open mode (read Cray data):"); fid=h5file_open(TEST_FILE_CRAY,flags); diff --git a/test/big.c b/test/big.c index 24b2d25..dffbbeb 100644 --- a/test/big.c +++ b/test/big.c @@ -22,14 +22,14 @@ /* * The purpose of this test is to verify if a virtual file driver can handle: * a. Large file (2GB) - * This should exceed 32bits I/O system since offset is a signed - * integral type (in order to support negative offset with respect to - * end of file). + * This should exceed 32bits I/O system since offset is a signed + * integral type (in order to support negative offset with respect to + * end of file). * b. Extra Large file (4GB) - * This definite exceeds 32bit I/O and file systems. + * This definite exceeds 32bit I/O and file systems. * c. Huge file (tens of GB) - * This verifies the HDF5 library handles big logical file size - * correctly. + * This verifies the HDF5 library handles big logical file size + * correctly. * In practice, if a VFD can handle a big file size, there is no need to * test the smaller file sizes. E.g., If it can handle the Huge file, * there is no need to test the Extra large or Large files. Therefore the @@ -81,15 +81,15 @@ typedef enum vfd_t { SEC2_VFD, STDIO_VFD, FAMILY_VFD } vfd_t; fsizes_t file_size= NOFILE; const char *FILENAME[] = { - "big", - "sec2", - "stdio", - NULL + "big", + "sec2", + "stdio", + NULL }; -int cflag=1; /* check file system before test */ -int sparse_support=0; /* sparse file supported, default false */ -int have_space=0; /* enough space for huge file test, default false */ -hsize_t family_size_def=FAMILY_SIZE; /* default family file size */ +int cflag=1; /* check file system before test */ +int sparse_support=0; /* sparse file supported, default false */ +int have_space=0; /* enough space for huge file test, default false */ +hsize_t family_size_def=FAMILY_SIZE; /* default family file size */ /* Protocols */ static void usage(void); @@ -216,55 +216,55 @@ supports_big(vfd_t vfd) case FAMILY_VFD: case SEC2_VFD: case STDIO_VFD: - if ((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, 0666)) < 0) - goto error; - - /* Write a few byte at the beginning */ - if (5!=HDwrite(fd, "hello", (size_t)5)) - goto quit; - fsize = SFILE; - - /* Write a few bytes at 2GB */ - if (HDlseek(fd, 2*GB, SEEK_SET)!=2*GB) - goto quit; - if (5!=HDwrite(fd, "hello", (size_t)5)) - goto quit; - fsize = LFILE; - - /* Write a few bytes at 4GB */ - if (HDlseek(fd, 4*GB, SEEK_SET) != 4*GB) - goto quit; - if (5!=HDwrite(fd, "hello", (size_t)5)) - goto quit; - fsize = XLFILE; - - /* If this supports sparse_file, write a few bytes at 32GB */ - if (!sparse_support) - goto quit; - if (HDlseek(fd, 32*GB, SEEK_SET) != 32*GB) - goto quit; - if (5!=HDwrite(fd, "hello", (size_t)5)) - goto quit; - fsize = HUGEFILE; - - break; + if ((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, 0666)) < 0) + goto error; + + /* Write a few byte at the beginning */ + if (5!=HDwrite(fd, "hello", (size_t)5)) + goto quit; + fsize = SFILE; + + /* Write a few bytes at 2GB */ + if (HDlseek(fd, 2*GB, SEEK_SET)!=2*GB) + goto quit; + if (5!=HDwrite(fd, "hello", (size_t)5)) + goto quit; + fsize = LFILE; + + /* Write a few bytes at 4GB */ + if (HDlseek(fd, 4*GB, SEEK_SET) != 4*GB) + goto quit; + if (5!=HDwrite(fd, "hello", (size_t)5)) + goto quit; + fsize = XLFILE; + + /* If this supports sparse_file, write a few bytes at 32GB */ + if (!sparse_support) + goto quit; + if (HDlseek(fd, 32*GB, SEEK_SET) != 32*GB) + goto quit; + if (5!=HDwrite(fd, "hello", (size_t)5)) + goto quit; + fsize = HUGEFILE; + + break; default: - /* unknown or unsupported VFD */ - goto error; - break; + /* unknown or unsupported VFD */ + goto error; + break; } - + quit: if (HDclose(fd) < 0) - goto error; + goto error; if (HDremove("y.h5") < 0) - goto error; + goto error; return(fsize); error: if (fd >= 0){ - HDclose(fd); - HDremove("y.h5"); + HDclose(fd); + HDremove("y.h5"); } return (fsize); } @@ -300,30 +300,30 @@ enough_room(hid_t fapl) for (i=0; i=0; i++) { - HDsnprintf(name, sizeof name, filename, i); - if(HDclose(fd[i]) < 0) + HDsnprintf(name, sizeof name, filename, i); + if(HDclose(fd[i]) < 0) ret_value=0; - HDremove(name); + HDremove(name); } return ret_value; @@ -356,43 +356,43 @@ writer (char* filename, hid_t fapl, fsizes_t testsize, int wrt_n) hsize_t hs_start[1]; hsize_t hs_size[1]; hid_t file=-1, space1=-1, space2=-1, mem_space=-1, d1=-1, d2=-1; - int *buf = (int*)malloc (sizeof(int) * WRT_SIZE); + int *buf = (int*)HDmalloc (sizeof(int) * WRT_SIZE); int i, j; - FILE *out = fopen(DNAME, "w"); + FILE *out = HDfopen(DNAME, "w"); hid_t dcpl; switch(testsize){ case LFILE: - TESTING("Large dataset write(2GB)"); - /* reduce size1 to produce a 2GB dataset */ - size1[1] = 1024/16; - size2[0] /= 16; - break; + TESTING("Large dataset write(2GB)"); + /* reduce size1 to produce a 2GB dataset */ + size1[1] = 1024/16; + size2[0] /= 16; + break; case XLFILE: - TESTING("Extra large dataset write(4GB)"); - /* reduce size1 to produce a 4GB dataset */ - size1[1] = 1024/8; - size2[0] /= 8; - break; + TESTING("Extra large dataset write(4GB)"); + /* reduce size1 to produce a 4GB dataset */ + size1[1] = 1024/8; + size2[0] /= 8; + break; case HUGEFILE: - TESTING("Huge dataset write"); - /* Leave size1 as 32GB */ - break; + TESTING("Huge dataset write"); + /* Leave size1 as 32GB */ + break; case SFILE: - TESTING("small dataset write(1GB)"); - /* reduce size1 to produce a 1GB dataset */ - size1[1] = 1024/32; - size2[0] /= 32; - break; + TESTING("small dataset write(1GB)"); + /* reduce size1 to produce a 1GB dataset */ + size1[1] = 1024/32; + size2[0] /= 32; + break; case NOFILE: - /* what to do?? */ - HDfprintf(stdout, "Unexpected file size of NOFILE\n"); - goto error; - break; + /* what to do?? */ + HDfprintf(stdout, "Unexpected file size of NOFILE\n"); + goto error; + break; } /* @@ -400,30 +400,30 @@ writer (char* filename, hid_t fapl, fsizes_t testsize, int wrt_n) * which is a family of files. Each member of the family will be 1GB */ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { - goto error; + goto error; } /* Create simple data spaces according to the size specified above. */ if ((space1 = H5Screate_simple (4, size1, size1)) < 0 || - (space2 = H5Screate_simple (1, size2, size2)) < 0) { - goto error; + (space2 = H5Screate_simple (1, size2, size2)) < 0) { + goto error; } /* Create the datasets */ -/* - * The fix below is provided for bug#921 - * H5Dcreate with H5P_DEFAULT creation properties - * will create a set of solid 1GB files; test will crash if quotas are enforced - * or it will take some time to write a file. - * We should create a dataset allocating space late and never writing fill values. - * EIP 4/8/03 -*/ + /* + * The fix below is provided for bug#921 + * H5Dcreate with H5P_DEFAULT creation properties + * will create a set of solid 1GB files; test will crash if quotas are enforced + * or it will take some time to write a file. + * We should create a dataset allocating space late and never writing fill values. + * EIP 4/8/03 + */ dcpl = H5Pcreate(H5P_DATASET_CREATE); H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE); H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER); if((d1 = H5Dcreate2(file, "d1", H5T_NATIVE_INT, space1, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 || - (d2 = H5Dcreate2(file, "d2", H5T_NATIVE_INT, space2, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { - goto error; + (d2 = H5Dcreate2(file, "d2", H5T_NATIVE_INT, space2, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + goto error; } @@ -431,15 +431,15 @@ writer (char* filename, hid_t fapl, fsizes_t testsize, int wrt_n) hs_size[0] = WRT_SIZE; if ((mem_space = H5Screate_simple (1, hs_size, hs_size)) < 0) goto error; for (i=0; i}\n" - "\t-h\tPrint the help page\n" - "\t-c\tFile system Checking skipped. Caution: this test generates\n" - "\t\tmany big files and may fill up the file system.\n" - "\t-fsize\tChange family size default to where is\n" - "\t\ta positive float point number. Default value is %Hu.\n" - "Examples:\n" - "\tbig -fsize 2.1e9 \t# test with file size just under 2GB\n" - "\tbig -fsize 2.2e9 \t# test with file size just above 2GB\n" - "\tBe sure the file system can support the file size requested\n" - , (hsize_t)FAMILY_SIZE); + "Usage: big [-h] [-c] [-fsize }\n" + "\t-h\tPrint the help page\n" + "\t-c\tFile system Checking skipped. Caution: this test generates\n" + "\t\tmany big files and may fill up the file system.\n" + "\t-fsize\tChange family size default to where is\n" + "\t\ta positive float point number. Default value is %Hu.\n" + "Examples:\n" + "\tbig -fsize 2.1e9 \t# test with file size just under 2GB\n" + "\tbig -fsize 2.2e9 \t# test with file size just above 2GB\n" + "\tBe sure the file system can support the file size requested\n" + , (hsize_t)FAMILY_SIZE); } - + /* Flush stdout at the end of this test routine to ensure later output to */ /* stderr will not come out before it.*/ int testvfd(vfd_t vfd) @@ -611,107 +611,107 @@ int testvfd(vfd_t vfd) switch(vfd){ case FAMILY_VFD: - /* Test huge file with the family driver */ - puts("Testing big file with the Family Driver "); - if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; - - if (H5Pset_fapl_family(fapl, family_size_def, H5P_DEFAULT) < 0) - goto error; - - if (cflag){ - /* - * We shouldn't run this test if the file system doesn't support holes - * because we would generate multi-gigabyte files. - */ - puts("Checking if file system is adequate for this test..."); - if (sizeof(long long)<8 || 0==GB8LL) { - puts("Test skipped because sizeof(long long) is too small. This"); - puts("hardware apparently doesn't support 64-bit integer types."); - usage(); - goto quit; - } - if (!sparse_support) { - puts("Test skipped because file system does not support holes."); - usage(); - goto quit; - } - if (!enough_room(fapl)) { - puts("Test skipped because of quota (file size or num open files)."); - usage(); - goto quit; - } - } - - /* Do the test with the Family Driver */ - h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - - if (writer(filename, fapl, HUGEFILE, WRT_N)) goto error; - if (reader(filename, fapl)) goto error; - - puts("Test passed with the Family Driver."); - break; + /* Test huge file with the family driver */ + HDputs("Testing big file with the Family Driver "); + if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + if (H5Pset_fapl_family(fapl, family_size_def, H5P_DEFAULT) < 0) + goto error; + + if (cflag){ + /* + * We shouldn't run this test if the file system doesn't support holes + * because we would generate multi-gigabyte files. + */ + HDputs("Checking if file system is adequate for this test..."); + if (sizeof(long long)<8 || 0==GB8LL) { + HDputs("Test skipped because sizeof(long long) is too small. This"); + HDputs("hardware apparently doesn't support 64-bit integer types."); + usage(); + goto quit; + } + if (!sparse_support) { + HDputs("Test skipped because file system does not support holes."); + usage(); + goto quit; + } + if (!enough_room(fapl)) { + HDputs("Test skipped because of quota (file size or num open files)."); + usage(); + goto quit; + } + } + + /* Do the test with the Family Driver */ + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + + if (writer(filename, fapl, HUGEFILE, WRT_N)) goto error; + if (reader(filename, fapl)) goto error; + + HDputs("Test passed with the Family Driver."); + break; case SEC2_VFD: - testsize = supports_big(SEC2_VFD); - if (testsize == NOFILE) { - HDfprintf(stdout, "Test for sec2 is skipped because file system does not support big files.\n"); - goto quit; - } - /* Test big file with the SEC2 driver */ - puts("Testing big file with the SEC2 Driver "); + testsize = supports_big(SEC2_VFD); + if (testsize == NOFILE) { + HDfprintf(stdout, "Test for sec2 is skipped because file system does not support big files.\n"); + goto quit; + } + /* Test big file with the SEC2 driver */ + HDputs("Testing big file with the SEC2 Driver "); - if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; - if(H5Pset_fapl_sec2(fapl) < 0) - goto error; + if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if(H5Pset_fapl_sec2(fapl) < 0) + goto error; - h5_fixname(FILENAME[1], fapl, filename, sizeof filename); + h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if (writer(filename, fapl, testsize, WRT_N)) goto error; - if (reader(filename, fapl)) goto error; + if (writer(filename, fapl, testsize, WRT_N)) goto error; + if (reader(filename, fapl)) goto error; - puts("Test passed with the SEC2 Driver."); - break; + HDputs("Test passed with the SEC2 Driver."); + break; case STDIO_VFD: - testsize = supports_big(STDIO_VFD); - if (testsize == NOFILE) { - HDfprintf(stdout, "Test for stdio is skipped because file system does not support big files.\n"); - goto quit; - } - puts("\nTesting big file with the STDIO Driver "); + testsize = supports_big(STDIO_VFD); + if (testsize == NOFILE) { + HDfprintf(stdout, "Test for stdio is skipped because file system does not support big files.\n"); + goto quit; + } + HDputs("\nTesting big file with the STDIO Driver "); - if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; - if(H5Pset_fapl_stdio(fapl) < 0) - goto error; + if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if(H5Pset_fapl_stdio(fapl) < 0) + goto error; - h5_fixname(FILENAME[2], fapl, filename, sizeof filename); + h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if (writer(filename, fapl, testsize, WRT_N)) goto error; - if (reader(filename, fapl)) goto error; - puts("Test passed with the STDIO Driver."); - break; + if (writer(filename, fapl, testsize, WRT_N)) goto error; + if (reader(filename, fapl)) goto error; + HDputs("Test passed with the STDIO Driver."); + break; default: - puts("Unsupprted VFD"); - usage(); - goto error;; + HDputs("Unsupprted VFD"); + usage(); + goto error;; } /* end of switch (vfd) */ quit: /* End with normal return code */ /* Clean up the test file */ if (h5_cleanup(FILENAME, fapl)) HDremove(DNAME); - fflush(stdout); + HDfflush(stdout); return 0; error: if (fapl>=0) H5Pclose(fapl); - puts("*** TEST FAILED ***"); - fflush(stdout); + HDputs("*** TEST FAILED ***"); + HDfflush(stdout); return 1; } @@ -748,58 +748,58 @@ main (int ac, char **av) /* parameters setup */ while (--ac > 0){ - av++; - if (strcmp("-fsize", *av)==0){ - /* specify a different family file size */ - ac--; av++; - if (ac > 0) { - family_size_def = (hsize_t)HDstrtoull(*av, NULL, 0); - } - else{ - printf("***Missing fsize value***\n"); - usage(); - return 1; - } - } - else if (strcmp("-c", *av)==0){ - /* turn off file system check before test */ - cflag=0; - } - else if (strcmp("-h", *av)==0){ - usage(); - return 0; - }else{ - usage(); - return 1; - } + av++; + if (HDstrcmp("-fsize", *av)==0){ + /* specify a different family file size */ + ac--; av++; + if (ac > 0) { + family_size_def = (hsize_t)HDstrtoull(*av, NULL, 0); + } + else{ + printf("***Missing fsize value***\n"); + usage(); + return 1; + } + } + else if (HDstrcmp("-c", *av)==0){ + /* turn off file system check before test */ + cflag=0; + } + else if (HDstrcmp("-h", *av)==0){ + usage(); + return 0; + }else{ + usage(); + return 1; + } } /* check sparse file support unless cflag is not set. */ if (cflag) - sparse_support = is_sparse(); + sparse_support = is_sparse(); /* Choose random # seed */ seed = (unsigned long)HDtime(NULL); #ifdef QAK -/* seed = (unsigned long)1155438845; */ -HDfprintf(stderr, "Random # seed was: %lu\n", seed); + /* seed = (unsigned long)1155438845; */ + HDfprintf(stderr, "Random # seed was: %lu\n", seed); #endif /* QAK */ HDsrandom(seed); -/*=================================================*/ + /*=================================================*/ if (testvfd(FAMILY_VFD) != 0) - goto error; + goto error; if (testvfd(SEC2_VFD) != 0) - goto error; + goto error; if (testvfd(STDIO_VFD) != 0) - goto error; + goto error; /* End with normal exit code */ return 0; error: - puts("*** TEST FAILED ***"); + HDputs("*** TEST FAILED ***"); return 1; } diff --git a/test/tmisc.c b/test/tmisc.c index 12d8531..9689508 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -15,7 +15,7 @@ /*********************************************************** * -* Test program: tmisc +* Test program: tmisc * * Test miscellaneous features not tested elsewhere. Generally * regression tests for bugs that are reported and don't @@ -23,7 +23,7 @@ * *************************************************************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#define H5D_PACKAGE /*suppress error about including H5Dpkg */ /* Define this macro to indicate that the testing APIs should be available */ #define H5D_TESTING @@ -31,10 +31,10 @@ #include "hdf5.h" #include "testhdf5.h" #include "H5srcdir.h" -#include "H5Dpkg.h" /* Datasets */ +#include "H5Dpkg.h" /* Datasets */ /* Definitions for misc. test #1 */ -#define MISC1_FILE "tmisc1.h5" +#define MISC1_FILE "tmisc1.h5" #define MISC1_VAL (13417386) /* 0xccbbaa */ #define MISC1_VAL2 (15654348) /* 0xeeddcc */ #define MISC1_DSET_NAME "/scalar_set" @@ -166,8 +166,8 @@ typedef struct /* Definitions for misc. test #12 */ #define MISC12_FILE "tmisc12.h5" #define MISC12_DSET_NAME "Dataset" -#define MISC12_SPACE1_RANK 1 -#define MISC12_SPACE1_DIM1 4 +#define MISC12_SPACE1_RANK 1 +#define MISC12_SPACE1_DIM1 4 #define MISC12_CHUNK_SIZE 2 #define MISC12_APPEND_SIZE 5 @@ -453,7 +453,7 @@ static void test_misc2_write_attribute(void) ret = H5Aread(att1, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - free(data_check.string); + HDfree(data_check.string); ret = H5Aclose(att1); CHECK(ret, FAIL, "HAclose"); @@ -464,8 +464,6 @@ static void test_misc2_write_attribute(void) ret = H5Fclose(file1); CHECK(ret, FAIL, "H5Fclose"); - - root2 = H5Gopen2(file2, "/", H5P_DEFAULT); CHECK(root2, FAIL, "H5Gopen2"); @@ -480,7 +478,7 @@ static void test_misc2_write_attribute(void) ret = H5Aread(att2, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - free(data_check.string); + HDfree(data_check.string); ret = H5Aclose(att2); CHECK(ret, FAIL, "HAclose"); @@ -497,8 +495,8 @@ static void test_misc2_write_attribute(void) ret = H5Fclose(file2); CHECK(ret, FAIL, "H5Fclose"); - free(string_att1); - free(string_att2); + HDfree(string_att1); + HDfree(string_att2); return; } @@ -524,7 +522,7 @@ static void test_misc2_read_attribute(const char *filename, const char *att_name ret = H5Aread(att, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - free(data_check.string); + HDfree(data_check.string); ret = H5Aclose(att); CHECK(ret, FAIL, "H5Aclose"); @@ -732,7 +730,7 @@ delete_struct3(misc5_struct3_hndl *str3hndl) ret=H5Tclose(str3hndl->st3h_base); CHECK(ret,FAIL,"H5Tclose"); - free(str3hndl); + HDfree(str3hndl); } static void @@ -783,7 +781,7 @@ delete_struct2(misc5_struct2_hndl *str2hndl) H5Tclose(str2hndl->st2h_base); CHECK(ret,FAIL,"H5Tclose"); - free(str2hndl); + HDfree(str2hndl); } static void @@ -794,7 +792,7 @@ set_struct2(misc5_struct2 *buf) buf->st2_el1=MISC5_DBGELVAL2; buf->st2_el2.len=MISC5_DBGNELM3; - buf->st2_el2.p=malloc((buf->st2_el2.len)*sizeof(misc5_struct3)); + buf->st2_el2.p=HDmalloc((buf->st2_el2.len)*sizeof(misc5_struct3)); CHECK(buf->st2_el2.p,NULL,"malloc"); for(i=0; i<(buf->st2_el2.len); i++) @@ -804,7 +802,7 @@ set_struct2(misc5_struct2 *buf) static void clear_struct2(misc5_struct2 *buf) { - free(buf->st2_el2.p); + HDfree(buf->st2_el2.p); } /*********************** struct1 ***********************/ @@ -849,7 +847,7 @@ delete_struct1(misc5_struct1_hndl *str1hndl) ret=H5Tclose(str1hndl->st1h_base); CHECK(ret,FAIL,"H5Tclose"); - free(str1hndl); + HDfree(str1hndl); } static void @@ -860,7 +858,7 @@ set_struct1(misc5_struct1 *buf) buf->st1_el1=MISC5_DBGELVAL1; buf->st1_el2.len=MISC5_DBGNELM2; - buf->st1_el2.p=malloc((buf->st1_el2.len)*sizeof(misc5_struct2)); + buf->st1_el2.p=HDmalloc((buf->st1_el2.len)*sizeof(misc5_struct2)); CHECK(buf->st1_el2.p,NULL,"malloc"); for(i=0; i<(buf->st1_el2.len); i++) @@ -874,7 +872,7 @@ clear_struct1(misc5_struct1 *buf) for(i=0;ist1_el2.len;i++) clear_struct2(&((( misc5_struct2 *)(buf->st1_el2.p))[i])); - free(buf->st1_el2.p); + HDfree(buf->st1_el2.p); } static void @@ -910,7 +908,7 @@ test_misc5(void) /* Create the variable-length buffer */ buf.len = MISC5_DBGNELM1; - buf.p = malloc((buf.len) * sizeof(misc5_struct1)); + buf.p = HDmalloc((buf.len) * sizeof(misc5_struct1)); CHECK(buf.p, NULL, "malloc"); /* Create the top-level VL information */ @@ -926,7 +924,7 @@ test_misc5(void) clear_struct1(&(((misc5_struct1 *)(buf.p))[j])); /* Free the variable-length buffer */ - free(buf.p); + HDfree(buf.p); /* Close dataset */ ret = H5Dclose(dataset_id); @@ -1236,10 +1234,10 @@ test_misc8(void) MESSAGE(5, ("Testing dataset storage sizes\n")); /* Allocate space for the data to write & read */ - wdata=malloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1); + wdata=HDmalloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1); CHECK(wdata,NULL,"malloc"); #ifdef VERIFY_DATA - rdata=malloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1); + rdata=HDmalloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1); CHECK(rdata,NULL,"malloc"); #endif /* VERIFY_DATA */ @@ -1677,7 +1675,7 @@ test_misc8(void) CHECK(ret, FAIL, "H5Fclose"); /* Free the read & write buffers */ - free(wdata); + HDfree(wdata); #ifdef VERIFY_DATA free(rdata); #endif /* VERIFY_DATA */ @@ -1808,11 +1806,11 @@ test_misc11(void) unsigned sym_ik; /* Symbol table B-tree initial 'K' value */ unsigned istore_ik; /* Indexed storage B-tree initial 'K' value */ unsigned sym_lk; /* Symbol table B-tree leaf 'K' value */ - unsigned super; /* Superblock version # */ - unsigned freelist; /* Free list version # */ - unsigned stab; /* Symbol table entry version # */ - unsigned shhdr; /* Shared object header version # */ - unsigned nindexes; /* Shared message number of indexes */ + unsigned super; /* Superblock version # */ + unsigned freelist; /* Free list version # */ + unsigned stab; /* Symbol table entry version # */ + unsigned shhdr; /* Shared object header version # */ + unsigned nindexes; /* Shared message number of indexes */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -1978,10 +1976,10 @@ test_misc12(void) hsize_t dimsn[] = {MISC12_APPEND_SIZE}; hsize_t maxdims1[1] = {H5S_UNLIMITED}; hsize_t chkdims1[1] = {MISC12_CHUNK_SIZE}; - hsize_t newsize[1] = {MISC12_SPACE1_DIM1+MISC12_APPEND_SIZE}; - hsize_t offset[1] = {MISC12_SPACE1_DIM1}; - hsize_t count[1] = {MISC12_APPEND_SIZE}; - int i; /* counting variable */ + hsize_t newsize[1] = {MISC12_SPACE1_DIM1+MISC12_APPEND_SIZE}; + hsize_t offset[1] = {MISC12_SPACE1_DIM1}; + hsize_t count[1] = {MISC12_APPEND_SIZE}; + int i; /* counting variable */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -2235,7 +2233,7 @@ create_hdf_file(const char *name) /* Close the file */ ret = H5Fclose(fid); - assert(ret >= 0); + HDassert(ret >= 0); CHECK(ret, FAIL, "H5Fclose"); } @@ -2265,7 +2263,7 @@ insert_user_block(const char *old_name, const char *new_name,const char *str,siz VERIFY(written, size, "HDfwrite"); /* Open the old file */ - old_fp=fopen(old_name,"rb"); + old_fp=HDfopen(old_name,"rb"); CHECK(old_fp, NULL, "HDfopen"); /* Allocate space for the copy buffer */ @@ -2288,10 +2286,10 @@ insert_user_block(const char *old_name, const char *new_name,const char *str,siz VERIFY(ret, 0, "HDfclose"); /* Free the copy buffer */ - free(copy_buf); + HDfree(copy_buf); /* Free the user block */ - free(user_block); + HDfree(user_block); } static void @@ -4480,7 +4478,6 @@ test_misc25a(void) CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -4524,7 +4521,6 @@ test_misc25a(void) CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -4657,8 +4653,8 @@ test_misc25b(void) /* Build the name of the file, with the source directory */ if (srcdir && ((HDstrlen(srcdir) + HDstrlen(MISC25B_FILE) + 1) < sizeof(testfile))){ - HDstrcpy(testfile, srcdir); - HDstrcat(testfile, "/"); + HDstrcpy(testfile, srcdir); + HDstrcat(testfile, "/"); } HDstrcat(testfile, MISC25B_FILE); @@ -5169,7 +5165,7 @@ test_misc30_get_info_cb(hid_t loc_id, const char *name, const H5L_info_t UNUSED { H5O_info_t object_info; - return H5Oget_info_by_name(loc_id, name, &object_info, H5P_DEFAULT); + return H5Oget_info_by_name(loc_id, name, &object_info, H5P_DEFAULT); } static int @@ -5218,7 +5214,7 @@ test_misc30(void) CHECK(fid, FAIL, "H5Fopen"); if(get_info) { - ret = test_misc30_get_info(fid); + ret = test_misc30_get_info(fid); CHECK(ret, FAIL, "test_misc30_get_info"); } @@ -5289,7 +5285,6 @@ test_misc(void) test_misc29(); /* Test that speculative metadata reads are handled correctly */ test_misc30(); /* Exercise local heap loading bug where free lists were getting dropped */ - } /* test_misc() */ diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 73bfd13..64c5e7c 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -477,21 +477,21 @@ set_data_output_file(const char *fname, int is_bin) * so that rawdatastream is changed only when succeeded */ if (rawdatastream && rawdatastream != stdout) { - if (fclose(rawdatastream)) - perror("closing rawdatastream"); + if (HDfclose(rawdatastream)) + HDperror("closing rawdatastream"); else rawdatastream = NULL; } /* binary output */ if (is_bin) { - if ((f = fopen(fname, "wb")) != NULL) { + if ((f = HDfopen(fname, "wb")) != NULL) { rawdatastream = f; return 0; } } else { - if ((f = fopen(fname, "w")) != NULL) { + if ((f = HDfopen(fname, "w")) != NULL) { rawdatastream = f; return 0; } @@ -518,13 +518,13 @@ set_output_file(const char *fname) * so that rawoutstream is changed only when succeeded */ if (rawoutstream && rawoutstream != stdout) { - if (fclose(rawoutstream)) - perror("closing rawoutstream"); + if (HDfclose(rawoutstream)) + HDperror("closing rawoutstream"); else rawoutstream = NULL; } - if ((f = fopen(fname, "w")) != NULL) { + if ((f = HDfopen(fname, "w")) != NULL) { rawoutstream = f; return 0; } @@ -550,13 +550,13 @@ set_error_file(const char *fname) * so that rawerrorstream is changed only when succeeded */ if (rawerrorstream && rawerrorstream != stderr) { - if (fclose(rawerrorstream)) - perror("closing rawerrorstream"); + if (HDfclose(rawerrorstream)) + HDperror("closing rawerrorstream"); else rawerrorstream = NULL; } - if ((f = fopen(fname, "w")) != NULL) { + if ((f = HDfopen(fname, "w")) != NULL) { rawerrorstream = f; return 0; } @@ -584,15 +584,15 @@ set_binary_form(const char *form) { int bform = -1; - if (strcmp(form,"NATIVE") == 0 || strcmp(form,"MEMORY") == 0) { + if (HDstrcmp(form,"NATIVE") == 0 || HDstrcmp(form,"MEMORY") == 0) { /* native form */ bform = 0; } - else if (strcmp(form,"FILE") == 0) /* file type form */ + else if (HDstrcmp(form,"FILE") == 0) /* file type form */ bform = 1; - else if (strcmp(form,"LE") == 0) /* convert to little endian */ + else if (HDstrcmp(form,"LE") == 0) /* convert to little endian */ bform = 2; - else if (strcmp(form,"BE") == 0) /* convert to big endian */ + else if (HDstrcmp(form,"BE") == 0) /* convert to big endian */ bform = 3; return bform; @@ -619,9 +619,9 @@ set_sort_by(const char *form) { H5_index_t idx_type = H5_INDEX_UNKNOWN; - if (strcmp(form,"name")==0) /* H5_INDEX_NAME */ + if (HDstrcmp(form,"name")==0) /* H5_INDEX_NAME */ idx_type = H5_INDEX_NAME; - else if (strcmp(form,"creation_order")==0) /* H5_INDEX_CRT_ORDER */ + else if (HDstrcmp(form,"creation_order")==0) /* H5_INDEX_CRT_ORDER */ idx_type = H5_INDEX_CRT_ORDER; return idx_type; @@ -648,9 +648,9 @@ set_sort_order(const char *form) { H5_iter_order_t iter_order = H5_ITER_UNKNOWN; - if (strcmp(form,"ascending")==0) /* H5_ITER_INC */ + if (HDstrcmp(form,"ascending")==0) /* H5_ITER_INC */ iter_order = H5_ITER_INC; - else if (strcmp(form,"descending")==0) /* H5_ITER_DEC */ + else if (HDstrcmp(form,"descending")==0) /* H5_ITER_DEC */ iter_order = H5_ITER_DEC; return iter_order; @@ -689,7 +689,7 @@ parse_hsize_list(const char *h_list, subset_d *d) /* count how many integers do we have */ for (ptr = h_list; ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++) - if (isdigit(*ptr)) { + if (HDisdigit(*ptr)) { if (!last_digit) /* the last read character wasn't a digit */ size_count++; @@ -708,11 +708,11 @@ parse_hsize_list(const char *h_list, subset_d *d) p_list = (hsize_t *)HDcalloc(size_count, sizeof(hsize_t)); for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++) - if(isdigit(*ptr)) { + if(HDisdigit(*ptr)) { /* we should have an integer now */ - p_list[i++] = (hsize_t)atof(ptr); + p_list[i++] = (hsize_t)HDatof(ptr); - while (isdigit(*ptr)) + while (HDisdigit(*ptr)) /* scroll to end of integer */ ptr++; } @@ -744,7 +744,7 @@ parse_subset_params(char *dset) struct subset_t *s = NULL; register char *brace; - if (!disable_compact_subset && ((brace = strrchr(dset, '[')) != NULL)) { + if (!disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) { *brace++ = '\0'; s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t)); @@ -1196,7 +1196,7 @@ parse_start: usage(h5tools_getprogname()); goto error; } - if (strcmp(opt_arg,":") == 0) { + if (HDstrcmp(opt_arg,":") == 0) { xmlnsprefix = ""; } else { @@ -1474,7 +1474,7 @@ main(int argc, const char *argv[]) } } else { - if (useschema && strcmp(xmlnsprefix,"")) { + if (useschema && HDstrcmp(xmlnsprefix,"")) { error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -1515,7 +1515,7 @@ main(int argc, const char *argv[]) /* alternative first element, depending on schema or DTD. */ if (useschema) { - if (strcmp(xmlnsprefix,"") == 0) { + if (HDstrcmp(xmlnsprefix,"") == 0) { HDfprintf(rawoutstream, "\n", xml_dtd_uri); } @@ -1525,7 +1525,7 @@ main(int argc, const char *argv[]) char *indx; ns = HDstrdup(xmlnsprefix); - indx = strrchr(ns,(int)':'); + indx = HDstrrchr(ns,(int)':'); if (indx) *indx = '\0'; HDfprintf(rawoutstream, "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File\" " diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index 7315796..2171682 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -239,1071 +239,6 @@ usage: %s [OPTIONS] [OBJECTS...]\n\ } -/*------------------------------------------------------------------------- - * Function: display_string - * - * Purpose: Print a string value by escaping unusual characters. If - * STREAM is null then we only count how large the output would - * be. - * - * Return: Number of characters printed. - * - * Programmer: Robb Matzke - * Thursday, November 5, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static int -display_string(FILE *stream, const char *s, hbool_t escape_spaces) -{ - int nprint=0; - - for (/*void*/; s && *s; s++) { - switch (*s) { - case '"': - if (stream) HDfprintf(stream, "\\\""); - nprint += 2; - break; - case '\\': - if (stream) HDfprintf(stream, "\\\\"); - nprint += 2; - break; - case '\b': - if (stream) HDfprintf(stream, "\\b"); - nprint += 2; - break; - case '\f': - if (stream) HDfprintf(stream, "\\f"); - nprint += 2; - break; - case '\n': - if (stream) HDfprintf(stream, "\\n"); - nprint += 2; - break; - case '\r': - if (stream) HDfprintf(stream, "\\r"); - nprint += 2; - break; - case '\t': - if (stream) HDfprintf(stream, "\\t"); - nprint += 2; - break; - case ' ': - if (escape_spaces) { - if (stream) HDfprintf(stream, "\\ "); - nprint += 2; - } else { - if (stream) HDfprintf(stream, " "); - nprint++; - } - break; - default: - if (isprint((int)*s)) { - if (stream) HDfputc(*s, stream); - nprint++; - } else { - if (stream) { - HDfprintf(stream, "\\%03o", *((const unsigned char*)s)); - } - nprint += 4; - } - break; - } - } - return nprint; -} - - -/*------------------------------------------------------------------------- - * Function: display_obj_name - * - * Purpose: Print an object name and another string. - * - * Return: Success: TRUE - * - * Failure: FALSE, nothing printed - * - * Programmer: Quincey Koziol - * Tuesday, November 6, 2007 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static int -display_obj_name(FILE *stream, const iter_t *iter, const char *oname, - const char *s) -{ - static char fullname[NAME_BUF_SIZE]; /* Buffer for file and/or object name */ - const char *name = fullname; /* Pointer to buffer for printing */ - int n; - - if(show_file_name_g) - sprintf(fullname, "%s/%s", iter->fname, oname + iter->name_start); - else - name = oname + iter->name_start; - - /* Print the object name, either full name or base name */ - if(fullname_g) - n = display_string(stream, name, TRUE); - else { - const char *last_sep; /* The location of the last group separator */ - - /* Find the last component of the path name */ - if(NULL == (last_sep = HDstrrchr(name, '/'))) - last_sep = name; - else { - last_sep++; - } /* end else */ - n = display_string(stream, last_sep, TRUE); - } /* end else */ - HDfprintf(rawoutstream, "%*s ", MAX(0, (24 - n)), s); - - return TRUE; -} - - -/*------------------------------------------------------------------------- - * Function: display_native_type - * - * Purpose: Prints the name of a native C data type. - * - * Return: Success: TRUE - * - * Failure: FALSE, nothing printed. - * - * Programmer: Robb Matzke - * Thursday, November 5, 1998 - * - * Modifications: - * Robb Matzke, 1999-06-11 - * Added the C9x types, but we still prefer to display the types - * from the C language itself (like `int' vs. `int32_t'). - * - *------------------------------------------------------------------------- - */ -static hbool_t -display_native_type(hid_t type, int UNUSED ind) -{ - if (H5Tequal(type, H5T_NATIVE_SCHAR)==TRUE) { - HDfprintf(rawoutstream, "native signed char"); - } else if (H5Tequal(type, H5T_NATIVE_UCHAR)==TRUE) { - HDfprintf(rawoutstream, "native unsigned char"); - } else if (H5Tequal(type, H5T_NATIVE_INT)==TRUE) { - HDfprintf(rawoutstream, "native int"); - } else if (H5Tequal(type, H5T_NATIVE_UINT)==TRUE) { - HDfprintf(rawoutstream, "native unsigned int"); - } else if (H5Tequal(type, H5T_NATIVE_SHORT)==TRUE) { - HDfprintf(rawoutstream, "native short"); - } else if (H5Tequal(type, H5T_NATIVE_USHORT)==TRUE) { - HDfprintf(rawoutstream, "native unsigned short"); - } else if (H5Tequal(type, H5T_NATIVE_LONG)==TRUE) { - HDfprintf(rawoutstream, "native long"); - } else if (H5Tequal(type, H5T_NATIVE_ULONG)==TRUE) { - HDfprintf(rawoutstream, "native unsigned long"); - } else if (H5Tequal(type, H5T_NATIVE_LLONG)==TRUE) { - HDfprintf(rawoutstream, "native long long"); - } else if (H5Tequal(type, H5T_NATIVE_ULLONG)==TRUE) { - HDfprintf(rawoutstream, "native unsigned long long"); - } else if (H5Tequal(type, H5T_NATIVE_FLOAT)==TRUE) { - HDfprintf(rawoutstream, "native float"); - } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)==TRUE) { - HDfprintf(rawoutstream, "native double"); -#if H5_SIZEOF_LONG_DOUBLE !=0 - } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)==TRUE) { - HDfprintf(rawoutstream, "native long double"); -#endif - } else if (H5Tequal(type, H5T_NATIVE_INT8)==TRUE) { - HDfprintf(rawoutstream, "native int8_t"); - } else if (H5Tequal(type, H5T_NATIVE_UINT8)==TRUE) { - HDfprintf(rawoutstream, "native uint8_t"); - } else if (H5Tequal(type, H5T_NATIVE_INT16)==TRUE) { - HDfprintf(rawoutstream, "native int16_t"); - } else if (H5Tequal(type, H5T_NATIVE_UINT16)==TRUE) { - HDfprintf(rawoutstream, "native uint16_t"); - } else if (H5Tequal(type, H5T_NATIVE_INT32)==TRUE) { - HDfprintf(rawoutstream, "native int32_t"); - } else if (H5Tequal(type, H5T_NATIVE_UINT32)==TRUE) { - HDfprintf(rawoutstream, "native uint32_t"); - } else if (H5Tequal(type, H5T_NATIVE_INT64)==TRUE) { - HDfprintf(rawoutstream, "native int64_t"); - } else if (H5Tequal(type, H5T_NATIVE_UINT64)==TRUE) { - HDfprintf(rawoutstream, "native uint64_t"); - } else if (H5Tequal(type, H5T_NATIVE_INT_LEAST8)==TRUE) { - HDfprintf(rawoutstream, "native int_least8_t"); - } else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST8)==TRUE) { - HDfprintf(rawoutstream, "native uint_least8_t"); - } else if (H5Tequal(type, H5T_NATIVE_INT_LEAST16)==TRUE) { - HDfprintf(rawoutstream, "native int_least16_t"); - } else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST16)==TRUE) { - HDfprintf(rawoutstream, "native uint_least16_t"); - } else if (H5Tequal(type, H5T_NATIVE_INT_LEAST32)==TRUE) { - HDfprintf(rawoutstream, "native int_least32_t"); - } else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST32)==TRUE) { - HDfprintf(rawoutstream, "native uint_least32_t"); - } else if (H5Tequal(type, H5T_NATIVE_INT_LEAST64)==TRUE) { - HDfprintf(rawoutstream, "native int_least64_t"); - } else if (H5Tequal(type, H5T_NATIVE_UINT_LEAST64)==TRUE) { - HDfprintf(rawoutstream, "native uint_least64_t"); - } else if (H5Tequal(type, H5T_NATIVE_INT_FAST8)==TRUE) { - HDfprintf(rawoutstream, "native int_fast8_t"); - } else if (H5Tequal(type, H5T_NATIVE_UINT_FAST8)==TRUE) { - HDfprintf(rawoutstream, "native uint_fast8_t"); - } else if (H5Tequal(type, H5T_NATIVE_INT_FAST16)==TRUE) { - HDfprintf(rawoutstream, "native int_fast16_t"); - } else if (H5Tequal(type, H5T_NATIVE_UINT_FAST16)==TRUE) { - HDfprintf(rawoutstream, "native uint_fast16_t"); - } else if (H5Tequal(type, H5T_NATIVE_INT_FAST32)==TRUE) { - HDfprintf(rawoutstream, "native int_fast32_t"); - } else if (H5Tequal(type, H5T_NATIVE_UINT_FAST32)==TRUE) { - HDfprintf(rawoutstream, "native uint_fast32_t"); - } else if (H5Tequal(type, H5T_NATIVE_INT_FAST64)==TRUE) { - HDfprintf(rawoutstream, "native int_fast64_t"); - } else if (H5Tequal(type, H5T_NATIVE_UINT_FAST64)==TRUE) { - HDfprintf(rawoutstream, "native uint_fast64_t"); - } else if (H5Tequal(type, H5T_NATIVE_B8)==TRUE) { - HDfprintf(rawoutstream, "native 8-bit field"); - } else if (H5Tequal(type, H5T_NATIVE_B16)==TRUE) { - HDfprintf(rawoutstream, "native 16-bit field"); - } else if (H5Tequal(type, H5T_NATIVE_B32)==TRUE) { - HDfprintf(rawoutstream, "native 32-bit field"); - } else if (H5Tequal(type, H5T_NATIVE_B64)==TRUE) { - HDfprintf(rawoutstream, "native 64-bit field"); - } else if (H5Tequal(type, H5T_NATIVE_HSIZE)==TRUE) { - HDfprintf(rawoutstream, "native hsize_t"); - } else if (H5Tequal(type, H5T_NATIVE_HSSIZE)==TRUE) { - HDfprintf(rawoutstream, "native hssize_t"); - } else if (H5Tequal(type, H5T_NATIVE_HERR)==TRUE) { - HDfprintf(rawoutstream, "native herr_t"); - } else if (H5Tequal(type, H5T_NATIVE_HBOOL)==TRUE) { - HDfprintf(rawoutstream, "native hbool_t"); - } else { - return FALSE; - } - return TRUE; -} - - -/*------------------------------------------------------------------------- - * Function: display_ieee_type - * - * Purpose: Print the name of an IEEE floating-point data type. - * - * Return: Success: TRUE - * - * Failure: FALSE, nothing printed - * - * Programmer: Robb Matzke - * Thursday, November 5, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static hbool_t -display_ieee_type(hid_t type, int UNUSED ind) -{ - if (H5Tequal(type, H5T_IEEE_F32BE)==TRUE) { - HDfprintf(rawoutstream, "IEEE 32-bit big-endian float"); - } else if (H5Tequal(type, H5T_IEEE_F32LE)==TRUE) { - HDfprintf(rawoutstream, "IEEE 32-bit little-endian float"); - } else if (H5Tequal(type, H5T_IEEE_F64BE)==TRUE) { - HDfprintf(rawoutstream, "IEEE 64-bit big-endian float"); - } else if (H5Tequal(type, H5T_IEEE_F64LE)==TRUE) { - HDfprintf(rawoutstream, "IEEE 64-bit little-endian float"); - } else { - return FALSE; - } - return TRUE; -} - - -/*------------------------------------------------------------------------- - * Function: display_precision - * - * Purpose: Prints information on the next line about precision and - * padding if the precision is less than the total data type - * size. - * - * Return: void - * - * Programmer: Robb Matzke - * Thursday, November 5, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -display_precision(hid_t type, int ind) -{ - size_t prec; /* precision */ - H5T_pad_t plsb, pmsb; /* lsb and msb padding */ - const char *plsb_s=NULL; /* lsb padding string */ - const char *pmsb_s=NULL; /* msb padding string */ - size_t nbits; /* number of bits */ - - /* If the precision is less than the total size then show the precision - * and offset on the following line. Also display the padding - * information. */ - if (8*H5Tget_size(type)!=(prec=H5Tget_precision(type))) { - HDfprintf(rawoutstream, "\n%*s(%lu bit%s of precision beginning at bit %lu)", - ind, "", (unsigned long)prec, 1==prec?"":"s", - (unsigned long)H5Tget_offset(type)); - - H5Tget_pad(type, &plsb, &pmsb); - if (H5Tget_offset(type)>0) { - switch (plsb) { - case H5T_PAD_ZERO: - plsb_s = "zero"; - break; - case H5T_PAD_ONE: - plsb_s = "one"; - break; - case H5T_PAD_BACKGROUND: - plsb_s = "bkg"; - break; - case H5T_PAD_ERROR: - case H5T_NPAD: - plsb_s = "unknown"; - break; - default: - ; - break; - } - } - if (H5Tget_offset(type)+prec<8*H5Tget_size(type)) { - switch (pmsb) { - case H5T_PAD_ZERO: - pmsb_s = "zero"; - break; - case H5T_PAD_ONE: - pmsb_s = "one"; - break; - case H5T_PAD_BACKGROUND: - pmsb_s = "bkg"; - break; - case H5T_PAD_ERROR: - case H5T_NPAD: - pmsb_s = "unknown"; - break; - default: - ; - break; - } - } - if (plsb_s || pmsb_s) { - HDfprintf(rawoutstream, "\n%*s(", ind, ""); - if (plsb_s) { - nbits = H5Tget_offset(type); - HDfprintf(rawoutstream, "%lu %s bit%s at bit 0", - (unsigned long)nbits, plsb_s, 1==nbits?"":"s"); - } - if (plsb_s && pmsb_s) HDfprintf(rawoutstream, ", "); - if (pmsb_s) { - nbits = 8*H5Tget_size(type)-(H5Tget_offset(type)+prec); - HDfprintf(rawoutstream, "%lu %s bit%s at bit %lu", - (unsigned long)nbits, pmsb_s, 1==nbits?"":"s", - (unsigned long)(8*H5Tget_size(type)-nbits)); - } - HDfprintf(rawoutstream, ")"); - } - } -} - - -/*------------------------------------------------------------------------- - * Function: display_int_type - * - * Purpose: Print the name of an integer data type. Common information - * like number of bits, byte order, and sign scheme appear on - * the first line. Additional information might appear in - * parentheses on the following lines. - * - * Return: Success: TRUE - * - * Failure: FALSE, nothing printed - * - * Programmer: Robb Matzke - * Thursday, November 5, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static hbool_t -display_int_type(hid_t type, int ind) -{ - H5T_order_t order; /* byte order value */ - const char *order_s=NULL; /* byte order string */ - H5T_sign_t sign; /* sign scheme value */ - const char *sign_s=NULL; /* sign scheme string */ - - if (H5T_INTEGER!=H5Tget_class(type)) return FALSE; - - /* Byte order */ - if (H5Tget_size(type)>1) { - order = H5Tget_order(type); - if (H5T_ORDER_LE==order) { - order_s = " little-endian"; - } else if (H5T_ORDER_BE==order) { - order_s = " big-endian"; - } else if (H5T_ORDER_VAX==order) { - order_s = " mixed-endian"; - } else { - order_s = " unknown-byte-order"; - } - } else { - order_s = ""; - } - - /* Sign */ - if ((sign=H5Tget_sign(type))>=0) { - if (H5T_SGN_NONE==sign) { - sign_s = " unsigned"; - } else if (H5T_SGN_2==sign) { - sign_s = ""; - } else { - sign_s = " unknown-sign"; - } - } else { - sign_s = " unknown-sign"; - } - - /* Print size, order, and sign on first line, precision and padding - * information on the subsequent lines */ - HDfprintf(rawoutstream, "%lu-bit%s%s integer", - (unsigned long)(8*H5Tget_size(type)), order_s, sign_s); - display_precision(type, ind); - return TRUE; -} - - -/*------------------------------------------------------------------------- - * Function: display_float_type - * - * Purpose: Print info about a floating point data type. - * - * Return: Success: TRUE - * - * Failure: FALSE, nothing printed - * - * Programmer: Robb Matzke - * Thursday, November 5, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static hbool_t -display_float_type(hid_t type, int ind) -{ - H5T_order_t order; /* byte order value */ - const char *order_s=NULL; /* byte order string */ - size_t spos; /* sign bit position */ - size_t esize, epos; /* exponent size and position */ - size_t msize, mpos; /* significand size and position */ - size_t ebias; /* exponent bias */ - H5T_norm_t norm; /* significand normalization */ - const char *norm_s=NULL; /* normalization string */ - H5T_pad_t pad; /* internal padding value */ - const char *pad_s=NULL; /* internal padding string */ - - if (H5T_FLOAT!=H5Tget_class(type)) return FALSE; - - /* Byte order */ - if (H5Tget_size(type)>1) { - order = H5Tget_order(type); - if (H5T_ORDER_LE==order) { - order_s = " little-endian"; - } else if (H5T_ORDER_BE==order) { - order_s = " big-endian"; - } else if (H5T_ORDER_VAX==order) { - order_s = " mixed-endian"; - } else { - order_s = " unknown-byte-order"; - } - } else { - order_s = ""; - } - - /* Print size and byte order on first line, precision and padding on - * subsequent lines. */ - HDfprintf(rawoutstream, "%lu-bit%s floating-point", - (unsigned long)(8*H5Tget_size(type)), order_s); - display_precision(type, ind); - - /* Print sizes, locations, and other information about each field */ - H5Tget_fields (type, &spos, &epos, &esize, &mpos, &msize); - ebias = H5Tget_ebias(type); - norm = H5Tget_norm(type); - switch (norm) { - case H5T_NORM_IMPLIED: - norm_s = ", msb implied"; - break; - case H5T_NORM_MSBSET: - norm_s = ", msb always set"; - break; - case H5T_NORM_NONE: - norm_s = ", no normalization"; - break; - case H5T_NORM_ERROR: - norm_s = ", unknown normalization"; - break; - default: - ; - break; - } - HDfprintf(rawoutstream, "\n%*s(significant for %lu bit%s at bit %lu%s)", ind, "", - (unsigned long)msize, 1==msize?"":"s", (unsigned long)mpos, - norm_s); - HDfprintf(rawoutstream, "\n%*s(exponent for %lu bit%s at bit %lu, bias is 0x%lx)", - ind, "", (unsigned long)esize, 1==esize?"":"s", - (unsigned long)epos, (unsigned long)ebias); - HDfprintf(rawoutstream, "\n%*s(sign bit at %lu)", ind, "", (unsigned long)spos); - - /* Display internal padding */ - if (1+esize+msize0); - super = H5Tget_super(type); - HDfprintf(rawoutstream, "enum "); - display_type(super, ind+4); - HDfprintf(rawoutstream, " {"); - - /* Determine what data type to use for the native values. To simplify - * things we entertain three possibilities: - * 1. long long -- the largest native signed integer - * 2. unsigned long long -- the largest native unsigned integer - * 3. raw format */ - if (H5Tget_size(type)<=sizeof(long long)) { - dst_size = sizeof(long long); - if (H5T_SGN_NONE==H5Tget_sign(type)) { - native = H5T_NATIVE_ULLONG; - } else { - native = H5T_NATIVE_LLONG; - } - } else { - dst_size = H5Tget_size(type); - } - - /* Get the names and raw values of all members */ - name = HDcalloc(nmembs, sizeof(char*)); - value = (unsigned char *)HDcalloc(nmembs, MAX(H5Tget_size(type), dst_size)); - for (i=0; i0) H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT); - - /* Sort members by increasing value */ - /*not implemented yet*/ - - /* Print members */ - for (i=0; i", ind+4, ""); - HDfprintf(rawoutstream, "\n%*s}", ind, ""); - return TRUE; -} - - -/*------------------------------------------------------------------------- - * Function: display_string_type - * - * Purpose: Print information about a string data type. - * - * Return: Success: TRUE - * - * Failure: FALSE, nothing printed - * - * Programmer: Robb Matzke - * Thursday, November 5, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static hbool_t -display_string_type(hid_t type, int UNUSED ind) -{ - H5T_str_t pad; - const char *pad_s=NULL; - H5T_cset_t cset; - const char *cset_s=NULL; - - if (H5T_STRING!=H5Tget_class(type)) return FALSE; - - /* Padding */ - pad = H5Tget_strpad(type); - switch (pad) { - case H5T_STR_NULLTERM: - pad_s = "null-terminated"; - break; - case H5T_STR_NULLPAD: - pad_s = "null-padded"; - break; - case H5T_STR_SPACEPAD: - pad_s = "space-padded"; - break; - case H5T_STR_RESERVED_3: - case H5T_STR_RESERVED_4: - case H5T_STR_RESERVED_5: - case H5T_STR_RESERVED_6: - case H5T_STR_RESERVED_7: - case H5T_STR_RESERVED_8: - case H5T_STR_RESERVED_9: - case H5T_STR_RESERVED_10: - case H5T_STR_RESERVED_11: - case H5T_STR_RESERVED_12: - case H5T_STR_RESERVED_13: - case H5T_STR_RESERVED_14: - case H5T_STR_RESERVED_15: - case H5T_STR_ERROR: - pad_s = "unknown-format"; - break; - default: - ; - break; - } - - /* Character set */ - cset = H5Tget_cset(type); - switch (cset) { - case H5T_CSET_ASCII: - cset_s = "ASCII"; - break; - case H5T_CSET_UTF8: - cset_s = "UTF-8"; - break; - case H5T_CSET_RESERVED_2: - case H5T_CSET_RESERVED_3: - case H5T_CSET_RESERVED_4: - case H5T_CSET_RESERVED_5: - case H5T_CSET_RESERVED_6: - case H5T_CSET_RESERVED_7: - case H5T_CSET_RESERVED_8: - case H5T_CSET_RESERVED_9: - case H5T_CSET_RESERVED_10: - case H5T_CSET_RESERVED_11: - case H5T_CSET_RESERVED_12: - case H5T_CSET_RESERVED_13: - case H5T_CSET_RESERVED_14: - case H5T_CSET_RESERVED_15: - case H5T_CSET_ERROR: - cset_s = "unknown-character-set"; - break; - default: - ; - break; - } - - if (H5Tis_variable_str(type)) { - HDfprintf(rawoutstream, "variable-length"); - } else { - HDfprintf(rawoutstream, "%lu-byte", (unsigned long)H5Tget_size(type)); - } - HDfprintf(rawoutstream, " %s %s string", pad_s, cset_s); - return TRUE; -} - - -/*------------------------------------------------------------------------- - * Function: display_reference_type - * - * Purpose: Prints information about a reference data type. - * - * Return: Success: TRUE - * - * Failure: FALSE, nothing printed - * - * Programmer: Robb Matzke - * Thursday, November 5, 1998 - * - * Modifications: - * Robb Matzke, 1999-06-04 - * Knows about object and dataset region references. - * - *------------------------------------------------------------------------- - */ -static hbool_t -display_reference_type(hid_t type, int UNUSED ind) -{ - if (H5T_REFERENCE!=H5Tget_class(type)) return FALSE; - - if (H5Tequal(type, H5T_STD_REF_OBJ)==TRUE) { - HDfprintf(rawoutstream, "object reference"); - } else if (H5Tequal(type, H5T_STD_REF_DSETREG)==TRUE) { - HDfprintf(rawoutstream, "dataset region reference"); - } else { - HDfprintf(rawoutstream, "%lu-byte unknown reference", - (unsigned long)H5Tget_size(type)); - } - - return TRUE; -} - - -/*------------------------------------------------------------------------- - * Function: display_opaque_type - * - * Purpose: Prints information about an opaque data type. - * - * Return: Success: TRUE - * - * Failure: FALSE, nothing printed - * - * Programmer: Robb Matzke - * Monday, June 7, 1999 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static hbool_t -display_opaque_type(hid_t type, int ind) -{ - char *tag; - size_t size; - - if (H5T_OPAQUE!=H5Tget_class(type)) return FALSE; - - size = H5Tget_size(type); - HDfprintf(rawoutstream, "%lu-byte opaque type", (unsigned long)size); - if ((tag=H5Tget_tag(type))) { - HDfprintf(rawoutstream, "\n%*s(tag = \"", ind, ""); - display_string(rawoutstream, tag, FALSE); - HDfprintf(rawoutstream, "\")"); - HDfree(tag); - } - return TRUE; -} - - -/*------------------------------------------------------------------------- - * Function: display_vlen_type - * - * Purpose: Print information about a variable-length type - * - * Return: Success: TRUE - * - * Failure: FALSE - * - * Programmer: Robb Matzke - * Friday, December 1, 2000 - * - * Modifications: - *------------------------------------------------------------------------- - */ -static hbool_t -display_vlen_type(hid_t type, int ind) -{ - hid_t super; - - if (H5T_VLEN!=H5Tget_class(type)) return FALSE; - - HDfprintf(rawoutstream, "variable length of\n%*s", ind+4, ""); - super = H5Tget_super(type); - display_type(super, ind+4); - H5Tclose(super); - return TRUE; -} - - -/*--------------------------------------------------------------------------- - * Purpose: Print information about an array type - * - * Return: Success: TRUE - * - * Failure: FALSE - * - * Programmer: Robb Matzke - * Thursday, January 31, 2002 - * - * Modifications: - *--------------------------------------------------------------------------- - */ -static hbool_t -display_array_type(hid_t type, int ind) -{ - hid_t super; - int ndims, i; - hsize_t *dims=NULL; - - if (H5T_ARRAY!=H5Tget_class(type)) return FALSE; - ndims = H5Tget_array_ndims(type); - if (ndims) { - dims = (hsize_t *)HDmalloc(ndims*sizeof(dims[0])); - H5Tget_array_dims2(type, dims); - - /* Print dimensions */ - for (i=0; i1) { - order = H5Tget_order(type); - if (H5T_ORDER_LE==order) { - order_s = " little-endian"; - } else if (H5T_ORDER_BE==order) { - order_s = " big-endian"; - } else if (H5T_ORDER_VAX==order) { - order_s = " mixed-endian"; - } else { - order_s = "unknown-byte-order"; - } - } else { - order_s = ""; - } - - HDfprintf(rawoutstream, "%lu-bit%s bitfield", - (unsigned long)(8*H5Tget_size(type)), order_s); - display_precision(type, ind); - return TRUE; -} - - -/*------------------------------------------------------------------------- - * Function: display_type - * - * Purpose: Prints a data type definition. The definition is printed - * without any leading space or trailing line-feed (although - * there might be line-feeds inside the type definition). The - * first line is assumed to have IND characters before it on - * the same line (printed by the caller). - * - * Return: void - * - * Programmer: Robb Matzke - * Thursday, November 5, 1998 - * - * Modifications: - * Robb Matzke, 1999-06-11 - * Prints the OID of shared data types. - * - *------------------------------------------------------------------------- - */ -static void -display_type(hid_t type, int ind) -{ - H5T_class_t data_class = H5Tget_class(type); - - /* Bad data type */ - if (type<0) { - HDfprintf(rawoutstream, ""); - return; - } - - /* Shared? If so then print the type's OID */ - if(H5Tcommitted(type)) { - H5O_info_t oi; - - if(H5Oget_info(type, &oi) >= 0) - HDfprintf(rawoutstream, "shared-%lu:"H5_PRINTF_HADDR_FMT" ", - oi.fileno, oi.addr); - else - HDfprintf(rawoutstream, "shared "); - } /* end if */ - - /* Print the type */ - if((!simple_output_g && display_native_type(type, ind)) || - display_ieee_type(type, ind) || - display_int_type(type, ind) || - display_float_type(type, ind) || - display_cmpd_type(type, ind) || - display_enum_type(type, ind) || - display_string_type(type, ind) || - display_reference_type(type, ind) || - display_vlen_type(type, ind) || - display_array_type(type, ind) || - display_opaque_type(type, ind) || - display_bitfield_type(type, ind)) - return; - - /* Unknown type */ - HDfprintf(rawoutstream, "%lu-byte class-%u unknown", - (unsigned long)H5Tget_size(type), (unsigned)data_class); -} - /*------------------------------------------------------------------------- * Function: print_string @@ -1329,49 +264,50 @@ print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces) for (/*void*/; s && *s; s++) { switch (*s) { case '"': - h5tools_str_append(buffer, "\\\""); + if (buffer) h5tools_str_append(buffer, "\\\""); nprint += 2; break; case '\\': - h5tools_str_append(buffer, "\\\\"); + if (buffer) h5tools_str_append(buffer, "\\\\"); nprint += 2; break; case '\b': - h5tools_str_append(buffer, "\\b"); + if (buffer) h5tools_str_append(buffer, "\\b"); nprint += 2; break; case '\f': - h5tools_str_append(buffer, "\\f"); + if (buffer) h5tools_str_append(buffer, "\\f"); nprint += 2; break; case '\n': - h5tools_str_append(buffer, "\\n"); + if (buffer) h5tools_str_append(buffer, "\\n"); nprint += 2; break; case '\r': - h5tools_str_append(buffer, "\\r"); + if (buffer) h5tools_str_append(buffer, "\\r"); nprint += 2; break; case '\t': - h5tools_str_append(buffer, "\\t"); + if (buffer) h5tools_str_append(buffer, "\\t"); nprint += 2; break; case ' ': if (escape_spaces) { - h5tools_str_append(buffer, "\\ "); + if (buffer) h5tools_str_append(buffer, "\\ "); nprint += 2; } else { - h5tools_str_append(buffer, " "); + if (buffer) h5tools_str_append(buffer, " "); nprint++; } break; default: if (isprint((int)*s)) { - h5tools_str_append(buffer, "%c", *s); + if (buffer) h5tools_str_append(buffer, "%c", *s); nprint++; - } else { - h5tools_str_append(buffer, "\\%03o", *((const unsigned char*)s)); + } + else { + if (buffer) h5tools_str_append(buffer, "\\%03o", *((const unsigned char*)s)); nprint += 4; } break; @@ -2514,10 +1450,10 @@ dump_dataset_values(hid_t dset) } H5Tclose(f_type); - - HDfprintf(rawoutstream, "\n"); h5tools_str_close(&buffer); + + HDfprintf(rawoutstream, "\n"); } @@ -2694,18 +1630,15 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo, HDfree(buf); H5Tclose(p_type); } /* end if */ - HDfprintf(rawoutstream, "\n"); H5Sclose(space); H5Tclose(type); H5Aclose(attr); } - else { - HDfprintf(rawoutstream, "\n"); - } - h5tools_str_close(&buffer); + HDfprintf(rawoutstream, "\n"); + return 0; } @@ -2738,26 +1671,41 @@ dataset_list1(hid_t dset) int ndims; /* dimensionality */ H5S_class_t space_type; /* type of dataspace */ int i; + hsize_t curr_pos = 0; /* total data element position */ + h5tool_link_info_t lnk_info; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t *info = &ls_dataformat; + h5tool_format_t outputformat; + + HDmemset(&ctx, 0, sizeof(ctx)); + HDmemset(&buffer, 0, sizeof(h5tools_str_t)); + + h5tools_str_reset(&buffer); /* Information that goes on the same row as the name. The name has * already been printed. */ space = H5Dget_space(dset); space_type = H5Sget_simple_extent_type(space); ndims = H5Sget_simple_extent_dims(space, cur_size, max_size); - printf (" {"); + h5tools_str_append(&buffer, " {"); for (i=0; i0) { - HDfprintf(rawoutstream, "/%Hu", max_size[i]); + h5tools_str_append(&buffer, "/%s", "Inf"); + } + else if (max_size[i]!=cur_size[i] || verbose_g>0) { + h5tools_str_append(&buffer, "/"HSIZE_T_FORMAT, max_size[i]); } } - if (space_type==H5S_SCALAR) HDfprintf(rawoutstream, "SCALAR"); - else if (space_type==H5S_NULL) HDfprintf(rawoutstream, "NULL"); - HDfputc('}', rawoutstream); + if (space_type==H5S_SCALAR) h5tools_str_append(&buffer, "SCALAR"); + else if (space_type==H5S_NULL) h5tools_str_append(&buffer, "NULL"); + h5tools_str_append(&buffer, "}"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); H5Sclose (space); + h5tools_str_close(&buffer); + return 0; } @@ -2801,6 +1749,16 @@ dataset_list2(hid_t dset, const char UNUSED *name) double utilization; /* percent utilization of storage */ H5T_class_t tclass; /* datatype class identifier */ int i; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t *info = &ls_dataformat; + h5tool_format_t outputformat; + + HDmemset(&ctx, 0, sizeof(ctx)); + HDmemset(&buffer, 0, sizeof(h5tools_str_t)); + + h5tools_str_reset(&buffer); if(verbose_g > 0) { dcpl = H5Dget_create_plist(dset); @@ -2812,85 +1770,87 @@ dataset_list2(hid_t dset, const char UNUSED *name) hsize_t chsize[64]; /* chunk size in elements */ ndims = H5Pget_chunk(dcpl, NELMTS(chsize), chsize/*out*/); - HDfprintf(rawoutstream, " %-10s {", "Chunks:"); + h5tools_str_append(&buffer, " %-10s {", "Chunks:"); total = H5Tget_size(type); for (i=0; i0) { utilization = (total*100.0)/used; - HDfprintf(rawoutstream, ", %1.2f%% utilization", utilization); + h5tools_str_append(&buffer, ", %1.2f%% utilization", utilization); } } - HDfputc('\n', rawoutstream); + h5tools_str_append(&buffer, "\n"); /* Print information about external strorage */ if((nf = H5Pget_external_count(dcpl)) > 0) { for(i = 0, max_len = 0; i < nf; i++) { H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, NULL, NULL); - n = display_string(NULL, f_name, TRUE); + n = print_string(NULL, f_name, TRUE); max_len = MAX(max_len, n); } /* end for */ - HDfprintf(rawoutstream, " %-10s %d external file%s\n", + h5tools_str_append(&buffer, " %-10s %d external file%s\n", "Extern:", nf, 1==nf?"":"s"); - HDfprintf(rawoutstream, " %4s %10s %10s %10s %s\n", + h5tools_str_append(&buffer, " %4s %10s %10s %10s %s\n", "ID", "DSet-Addr", "File-Addr", "Bytes", "File"); - HDfprintf(rawoutstream, " %4s %10s %10s %10s ", + h5tools_str_append(&buffer, " %4s %10s %10s %10s ", "----", "----------", "----------", "----------"); - for (i=0; iline_ncols, 0, 0); /* Print address information */ if(address_g) @@ -2926,6 +1887,8 @@ dataset_list2(hid_t dset, const char UNUSED *name) H5Pclose(dcpl); } /* end if */ + h5tools_str_close(&buffer); + if(data_g) dump_dataset_values(dset); @@ -2954,9 +1917,23 @@ static herr_t datatype_list2(hid_t type, const char UNUSED *name) { if (verbose_g>0) { - HDfprintf(rawoutstream, " %-10s ", "Type:"); - display_type(type, 15); - HDfprintf(rawoutstream, "\n"); + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t *info = &ls_dataformat; + h5tool_format_t outputformat; + + HDmemset(&ctx, 0, sizeof(ctx)); + HDmemset(&buffer, 0, sizeof(h5tools_str_t)); + + h5tools_str_reset(&buffer); + + h5tools_str_append(&buffer, " %-10s ", "Type:"); + print_type(&buffer, type, 15); + h5tools_str_append(&buffer, "\n"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); + + h5tools_str_close(&buffer); } return 0; } @@ -2979,29 +1956,43 @@ datatype_list2(hid_t type, const char UNUSED *name) static herr_t list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void *_iter) { - H5O_type_t obj_type = oinfo->type; /* Type of the object */ - iter_t *iter = (iter_t*)_iter; + H5O_type_t obj_type = oinfo->type; /* Type of the object */ + iter_t *iter = (iter_t*)_iter; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t *info = &ls_dataformat; + h5tool_format_t outputformat; + + HDmemset(&ctx, 0, sizeof(ctx)); + HDmemset(&buffer, 0, sizeof(h5tools_str_t)); + + h5tools_str_reset(&buffer); /* Print the link's name, either full name or base name */ if(!iter->symlink_target) - display_obj_name(rawoutstream, iter, name, ""); + print_obj_name(&buffer, iter, name, ""); /* Check object information */ if(oinfo->type < 0 || oinfo->type >= H5O_TYPE_NTYPES) { - HDfprintf(rawoutstream, "Unknown type(%d)", (int)oinfo->type); + h5tools_str_append(&buffer, "Unknown type(%d)", (int)oinfo->type); obj_type = H5O_TYPE_UNKNOWN; } if(iter->symlink_target) - HDfputc('{', rawoutstream); + h5tools_str_append(&buffer, "{"); if(obj_type >= 0 && dispatch_g[obj_type].name) - HDfputs(dispatch_g[obj_type].name, rawoutstream); + h5tools_str_append(&buffer, "%s", dispatch_g[obj_type].name); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); /* Check if we've seen this object before */ if(first_seen) { - HDfprintf(rawoutstream, ", same as "); - display_string(rawoutstream, first_seen, TRUE); - if(!iter->symlink_target) - HDfprintf(rawoutstream, "\n"); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, ", same as "); + print_string(&buffer, first_seen, TRUE); + if(!iter->symlink_target) { + h5tools_str_append(&buffer, "\n"); + } + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); } /* end if */ else { hid_t obj = (-1); /* ID of object opened */ @@ -3010,15 +2001,20 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void * then return right away. */ if(obj_type >= 0 && (obj = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) { - HDfprintf(rawoutstream, " *ERROR*\n"); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, " *ERROR*\n"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); goto done; } /* end if */ /* List the first line of information for the object. */ if(obj_type >= 0 && dispatch_g[obj_type].list1) (dispatch_g[obj_type].list1)(obj); - if(!iter->symlink_target || (verbose_g > 0)) - HDfputc('\n', rawoutstream); + if(!iter->symlink_target || (verbose_g > 0)) { + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "\n"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); + } /* Show detailed information about the object, beginning with information * which is common to all objects. */ @@ -3032,8 +2028,10 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void H5Aiterate2(obj, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL); /* Object location & reference count */ - HDfprintf(rawoutstream, " %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", oinfo->fileno, oinfo->addr); - HDfprintf(rawoutstream, " %-10s %u\n", "Links:", (unsigned)oinfo->rc); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, " %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", oinfo->fileno, oinfo->addr); + h5tools_str_append(&buffer, " %-10s %u\n", "Links:", (unsigned)oinfo->rc); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); /* Modification time */ if(oinfo->mtime > 0) { @@ -3046,7 +2044,9 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void tm = HDlocaltime(&(oinfo->mtime)); if(tm) { HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); - HDfprintf(rawoutstream, " %-10s %s\n", "Modified:", buf); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, " %-10s %s\n", "Modified:", buf); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); } /* end if */ } /* end if */ @@ -3062,9 +2062,11 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void cmt_bufsize = H5Oget_comment(obj, comment, cmt_bufsize); if(cmt_bufsize > 0) { comment[cmt_bufsize] = 0; - HDfprintf(rawoutstream, " %-10s \"", "Comment:"); - display_string(rawoutstream, comment, FALSE); - HDfputs("\"\n", rawoutstream); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, " %-10s \"", "Comment:"); + print_string(&buffer, comment, FALSE); + h5tools_str_append(&buffer, "\"\n"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); } /* end if */ HDfree(comment); } @@ -3082,9 +2084,13 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void done: if(iter->symlink_target) { - HDfputs("}\n", rawoutstream); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "}\n"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); iter->symlink_target = FALSE; } + h5tools_str_close(&buffer); + return 0; } /* end list_obj() */ @@ -3110,7 +2116,17 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter) char *buf=NULL; iter_t *iter = (iter_t*)_iter; int ret; + hsize_t curr_pos = 0; /* total data element position */ h5tool_link_info_t lnk_info; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t *info = &ls_dataformat; + h5tool_format_t outputformat; + + HDmemset(&ctx, 0, sizeof(ctx)); + HDmemset(&buffer, 0, sizeof(h5tools_str_t)); + + h5tools_str_reset(&buffer); /* init linkinfo struct */ HDmemset(&lnk_info, 0, sizeof(h5tool_link_info_t)); @@ -3120,7 +2136,7 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter) lnk_info.opt.msg_mode=1; /* Print the link's name, either full name or base name */ - display_obj_name(rawoutstream, iter, name, ""); + print_obj_name(&buffer, iter, name, ""); switch(linfo->type) { case H5L_TYPE_SOFT: @@ -3135,20 +2151,24 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter) else if (no_dangling_link_g && ret == 0) iter->symlink_list->dangle_link = TRUE; - HDfputs("Soft Link {", rawoutstream); - HDfputs(buf, rawoutstream); - HDfputc('}', rawoutstream); + h5tools_str_append(&buffer, "Soft Link {"); + h5tools_str_append(&buffer, buf); + h5tools_str_append(&buffer, "}"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); if(follow_symlink_g) { hbool_t orig_grp_literal = grp_literal_g; - HDfputc(' ', rawoutstream); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, " "); /* Check if we have already seen this softlink */ if(symlink_is_visited(iter->symlink_list, linfo->type, NULL, buf)) { - HDfputs("{Already Visited}\n", rawoutstream); + h5tools_str_append(&buffer, "{Already Visited}\n"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); goto done; } + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); /* Add this link to the list of seen softlinks */ if(symlink_visit_add(iter->symlink_list, linfo->type, NULL, buf) < 0) @@ -3171,8 +2191,11 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter) grp_literal_g = orig_grp_literal; } - else - HDfputc('\n', rawoutstream); + else { + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "\n"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); + } break; @@ -3196,27 +2219,31 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter) if(H5Lunpack_elink_val(buf, linfo->u.val_size, NULL, &filename, &path) < 0) goto done; - HDfputs("External Link {", rawoutstream); - HDfputs(filename, rawoutstream); - HDfputc('/', rawoutstream); + h5tools_str_append(&buffer, "External Link {"); + h5tools_str_append(&buffer, filename); + h5tools_str_append(&buffer, "/"); if(*path != '/') - HDfputc('/', rawoutstream); - HDfputs(path, rawoutstream); - HDfputc('}', rawoutstream); + h5tools_str_append(&buffer, "/"); + h5tools_str_append(&buffer, path); + h5tools_str_append(&buffer, "}"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); /* Recurse through the external link */ /* keep the follow_elink_g for backward compatibility with -E */ if(follow_link) { hbool_t orig_grp_literal = grp_literal_g; - HDfputc(' ', rawoutstream); + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, " "); /* Check if we have already seen this elink */ if(symlink_is_visited(iter->symlink_list, linfo->type, filename, path)) { - HDfputs("{Already Visited}\n", rawoutstream); + h5tools_str_append(&buffer, "{Already Visited}\n"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); goto done; } + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); /* Add this link to the list of seen elinks */ if(symlink_visit_add(iter->symlink_list, linfo->type, filename, path) < 0) @@ -3242,17 +2269,19 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter) grp_literal_g = orig_grp_literal; } else - HDfputc('\n', rawoutstream); - + HDfprintf(rawoutstream, "\n"); } break; default: - HDfputs("UD Link {cannot follow UD links}\n", rawoutstream); + h5tools_str_append(&buffer, "UD Link {cannot follow UD links}\n"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); break; } /* end switch */ done: + h5tools_str_close(&buffer); + if (buf) HDfree(buf); return 0; @@ -3277,25 +2306,40 @@ done: static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter) { + int retval = 0; H5O_info_t oi; /* Information for object */ + hsize_t curr_pos = 0; /* total data element position */ + h5tool_link_info_t lnk_info; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t *info = &ls_dataformat; + h5tool_format_t outputformat; + + HDmemset(&ctx, 0, sizeof(ctx)); + HDmemset(&buffer, 0, sizeof(h5tools_str_t)); + + h5tools_str_reset(&buffer); /* Retrieve info for object to list */ if(H5Oget_info_by_name(file, oname, &oi, H5P_DEFAULT) < 0) { if(iter->symlink_target) { - HDfputs("{**NOT FOUND**}\n", rawoutstream); + h5tools_str_append(&buffer, "{**NOT FOUND**}\n"); iter->symlink_target = FALSE; } else - display_obj_name(rawoutstream, iter, oname, "**NOT FOUND**"); - return -1; + print_obj_name(&buffer, iter, oname, "**NOT FOUND**"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); + retval = -1; + goto done; } /* end if */ /* Check for group iteration */ if(H5O_TYPE_GROUP == oi.type && !grp_literal_g) { /* Get ID for group */ if(!iter->symlink_target && (iter->gid = H5Gopen2(file, oname, H5P_DEFAULT)) < 0) { - HDfprintf(rawerrorstream, "%s: unable to open '%s' as group\n", iter->fname, oname); - return 0; /* Previously "continue", when this code was in main(). + h5tools_str_append(&buffer, "%s: unable to open '%s' as group\n", iter->fname, oname); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); + goto done; /* Previously "continue", when this code was in main(). * We don't "continue" here in order to close the file * and free the file name properly. */ } /* end if */ @@ -3319,7 +2363,10 @@ visit_obj(hid_t file, const char *oname, iter_t *iter) list_obj(oname, &oi, NULL, iter); } /* end else */ - return 0; +done: + h5tools_str_close(&buffer); + + return retval; } @@ -3772,7 +2819,19 @@ main(int argc, const char *argv[]) if(HDstrcmp(oname, root_name)) { /* Check the type of link given */ if(H5Lget_info(file, oname, &li, H5P_DEFAULT) < 0) { - display_obj_name(rawoutstream, &iter, oname, "**NOT FOUND**"); + hsize_t curr_pos = 0; /* total data element position */ + h5tool_link_info_t lnk_info; + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t ctx; /* print context */ + h5tool_format_t *info = &ls_dataformat; + h5tool_format_t outputformat; + + HDmemset(&ctx, 0, sizeof(ctx)); + HDmemset(&buffer, 0, sizeof(h5tools_str_t)); + + h5tools_str_reset(&buffer); + print_obj_name(&buffer, &iter, oname, "**NOT FOUND**"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, info->line_ncols, 0, 0); leave(EXIT_FAILURE); } /* end if */ } /* end if */ diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index 06a4aa7..2702ecd 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -337,7 +337,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) case 'm': - options->min_comp = atoi( opt_arg ); + options->min_comp = HDatoi( opt_arg ); if ((int)options->min_comp<=0) { error_msg("invalid minimum compress size <%s>\n", opt_arg ); @@ -359,7 +359,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) case 'c': - options->grp_compact = atoi( opt_arg ); + options->grp_compact = HDatoi( opt_arg ); if (options->grp_compact>0) options->latest = 1; /* must use latest format */ break; @@ -367,7 +367,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) case 'd': - options->grp_indexed = atoi( opt_arg ); + options->grp_indexed = HDatoi( opt_arg ); if (options->grp_indexed>0) options->latest = 1; /* must use latest format */ break; @@ -382,7 +382,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) options->latest = 1; /* must use latest format */ if (msgPtr == NULL) { - ssize = atoi( opt_arg ); + ssize = HDatoi( opt_arg ); for (idx=0; idx<5; idx++) options->msg_size[idx] = ssize; } @@ -391,7 +391,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) char msgType[10]; HDstrcpy(msgType, msgPtr+1); msgPtr[0] = '\0'; - ssize = atoi( opt_arg ); + ssize = HDatoi( opt_arg ); if (HDstrncmp(msgType, "dspace",6) == 0) { options->msg_size[0] = ssize; } @@ -420,17 +420,17 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options) case 'b': - options->ublock_size = (hsize_t)atol( opt_arg ); + options->ublock_size = (hsize_t)HDatol( opt_arg ); break; case 't': - options->threshold = (hsize_t)atol( opt_arg ); + options->threshold = (hsize_t)HDatol( opt_arg ); break; case 'a': - options->alignment = atol( opt_arg ); + options->alignment = HDatol( opt_arg ); if ( options->alignment < 1 ) { error_msg("invalid alignment size\n", opt_arg ); @@ -491,7 +491,7 @@ void read_info(const char *filename, HDstrcat(data_file,filename); - if ((fp = fopen(data_file, "r")) == (FILE *)NULL) { + if ((fp = HDfopen(data_file, "r")) == (FILE *)NULL) { error_msg("cannot open options file %s\n", filename); HDexit(EXIT_FAILURE); } @@ -514,7 +514,7 @@ void read_info(const char *filename, while( c!=' ' ) { fscanf(fp, "%c", &c); - if (feof(fp)) break; + if (HDfeof(fp)) break; } c='0'; /* go until end */ @@ -523,7 +523,7 @@ void read_info(const char *filename, fscanf(fp, "%c", &c); comp_info[i]=c; i++; - if (feof(fp)) break; + if (HDfeof(fp)) break; if (c==10 /*eol*/) break; } comp_info[i-1]='\0'; /*cut the last " */ @@ -544,7 +544,7 @@ void read_info(const char *filename, while( c!=' ' ) { fscanf(fp, "%c", &c); - if (feof(fp)) break; + if (HDfeof(fp)) break; } c='0'; /* go until end */ @@ -553,7 +553,7 @@ void read_info(const char *filename, fscanf(fp, "%c", &c); comp_info[i]=c; i++; - if (feof(fp)) break; + if (HDfeof(fp)) break; if (c==10 /*eol*/) break; } comp_info[i-1]='\0'; /*cut the last " */ @@ -573,6 +573,6 @@ void read_info(const char *filename, } } - fclose(fp); + HDfclose(fp); return; } diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 15cb679..432821f 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -189,22 +189,6 @@ const h5tools_dump_header_t* h5tools_dump_header_format; table_t *h5dump_type_table = NULL; /*type table reference for datatype dump */ /* local prototypes */ - -hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, - h5tools_str_t *buffer/*string into which to render */, - hsize_t *curr_pos/*total data element position*/, - size_t ncols, hsize_t local_elmt_counter/*element counter*/, - hsize_t elmt_counter); - -hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, - h5tools_str_t *buffer/*string into which to render */, - hsize_t *curr_pos/*total data element position*/, - size_t ncols, hsize_t *ptdata, - hsize_t local_elmt_counter/*element counter*/, - hsize_t elmt_counter); - static int h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx, h5tools_str_t *buffer/*string into which to render */, size_t ncols, diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 1d99490..2bbafd8 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -173,7 +173,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) */ size_t newsize = MAX(str->len + nchars + 1, 2 * str->nalloc); HDassert(newsize > str->nalloc); /*overflow*/ - str->s = HDrealloc(str->s, newsize); + str->s = (char*)HDrealloc(str->s, newsize); HDassert(str->s); str->nalloc = newsize; } @@ -209,7 +209,7 @@ h5tools_str_reset(h5tools_str_t *str/*in,out*/) { if (!str->s || str->nalloc <= 0) { str->nalloc = STR_INIT_LEN; - str->s = HDmalloc(str->nalloc); + str->s = (char*)HDmalloc(str->nalloc); HDassert(str->s); } @@ -282,7 +282,7 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt) size_t n = sizeof(_temp); if (str->len - start + 1 > n) { n = str->len - start + 1; - temp = HDmalloc(n); + temp = (char*)HDmalloc(n); HDassert(temp); } @@ -1114,8 +1114,6 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) { - int x; - h5tools_str_append(str, "%s", "\n"); h5tools_str_indent(str, info, ctx); @@ -1123,7 +1121,6 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai else if (i && info->arr_sep) { /* if next element begin, add next line with indent */ if (is_next_arry_elmt) { - int x; is_next_arry_elmt = 0; h5tools_str_append(str, "%s", "\n "); diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index 3bb8b3f..ad8b9fe 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -151,7 +151,7 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo, size_t base_len = HDstrlen(udata->base_grp_name); size_t add_slash = base_len ? ((udata->base_grp_name)[base_len-1] != '/') : 1; - if(NULL == (new_name = HDmalloc(base_len + add_slash + HDstrlen(path) + 1))) + if(NULL == (new_name = (char*)HDmalloc(base_len + add_slash + HDstrlen(path) + 1))) return(H5_ITER_ERROR); HDstrcpy(new_name, udata->base_grp_name); if (add_slash) @@ -895,7 +895,7 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata) switch(linfo->type) { case H5L_TYPE_SOFT: if(linfo->u.val_size > 0) { - char *targbuf = HDmalloc(linfo->u.val_size + 1); + char *targbuf = (char*)HDmalloc(linfo->u.val_size + 1); HDassert(targbuf); H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT); @@ -912,7 +912,7 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata) const char *filename; const char *objname; - targbuf = HDmalloc(linfo->u.val_size + 1); + targbuf = (char*)HDmalloc(linfo->u.val_size + 1); HDassert(targbuf); H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT); -- cgit v0.12