diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2024-03-09 17:06:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-09 17:06:10 (GMT) |
commit | 0ea1d7280ba93039cad14faf7b0ed65da20ce563 (patch) | |
tree | 5cd59487a3270224e0aec98606a13cf22706cc26 /test | |
parent | d4c84f8d0a60e6eedd7288116d203dccf24a0b3a (diff) | |
download | hdf5-0ea1d7280ba93039cad14faf7b0ed65da20ce563.zip hdf5-0ea1d7280ba93039cad14faf7b0ed65da20ce563.tar.gz hdf5-0ea1d7280ba93039cad14faf7b0ed65da20ce563.tar.bz2 |
Clean up off_t usage (#4095)
* Add comments to C++ and Fortran API calls that use off_t
* Remove noise casts for small integers
Diffstat (limited to 'test')
-rw-r--r-- | test/big.c | 2 | ||||
-rw-r--r-- | test/enc_dec_plist.c | 8 | ||||
-rw-r--r-- | test/enc_dec_plist_cross_platform.c | 8 | ||||
-rw-r--r-- | test/external.c | 22 | ||||
-rw-r--r-- | test/file_image.c | 2 | ||||
-rw-r--r-- | test/fillval.c | 2 | ||||
-rw-r--r-- | test/gen_bad_offset.c | 12 | ||||
-rw-r--r-- | test/gen_plist.c | 8 | ||||
-rw-r--r-- | test/istore.c | 2 | ||||
-rw-r--r-- | test/objcopy.c | 2 | ||||
-rw-r--r-- | test/set_extent.c | 4 | ||||
-rw-r--r-- | test/th5s.c | 2 | ||||
-rw-r--r-- | test/twriteorder.c | 4 |
13 files changed, 38 insertions, 40 deletions
@@ -143,7 +143,7 @@ is_sparse(void) if ((fd = HDopen("x.h5", O_RDWR | O_TRUNC | O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) return 0; - if (HDlseek(fd, (HDoff_t)(1024 * 1024), SEEK_SET) != 1024 * 1024) + if (HDlseek(fd, (1024 * 1024), SEEK_SET) != 1024 * 1024) return 0; if (5 != HDwrite(fd, "hello", (size_t)5)) return 0; diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c index e643b1b..878fe86 100644 --- a/test/enc_dec_plist.c +++ b/test/enc_dec_plist.c @@ -220,13 +220,13 @@ main(void) FAIL_STACK_ERROR; max_size[0] = 100; - if ((H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) + if ((H5Pset_external(dcpl, "ext1.data", 0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) FAIL_STACK_ERROR; - if ((H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) + if ((H5Pset_external(dcpl, "ext2.data", 0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) FAIL_STACK_ERROR; - if ((H5Pset_external(dcpl, "ext3.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) + if ((H5Pset_external(dcpl, "ext3.data", 0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) FAIL_STACK_ERROR; - if ((H5Pset_external(dcpl, "ext4.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) + if ((H5Pset_external(dcpl, "ext4.data", 0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) FAIL_STACK_ERROR; /* Test encoding & decoding property list */ diff --git a/test/enc_dec_plist_cross_platform.c b/test/enc_dec_plist_cross_platform.c index a368214..d2d6810 100644 --- a/test/enc_dec_plist_cross_platform.c +++ b/test/enc_dec_plist_cross_platform.c @@ -178,8 +178,8 @@ test_plists(const char *filename_prefix) testfile = H5_get_srcdir_filename(filename); if ((fd_1 = HDopen(testfile, O_RDONLY)) < 0) TEST_ERROR; - size_1 = (size_t)HDlseek(fd_1, (HDoff_t)0, SEEK_END); - HDlseek(fd_1, (HDoff_t)0, SEEK_SET); + size_1 = (size_t)HDlseek(fd_1, 0, SEEK_END); + HDlseek(fd_1, 0, SEEK_SET); buf_1 = (void *)malloc(size_1); if (HDread(fd_1, buf_1, size_1) < 0) TEST_ERROR; @@ -194,8 +194,8 @@ test_plists(const char *filename_prefix) testfile = H5_get_srcdir_filename(filename); if ((fd_2 = HDopen(testfile, O_RDONLY)) < 0) TEST_ERROR; - size_2 = (size_t)HDlseek(fd_2, (HDoff_t)0, SEEK_END); - HDlseek(fd_2, (HDoff_t)0, SEEK_SET); + size_2 = (size_t)HDlseek(fd_2, 0, SEEK_END); + HDlseek(fd_2, 0, SEEK_SET); buf_2 = (void *)malloc(size_2); if (HDread(fd_2, buf_2, size_2) < 0) TEST_ERROR; diff --git a/test/external.c b/test/external.c index bf3c5bd..efd24fa 100644 --- a/test/external.c +++ b/test/external.c @@ -106,7 +106,7 @@ test_non_extendible(hid_t file) /* Create the dataset and close */ 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) + if (H5Pset_external(dcpl, "ext1.data", 0, (hsize_t)(max_size[0] * sizeof(int))) < 0) FAIL_STACK_ERROR; if ((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR; @@ -203,8 +203,7 @@ test_too_small(hid_t file) 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 */ + if (H5Pset_external(dcpl, "ext1.data", 0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */ FAIL_STACK_ERROR; if ((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR; @@ -260,7 +259,7 @@ test_large_enough_current_eventual(hid_t file) 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) + if (H5Pset_external(dcpl, "ext1.data", 0, (hsize_t)(max_size[0] * sizeof(int))) < 0) FAIL_STACK_ERROR; if ((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR; @@ -312,8 +311,7 @@ test_large_enough_current_not_eventual(hid_t file) 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 */ + if (H5Pset_external(dcpl, "ext1.data", 0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */ FAIL_STACK_ERROR; if ((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR; @@ -373,7 +371,7 @@ test_unlimited(hid_t file) /* Create dataset */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) + if (H5Pset_external(dcpl, "ext1.data", 0, H5F_UNLIMITED) < 0) FAIL_STACK_ERROR; if ((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR; @@ -576,12 +574,12 @@ test_add_to_unlimited(void) if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) + if (H5Pset_external(dcpl, "ext1.data", 0, H5F_UNLIMITED) < 0) FAIL_STACK_ERROR; H5E_BEGIN_TRY { - status = H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)100); + status = H5Pset_external(dcpl, "ext2.data", 0, 100); } H5E_END_TRY if (status >= 0) @@ -627,12 +625,12 @@ test_overflow(void) if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED - 1) < 0) + if (H5Pset_external(dcpl, "ext1.data", 0, H5F_UNLIMITED - 1) < 0) FAIL_STACK_ERROR; H5E_BEGIN_TRY { - status = H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)100); + status = H5Pset_external(dcpl, "ext2.data", 0, 100); } H5E_END_TRY if (status >= 0) @@ -1286,7 +1284,7 @@ test_h5d_get_access_plist(hid_t fapl_id) /* Create the dcpl and set external storage */ if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if (H5Pset_external(dcpl_id, "extern_1r.raw", (off_t)0, (hsize_t)0) < 0) + if (H5Pset_external(dcpl_id, "extern_1r.raw", 0, 0) < 0) FAIL_STACK_ERROR; /* Create the dapl and set the prefix */ diff --git a/test/file_image.c b/test/file_image.c index 81b49d6..66881c4 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -871,7 +871,7 @@ test_get_file_image(const char *test_banner, const int file_name_num, hid_t fapl HDoff_t off; /* Position at userblock */ - off = HDlseek(fd, (HDoff_t)USERBLOCK_SIZE, SEEK_SET); + off = HDlseek(fd, USERBLOCK_SIZE, SEEK_SET); VERIFY(off >= 0, "HDlseek() failed."); } diff --git a/test/fillval.c b/test/fillval.c index 2e8cb47..c8f4638 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -2098,7 +2098,7 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) if ((fd = HDopen(FILE_NAME_RAW, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0 || HDclose(fd) < 0) goto error; - if (H5Pset_external(dcpl, FILE_NAME_RAW, (off_t)0, (hsize_t)nelmts * sizeof(int)) < 0) + if (H5Pset_external(dcpl, FILE_NAME_RAW, 0, (hsize_t)nelmts * sizeof(int)) < 0) goto error; } #endif diff --git a/test/gen_bad_offset.c b/test/gen_bad_offset.c index 4f7b959..9c52195 100644 --- a/test/gen_bad_offset.c +++ b/test/gen_bad_offset.c @@ -31,11 +31,11 @@ * (A) Open the file: * fd = HDopen(TESTFILE, O_RDWR, 0663); * (B) Position the file at: - * (1) HDlseek(fd, (HDoff_t)880, SEEK_SET); + * (1) HDlseek(fd, 880, SEEK_SET); * "/group1/group2": replace heap offset "8" by bad offset - * (2) HDlseek(fd, (HDoff_t)1512, SEEK_SET); + * (2) HDlseek(fd, 1512, SEEK_SET); * "/dsetA": replace name offset into private heap "72" by bad offset - * (3) HDlseek(fd, (HDoff_t)1616, SEEK_SET); + * (3) HDlseek(fd, 1616, SEEK_SET); * /soft_one: replace link value offset in the scratch pad "32" by bad offset * (C) Write the bad offset value to the file for (1), (2) and (3): * write(fd, &val, sizeof(val)); @@ -104,21 +104,21 @@ main(void) FAIL_STACK_ERROR; /* Position the file for /group1/group2: replace heap offset "8" by bad offset */ - if (HDlseek(fd, (HDoff_t)880, SEEK_SET) < 0) + if (HDlseek(fd, 880, SEEK_SET) < 0) FAIL_STACK_ERROR; /* Write the bad offset value to the file */ if (HDwrite(fd, &val, sizeof(val)) < 0) FAIL_STACK_ERROR; /* Position the file for /dsetA: replace name offset into private heap "72" by bad offset */ - if (HDlseek(fd, (HDoff_t)1512, SEEK_SET) < 0) + if (HDlseek(fd, 1512, SEEK_SET) < 0) FAIL_STACK_ERROR; /* Write the bad offset value to the file */ if (HDwrite(fd, &val, sizeof(val)) < 0) FAIL_STACK_ERROR; /* Position the file for /soft_one: replace link value offset in the scratch pad "32" by bad offset */ - if (HDlseek(fd, (HDoff_t)1616, SEEK_SET) < 0) + if (HDlseek(fd, 1616, SEEK_SET) < 0) FAIL_STACK_ERROR; /* Write the bad offset value to the file */ if (HDwrite(fd, &val, sizeof(val)) < 0) diff --git a/test/gen_plist.c b/test/gen_plist.c index 6d40ae7..1400b40 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -123,13 +123,13 @@ main(void) assert(ret > 0); max_size[0] = 100; - if ((ret = H5Pset_external(dcpl1, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) + if ((ret = H5Pset_external(dcpl1, "ext1.data", 0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) assert(ret > 0); - if ((ret = H5Pset_external(dcpl1, "ext2.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) + if ((ret = H5Pset_external(dcpl1, "ext2.data", 0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) assert(ret > 0); - if ((ret = H5Pset_external(dcpl1, "ext3.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) + if ((ret = H5Pset_external(dcpl1, "ext3.data", 0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) assert(ret > 0); - if ((ret = H5Pset_external(dcpl1, "ext4.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) + if ((ret = H5Pset_external(dcpl1, "ext4.data", 0, (hsize_t)(max_size[0] * sizeof(int) / 4))) < 0) assert(ret > 0); if ((ret = encode_plist(dcpl1, little_endian, word_length, "plist_files/dcpl_")) < 0) diff --git a/test/istore.c b/test/istore.c index 33032d1..8da9961 100644 --- a/test/istore.c +++ b/test/istore.c @@ -62,7 +62,7 @@ is_sparse(void) if ((fd = HDopen("x.h5", O_RDWR | O_TRUNC | O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) return 0; - if (HDlseek(fd, (HDoff_t)(1024 * 1024), SEEK_SET) != 1024 * 1024) + if (HDlseek(fd, (1024 * 1024), SEEK_SET) != 1024 * 1024) return 0; if (5 != HDwrite(fd, "hello", (size_t)5)) return 0; diff --git a/test/objcopy.c b/test/objcopy.c index d604c54..08e7b07 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -5200,7 +5200,7 @@ test_copy_dataset_external(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t size = DIM_SIZE_1 * sizeof(int); if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; - if (H5Pset_external(pid, FILE_EXT, (off_t)0, size) < 0) + if (H5Pset_external(pid, FILE_EXT, 0, size) < 0) TEST_ERROR; /* create dataset at SRC file */ diff --git a/test/set_extent.c b/test/set_extent.c index d418f2e..6e2b7c5 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -1831,10 +1831,10 @@ test_external(hid_t fapl, bool use_select_io) if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR; - if (H5Pset_external(dcpl, EXT_FILE_NAME1, (off_t)0, size) < 0) + if (H5Pset_external(dcpl, EXT_FILE_NAME1, 0, size) < 0) FAIL_STACK_ERROR; - if (H5Pset_external(dcpl, EXT_FILE_NAME2, (off_t)0, size) < 0) + if (H5Pset_external(dcpl, EXT_FILE_NAME2, 0, size) < 0) FAIL_STACK_ERROR; { diff --git a/test/th5s.c b/test/th5s.c index f0e4959..4c46c40 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -933,7 +933,7 @@ test_h5s_zero_dim(void) * space in the external file is the size of the dataset (zero because one dimension size is zero). * There's no need to clean up the external file since the library doesn't create it * until the data is written to it. */ - ret = H5Pset_external(plist_id, EXTFILE_NAME, (off_t)0, (hsize_t)0); + ret = H5Pset_external(plist_id, EXTFILE_NAME, 0, (hsize_t)0); CHECK(ret, FAIL, "H5Pset_external"); ret = H5Pset_alloc_time(plist_id, alloc_time); diff --git a/test/twriteorder.c b/test/twriteorder.c index 9bfe87b..41841b5 100644 --- a/test/twriteorder.c +++ b/test/twriteorder.c @@ -283,7 +283,7 @@ write_wo_file(void) } /* end for */ /* write the last blkaddr in partition 0 */ - HDlseek(write_fd_g, (HDoff_t)0, SEEK_SET); + HDlseek(write_fd_g, 0, SEEK_SET); if ((bytes_wrote = HDwrite(write_fd_g, &blkaddr_old, (size_t)sizeof(blkaddr_old))) != sizeof(blkaddr_old)) { printf("blkaddr write failed in partition %d\n", 0); @@ -310,7 +310,7 @@ read_wo_file(void) /* keep reading the initial block address until it is non-zero before proceeding. */ while (blkaddr == 0) { - HDlseek(read_fd, (HDoff_t)0, SEEK_SET); + HDlseek(read_fd, 0, SEEK_SET); if ((bytes_read = HDread(read_fd, &blkaddr, (size_t)sizeof(blkaddr))) != sizeof(blkaddr)) { printf("blkaddr read failed in partition %d\n", 0); return -1; |