diff options
author | Jacob Smith <jake.smith@hdfgroup.org> | 2019-07-22 21:55:37 (GMT) |
---|---|---|
committer | Jacob Smith <jake.smith@hdfgroup.org> | 2019-07-22 21:55:37 (GMT) |
commit | 7ff3a63d5f6c74210a7e5ee064086306436c4062 (patch) | |
tree | 812406ba59c35ae766ded6e7a53ea0db793667d3 | |
parent | 9103fd59530cc45cef39cba81e0f1330a94b4807 (diff) | |
download | hdf5-7ff3a63d5f6c74210a7e5ee064086306436c4062.zip hdf5-7ff3a63d5f6c74210a7e5ee064086306436c4062.tar.gz hdf5-7ff3a63d5f6c74210a7e5ee064086306436c4062.tar.bz2 |
Minor formatting adjustments.
-rw-r--r-- | test/external.c | 121 | ||||
-rw-r--r-- | test/vfd.c | 85 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack.c | 18 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_main.c | 8 | ||||
-rw-r--r-- | tools/test/h5repack/testfiles/h5repack-help.txt | 8 |
5 files changed, 110 insertions, 130 deletions
diff --git a/test/external.c b/test/external.c index 619ca62..09e1e20 100644 --- a/test/external.c +++ b/test/external.c @@ -38,17 +38,15 @@ files_have_same_contents(const char *name1, const char *name2) { int fd1 = 0; int fd2 = 0; - ssize_t n1; - ssize_t n2; + ssize_t n1 = 0; + ssize_t n2 = 0; char buf1[1024]; char buf2[1024]; hbool_t ret = FALSE; /* not equal until proven otherwise */ - fd1 = HDopen(name1, O_RDONLY); - if(fd1 < 0) + if ((fd1 = HDopen(name1, O_RDONLY)) < 0) goto out; - fd2 = HDopen(name2, O_RDONLY); - if(fd2 < 0) + if ((fd2 = HDopen(name2, O_RDONLY)) < 0) goto out; /* Loop until files are empty or we encounter a problem */ @@ -101,29 +99,26 @@ out: static int test_non_extendible(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1] = {100}; /* data space current size */ - hsize_t max_size[1] = {100}; /* data space maximum size */ - int n; /* number of external files */ - off_t file_offset; /* external file offset */ - hsize_t file_size; /* sizeof external file segment */ - haddr_t dset_addr; /* address of dataset */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* data space current size */ + hsize_t max_size[1] = {100}; /* data space maximum size */ + int n = 0; /* number of external files */ + off_t file_offset = 0; /* external file offset */ + hsize_t file_size = 0; /* sizeof external file segment */ + haddr_t dset_addr = HADDR_UNDEF; /* address of dataset */ TESTING("fixed-size data space, exact storage"); /* Create the dataset and close */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0) FAIL_STACK_ERROR - space = H5Screate_simple(1, cur_size, max_size); - if(space < 0) + if((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(dset < 0) + if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR @@ -133,8 +128,7 @@ test_non_extendible(hid_t file) FAIL_STACK_ERROR /* Read dataset creation information */ - dset = H5Dopen2(file, "dset1", H5P_DEFAULT); - if(dset < 0) + if((dset = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Test dataset address. Should be undefined. */ @@ -145,11 +139,9 @@ test_non_extendible(hid_t file) FAIL_STACK_ERROR /* Check external count */ - dcpl = H5Dget_create_plist(dset); - if(dcpl < 0) + if((dcpl = H5Dget_create_plist(dset)) < 0) FAIL_STACK_ERROR - n = H5Pget_external_count(dcpl); - if(n < 0) + if((n = H5Pget_external_count(dcpl)) < 0) FAIL_STACK_ERROR if(1 != n) { H5_FAILED(); @@ -215,13 +207,11 @@ test_too_small(hid_t file) TESTING("external storage is too small"); - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */ FAIL_STACK_ERROR - space = H5Screate_simple(1, cur_size, max_size); - if(space < 0) + if((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR H5E_BEGIN_TRY { @@ -273,16 +263,13 @@ test_large_enough_current_eventual(hid_t file) TESTING("extendible dataspace, exact external size"); - dcpl = H5Pcreate (H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0) FAIL_STACK_ERROR - space = H5Screate_simple(1, cur_size, max_size); - if(space < 0) + if((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - dset = H5Dcreate2(file, "dset3", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(dset < 0) + if((dset = H5Dcreate2(file, "dset3", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR @@ -327,13 +314,11 @@ test_large_enough_current_not_eventual(hid_t file) TESTING("extendible dataspace, external storage is too small"); - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */ FAIL_STACK_ERROR - space = H5Screate_simple(1, cur_size, max_size); - if(space < 0) + if((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR H5E_BEGIN_TRY { @@ -387,16 +372,13 @@ test_unlimited(hid_t file) TESTING("unlimited dataspace, unlimited external storage"); /* Create dataset */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) FAIL_STACK_ERROR - space = H5Screate_simple(1, cur_size, max_size); - if(space < 0) + if((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - dset = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(dset < 0) + if((dset = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR @@ -404,14 +386,11 @@ test_unlimited(hid_t file) if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR /* Read dataset creation information */ - dset = H5Dopen2(file, "dset5", H5P_DEFAULT); - if(dset < 0) + if((dset = H5Dopen2(file, "dset5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - dcpl = H5Dget_create_plist(dset); - if(dcpl < 0) + if((dcpl = H5Dget_create_plist(dset)) < 0) FAIL_STACK_ERROR - n = H5Pget_external_count(dcpl); - if(n < 0) + if((n = H5Pget_external_count(dcpl)) < 0) FAIL_STACK_ERROR if(1 != n) { H5_FAILED(); @@ -493,12 +472,10 @@ test_multiple_files(hid_t file) } } - space = H5Screate_simple(1, cur_size, max_size); - if(space < 0) + if((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - dset = H5Dcreate2(file, "dset6", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(dset < 0) + if((dset = H5Dcreate2(file, "dset6", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR @@ -508,8 +485,7 @@ test_multiple_files(hid_t file) /* ---------------------------------------------- * Verify that too-small external files will fail */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR max_ext_size -= 1; @@ -522,7 +498,7 @@ test_multiple_files(hid_t file) fflush(stderr); FAIL_STACK_ERROR } - } + } /* end for each external file */ H5E_BEGIN_TRY { dset = H5Dcreate2(file, "dset7", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); @@ -564,13 +540,12 @@ static int test_add_to_unlimited(void) { hid_t dcpl = -1; /* dataset creation properties */ - herr_t status; /* function return status */ - int n; /* number of external files */ + herr_t status = FAIL; /* function return status */ + int n = 0; /* number of external files */ TESTING("external file following unlimited file"); - dcpl = H5Pcreate (H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) FAIL_STACK_ERROR @@ -581,8 +556,7 @@ test_add_to_unlimited(void) if(status >= 0) FAIL_PUTS_ERROR(" H5Pset_external() succeeded when it should have failed."); - n = H5Pget_external_count(dcpl); - if(n < 0) + if((n = H5Pget_external_count(dcpl)) < 0) FAIL_STACK_ERROR if(1 != n) FAIL_PUTS_ERROR(" Wrong external file count returned."); @@ -617,12 +591,11 @@ static int test_overflow(void) { hid_t dcpl = -1; /* dataset creation properties */ - herr_t status; /* return status */ + herr_t status = FAIL; /* return status */ TESTING("address overflow in external files"); - dcpl = H5Pcreate (H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED-1) < 0) FAIL_STACK_ERROR @@ -667,7 +640,7 @@ test_read_file_set(hid_t fapl) hid_t space = -1; /* data space */ hid_t dset = -1; /* dataset */ hid_t grp = -1; /* group to emit diagnostics */ - size_t i; /* miscellaneous counter */ + size_t i = 0; /* miscellaneous counter */ char filename[1024]; /* file names */ int part[PART_SIZE]; /* raw data buffer (partial) */ int whole[TOTAL_SIZE]; /* raw data buffer (total) */ @@ -785,7 +758,7 @@ test_write_file_set(hid_t fapl) hid_t mem_space = -1; /* memory data space */ hid_t file_space = -1; /* file data space */ hid_t dset = -1; /* dataset */ - unsigned i; /* miscellaneous counter */ + unsigned i = 0; /* miscellaneous counter */ int part[PART_SIZE]; /* raw data buffer (partial) */ int whole[TOTAL_SIZE]; /* raw data buffer (total) */ hsize_t cur_size = 100; /* current data space size */ @@ -909,7 +882,7 @@ test_path_absolute(hid_t fapl) hid_t dcpl = -1; /* dataset creation properties */ hid_t space = -1; /* data space */ hid_t dset = -1; /* dataset */ - size_t i; /* miscellaneous counter */ + size_t i = 0; /* miscellaneous counter */ char cwdpath[1024]; /* working directory */ char filename[1024]; /* file name */ int part[PART_SIZE]; /* raw data buffer (partial) */ @@ -999,7 +972,7 @@ test_path_relative(hid_t fapl) hid_t dcpl = -1; /* dataset creation properties */ hid_t space = -1; /* data space */ hid_t dset = -1; /* dataset */ - size_t i; /* miscellaneous counters */ + size_t i = 0; /* miscellaneous counters */ char cwdpath[1024]; /* working directory */ char filename[1024]; /* file name */ int part[PART_SIZE]; /* raw data buffer (partial) */ @@ -1093,7 +1066,7 @@ test_path_relative_cwd(hid_t fapl) hid_t dset = -1; /* dataset */ hid_t dset2 = -1; /* dataset, opened a second time */ hid_t dset3 = -1; /* dataset, opened with different prefix */ - size_t i; /* miscellaneous counters */ + size_t i = 0; /* miscellaneous counters */ char cwdpath[1024]; /* working directory */ char filename[1024]; /* file name */ int part[PART_SIZE]; /* raw data buffer (partial) */ @@ -1113,54 +1113,60 @@ error: /*------------------------------------------------------------------------- - * Function: test_family_member_fapl + * Function: test_family_member_fapl * - * Purpose: Actually use the member fapl input to the member vfd. + * Purpose: Actually use the member fapl input to the member vfd. * - * Return: 0 - success - * -1 - failure + * Return: Success: 0 + * Failure: -1 * - * Programmer: Jacob Smith - * 21 May 2019 + * Programmer: Jacob Smith + * 21 May 2019 * *------------------------------------------------------------------------- */ static herr_t test_family_member_fapl(void) { - hid_t file; - hid_t fapl_id; - hid_t memb_fapl_id; - hid_t space; - hid_t dset; + hid_t file = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t memb_fapl_id = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; char filename[1024]; - char dname[] = "dataset"; - unsigned i; - unsigned j; + char dname[] = "dataset"; + unsigned i = 0; + unsigned j = 0; int buf[FAMILY_NUMBER][FAMILY_SIZE]; - hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE}; + hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE}; TESTING("Family member FAPL"); fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (H5I_INVALID_HID == fapl_id) + if (H5I_INVALID_HID == fapl_id) { TEST_ERROR; + } memb_fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (H5I_INVALID_HID == memb_fapl_id) + if (H5I_INVALID_HID == memb_fapl_id) { TEST_ERROR; - if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL) + } + if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL) { TEST_ERROR; - if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_SIZE, memb_fapl_id) == FAIL) + } + if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_SIZE, memb_fapl_id) == FAIL) { TEST_ERROR; + } h5_fixname(FILENAME[2], fapl_id, filename, sizeof(filename)); file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if (H5I_INVALID_HID == file) + if (H5I_INVALID_HID == file) { TEST_ERROR; + } space = H5Screate_simple(2, dims, NULL); - if (H5I_INVALID_HID == space) + if (H5I_INVALID_HID == space) { TEST_ERROR; + } /* Create and write to dataset, then close file. */ @@ -1172,11 +1178,14 @@ test_family_member_fapl(void) H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (H5I_INVALID_HID == dset) + if (H5I_INVALID_HID == dset) { TEST_ERROR; - for (i = 0; i < FAMILY_NUMBER; i++) - for (j = 0; j < FAMILY_SIZE; j++) + } + for (i = 0; i < FAMILY_NUMBER; i++) { + for (j = 0; j < FAMILY_SIZE; j++) { buf[i][j] = (int)((i * 10000) + j); + } + } if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, @@ -1184,34 +1193,46 @@ test_family_member_fapl(void) H5P_DEFAULT, buf) == FAIL) + { TEST_ERROR; - if (H5Dclose(dset) == FAIL) TEST_ERROR; - if (H5Sclose(space) == FAIL) TEST_ERROR; - if (H5Fclose(file) == FAIL) TEST_ERROR; + } + if (H5Dclose(dset) == FAIL) { + TEST_ERROR; + } + if (H5Sclose(space) == FAIL) { + TEST_ERROR; + } + if (H5Fclose(file) == FAIL) { + TEST_ERROR; + } /* "Close" member FAPL at top level and re-open file. * Should succeed, with library managing reference count properly */ - if (H5Pclose(memb_fapl_id) == FAIL) + if (H5Pclose(memb_fapl_id) == FAIL) { TEST_ERROR; + } file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) + if (H5I_INVALID_HID == file) { TEST_ERROR; + } - if (H5Fclose(file) == FAIL) + if (H5Fclose(file) == FAIL) { TEST_ERROR; + } h5_delete_test_file(FILENAME[2], fapl_id); - if (H5Pclose(fapl_id) == FAIL) + if (H5Pclose(fapl_id) == FAIL) { TEST_ERROR; + } PASSED(); return 0; error: - H5E_BEGIN_TRY{ + H5E_BEGIN_TRY { H5Sclose(space); H5Dclose(dset); H5Pclose(memb_fapl_id); diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index 7dc38e6..c9cc020 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -382,15 +382,7 @@ copy_attr( */ for (u = 0; u < (unsigned) oinfo.num_attrs; u++) { /* open attribute */ - attr_id = H5Aopen_by_idx( - loc_in, - ".", - H5_INDEX_CRT_ORDER, - H5_ITER_INC, - (hsize_t) u, - H5P_DEFAULT, - H5P_DEFAULT); - if (attr_id < 0) + if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t) u, H5P_DEFAULT, H5P_DEFAULT)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx failed"); if (H5Aget_name(attr_id, (size_t) 255, name) < 0) @@ -410,13 +402,7 @@ copy_attr( HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iget_file_id failed"); /* Copy named dt */ - wtype_id = copy_named_datatype( - ftype_id, - fidout, - named_dt_head_p, - travt, - options); - if (wtype_id < 0) { + if ((wtype_id = copy_named_datatype(ftype_id, fidout, named_dt_head_p, travt, options)) < 0) { H5Fclose(fidout); HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_named_datatype failed"); diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 19eabd0..b4e5470 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -90,11 +90,11 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " This option will take precedence over the options\n"); PRINTVALSTREAM(rawoutstream, " --low and --high\n"); PRINTVALSTREAM(rawoutstream, " --low=BOUND The low bound for library release versions to use\n"); - PRINTVALSTREAM(rawoutstream, " when creating objects in the file (default is 0\n"); - PRINTVALSTREAM(rawoutstream, " [H5F_LIBVER_EARLIEST])\n"); + PRINTVALSTREAM(rawoutstream, " when creating objects in the file\n"); + PRINTVALSTREAM(rawoutstream, " (default is H5F_LIBVER_EARLIEST)\n"); PRINTVALSTREAM(rawoutstream, " --high=BOUND The high bound for library release versions to use\n"); - PRINTVALSTREAM(rawoutstream, " when creating objects in the file (default is 2\n"); - PRINTVALSTREAM(rawoutstream, " [H5F_LIBVER_V110 this release; H5F_LIBVER_LATEST])\n"); + PRINTVALSTREAM(rawoutstream, " when creating objects in the file\n"); + PRINTVALSTREAM(rawoutstream, " (default is H5F_LIBVER_LATEST)\n"); PRINTVALSTREAM(rawoutstream, " -c L1, --compact=L1 Maximum number of links in header messages\n"); PRINTVALSTREAM(rawoutstream, " -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); PRINTVALSTREAM(rawoutstream, " -s S[:F], --ssize=S[:F] Shared object header message minimum size\n"); diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt index ad07784..03553dd 100644 --- a/tools/test/h5repack/testfiles/h5repack-help.txt +++ b/tools/test/h5repack/testfiles/h5repack-help.txt @@ -12,11 +12,11 @@ usage: h5repack [OPTIONS] file1 file2 This option will take precedence over the options --low and --high --low=BOUND The low bound for library release versions to use - when creating objects in the file (default is 0 - [H5F_LIBVER_EARLIEST]) + when creating objects in the file + (default is H5F_LIBVER_EARLIEST) --high=BOUND The high bound for library release versions to use - when creating objects in the file (default is 2 - [H5F_LIBVER_V110 this release; H5F_LIBVER_LATEST]) + when creating objects in the file + (default is H5F_LIBVER_LATEST) -c L1, --compact=L1 Maximum number of links in header messages -d L2, --indexed=L2 Minimum number of links in the indexed format -s S[:F], --ssize=S[:F] Shared object header message minimum size |