diff options
author | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2023-09-08 23:06:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-08 23:06:23 (GMT) |
commit | 117d579c326f64d09d71e28cb0135bbd16a5232e (patch) | |
tree | 384ac7e1e3b9881e6d6ab783ee0391ab7adc1f29 /test/swmr.c | |
parent | 2345f901b26277f643dd91a528e4da975f4e75c1 (diff) | |
download | hdf5-117d579c326f64d09d71e28cb0135bbd16a5232e.zip hdf5-117d579c326f64d09d71e28cb0135bbd16a5232e.tar.gz hdf5-117d579c326f64d09d71e28cb0135bbd16a5232e.tar.bz2 |
Consistent initialization of hid_t in the tests (#3521)
Diffstat (limited to 'test/swmr.c')
-rw-r--r-- | test/swmr.c | 243 |
1 files changed, 122 insertions, 121 deletions
diff --git a/test/swmr.c b/test/swmr.c index 1caf548..6b9e097 100644 --- a/test/swmr.c +++ b/test/swmr.c @@ -115,10 +115,10 @@ static int test_multiple_same(hid_t in_fapl, bool new_format); static int test_metadata_read_attempts(hid_t in_fapl) { - hid_t fapl = -1; /* File access property list */ - hid_t file_fapl = -1; /* The file's access property list */ - hid_t fid = -1, fid1 = -1, fid2 = -1; /* File IDs */ - hid_t driver_id = -1; /* ID for this VFD */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t file_fapl = H5I_INVALID_HID; /* The file's access property list */ + hid_t fid = H5I_INVALID_HID, fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; /* File IDs */ + hid_t driver_id = H5I_INVALID_HID; /* ID for this VFD */ unsigned long driver_flags = 0; /* VFD feature flags */ bool compat_w_default_vfd; /* current VFD compat w/ H5P_DEFAULT? */ unsigned attempts; /* The # of read attempts */ @@ -1572,26 +1572,26 @@ error: static int test_start_swmr_write(hid_t in_fapl, bool new_format) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property */ - hid_t gid = -1; /* Group ID */ - hid_t dcpl = -1; /* Dataset creation property */ - hid_t file_fapl = -1; /* File access property for the file */ - hid_t did1 = -1, did2 = -1, did3 = -1; /* Dataset IDs */ - hid_t did1_a = -1, did1_b = -1; - hid_t sid1 = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */ - hsize_t dim[1] = {1}; /* Dimension sizes */ - hsize_t max_dim[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dim[1] = {2}; /* Chunk dimension sizes */ - hsize_t dim2[2] = {5, 10}; /* Dimension sizes */ - hsize_t max_dim2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dim2[2] = {2, 7}; /* Chunk dimension sizes */ - H5D_chunk_index_t idx_type; /* Dataset chunk index type */ - int wdata = 99; /* Data to write */ - int rdata; /* Data read */ - unsigned attempts; /* The retrieved # of read attempts */ - char filename[NAME_BUF_SIZE]; /* File name */ - herr_t ret; /* Return value */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property */ + hid_t file_fapl = H5I_INVALID_HID; /* File access property for the file */ + hid_t did1 = H5I_INVALID_HID, did2 = H5I_INVALID_HID, did3 = H5I_INVALID_HID; /* Dataset IDs */ + hid_t did1_a = H5I_INVALID_HID, did1_b = H5I_INVALID_HID; + hid_t sid1 = H5I_INVALID_HID, sid2 = H5I_INVALID_HID, sid3 = H5I_INVALID_HID; /* Dataspace IDs */ + hsize_t dim[1] = {1}; /* Dimension sizes */ + hsize_t max_dim[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dim[1] = {2}; /* Chunk dimension sizes */ + hsize_t dim2[2] = {5, 10}; /* Dimension sizes */ + hsize_t max_dim2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dim2[2] = {2, 7}; /* Chunk dimension sizes */ + H5D_chunk_index_t idx_type; /* Dataset chunk index type */ + int wdata = 99; /* Data to write */ + int rdata; /* Data read */ + unsigned attempts; /* The retrieved # of read attempts */ + char filename[NAME_BUF_SIZE]; /* File name */ + herr_t ret; /* Return value */ /* Get a copy of the parameter fapl (non-latest-format) */ if ((fapl = H5Pcopy(in_fapl)) < 0) @@ -1940,18 +1940,18 @@ error: static int test_err_start_swmr_write(hid_t in_fapl, bool new_format) { - hid_t fid = -1; /* File ID */ - hid_t fid2 = -1; /* File ID */ - hid_t fapl = -1; /* A copy of file access property */ - hid_t new_fapl = -1; /* A copy of file access property */ - hid_t gid = -1; /* Group ID */ - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t tid = -1; /* Datatype ID */ - hid_t bad_fid = -1; /* Test fid (should never represent a real ID) */ - herr_t ret; /* Return value */ - char filename[NAME_BUF_SIZE]; /* File name */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fid2 = H5I_INVALID_HID; /* File ID */ + hid_t fapl = H5I_INVALID_HID; /* A copy of file access property */ + hid_t new_fapl = H5I_INVALID_HID; /* A copy of file access property */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ + hid_t tid = H5I_INVALID_HID; /* Datatype ID */ + hid_t bad_fid = H5I_INVALID_HID; /* Test fid (should never represent a real ID) */ + herr_t ret; /* Return value */ + char filename[NAME_BUF_SIZE]; /* File name */ /* Create a copy of the input parameter in_fapl */ if ((fapl = H5Pcopy(in_fapl)) < 0) @@ -2420,18 +2420,18 @@ test_start_swmr_write_concur(hid_t H5_ATTR_UNUSED in_fapl, bool new_format) static int test_start_swmr_write_concur(hid_t in_fapl, bool new_format) { - hid_t fid = -1, fid1 = -1, fid2 = -1; /* File IDs */ - hid_t fapl; /* File access property list */ - pid_t childpid = 0; /* Child process ID */ - pid_t tmppid; /* Child process ID returned by waitpid */ - int child_status; /* Status passed to waitpid */ - int child_wait_option = 0; /* Options passed to waitpid */ - int child_exit_val; /* Exit status of the child */ - char filename[NAME_BUF_SIZE]; /* File name */ - - hid_t did = -1, did1 = -1, did2 = -1, did3 = -1; - hid_t sid = -1; - hid_t dcpl = -1; + hid_t fid = H5I_INVALID_HID, fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; /* File IDs */ + hid_t fapl; /* File access property list */ + pid_t childpid = 0; /* Child process ID */ + pid_t tmppid; /* Child process ID returned by waitpid */ + int child_status; /* Status passed to waitpid */ + int child_wait_option = 0; /* Options passed to waitpid */ + int child_exit_val; /* Exit status of the child */ + char filename[NAME_BUF_SIZE]; /* File name */ + + hid_t did = H5I_INVALID_HID, did1 = H5I_INVALID_HID, did2 = H5I_INVALID_HID, did3 = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; hsize_t chunk_dims[1] = {1}; hsize_t maxdims[1] = {H5S_UNLIMITED}; hsize_t dims[1] = {1}; @@ -2583,9 +2583,9 @@ test_start_swmr_write_concur(hid_t in_fapl, bool new_format) if ((childpid = fork()) < 0) FAIL_STACK_ERROR; - if (childpid == 0) { /* Child process */ - hid_t child_fid1 = -1, child_fid2; /* File IDs */ - hid_t child_did1 = -1, child_did2 = -1; /* Dataset IDs */ + if (childpid == 0) { /* Child process */ + hid_t child_fid1 = H5I_INVALID_HID, child_fid2; /* File IDs */ + hid_t child_did1 = H5I_INVALID_HID, child_did2 = H5I_INVALID_HID; /* Dataset IDs */ int child_notify = 0; int rdata = 0; @@ -3029,14 +3029,14 @@ error: static int test_start_swmr_write_stress_ohdr(hid_t in_fapl) { - hid_t fid = -1; /* File IDs */ - hid_t fapl; /* File access property list */ - char filename[NAME_BUF_SIZE]; /* File name */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t sid = -1; /* Dataspace ID */ - hid_t tid = -1; /* Datatype ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t aid = -1; /* Attribute ID */ + hid_t fid = H5I_INVALID_HID; /* File IDs */ + hid_t fapl; /* File access property list */ + char filename[NAME_BUF_SIZE]; /* File name */ + hid_t did = H5I_INVALID_HID, did2 = H5I_INVALID_HID; /* Dataset IDs */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t tid = H5I_INVALID_HID; /* Datatype ID */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list ID */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ hsize_t chunk_dims[2] = {10, 10}; hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; char fill[256]; /* Fill value for dataset */ @@ -3582,14 +3582,14 @@ flush_cb(hid_t H5_ATTR_UNUSED obj_id, void *_udata) static int test_object_flush_cb(hid_t in_fapl) { - hid_t fapl = -1; /* A copy of file access property list */ - hid_t ffapl = -1; /* A file's file access property list */ - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ - hid_t did1 = -1, did2 = -1; /* Dataset IDs */ - hid_t sid = -1; /* Dataspace ID */ - hsize_t dims[2] = {5, 10}; /* Dataset dimension sizes */ - int buf[50]; /* Data buffer */ + hid_t fapl = H5I_INVALID_HID; /* A copy of file access property list */ + hid_t ffapl = H5I_INVALID_HID; /* A file's file access property list */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hid_t did1 = H5I_INVALID_HID, did2 = H5I_INVALID_HID; /* Dataset IDs */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hsize_t dims[2] = {5, 10}; /* Dataset dimension sizes */ + int buf[50]; /* Data buffer */ H5F_flush_cb_t ret_cb; /* The callback function set in object flush property */ void *ret_ct; /* The user data set in object flush property */ unsigned flush_ct = 0; /* The user data for object flush property */ @@ -3860,13 +3860,13 @@ append_cb2(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void static int test_append_flush_generic(void) { - hid_t dapl = -1; /* A copy of dataset access property */ - hsize_t boundary[3]; /* The boundary for append flush property */ - unsigned count = 0; /* The user data for append flush property */ - hsize_t ret_boundary[3]; /* The boundary set in append flush property */ - H5D_append_cb_t ret_cb; /* The callback function set in append flush property */ - unsigned *ret_count; /* The user data set in append flush property */ - herr_t ret; /* The return value */ + hid_t dapl = H5I_INVALID_HID; /* A copy of dataset access property */ + hsize_t boundary[3]; /* The boundary for append flush property */ + unsigned count = 0; /* The user data for append flush property */ + hsize_t ret_boundary[3]; /* The boundary set in append flush property */ + H5D_append_cb_t ret_cb; /* The callback function set in append flush property */ + unsigned *ret_count; /* The user data set in append flush property */ + herr_t ret; /* The return value */ TESTING("H5Fget/set_append_flush() for a generic dataset access property list"); @@ -4035,13 +4035,13 @@ error: static int test_append_flush_dataset_chunked(hid_t in_fapl) { - hid_t fid = -1; /* file ID */ - hid_t fapl = -1; /* A copy of file access property */ - hid_t did1 = -1, did2 = -1; /* The dataset ID */ - hid_t sid = -1; /* The dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl = -1; /* A copy of dataset access property */ - hid_t ddapl = -1; /* The dataset access property of the opened dataset */ + hid_t fid = H5I_INVALID_HID; /* file ID */ + hid_t fapl = H5I_INVALID_HID; /* A copy of file access property */ + hid_t did1 = H5I_INVALID_HID, did2 = H5I_INVALID_HID; /* The dataset ID */ + hid_t sid = H5I_INVALID_HID; /* The dataspace ID */ + hid_t dcpl = H5I_INVALID_HID; /* A copy of dataset creation property */ + hid_t dapl = H5I_INVALID_HID; /* A copy of dataset access property */ + hid_t ddapl = H5I_INVALID_HID; /* The dataset access property of the opened dataset */ hsize_t boundary[3]; /* Boundary size */ unsigned count = 0; /* User data */ @@ -4258,12 +4258,12 @@ error: static int test_append_flush_dataset_fixed(hid_t in_fapl) { - hid_t fid = -1; /* file ID */ - hid_t fapl = -1; /* A copy of file access property */ - hid_t did1 = -1, did2 = -1; /* The dataset ID */ - hid_t sid = -1; /* The dataspace ID */ - hid_t dapl = -1; /* A copy of dataset access property */ - hid_t ddapl = -1; /* The dataset access property of the opened dataset */ + hid_t fid = H5I_INVALID_HID; /* file ID */ + hid_t fapl = H5I_INVALID_HID; /* A copy of file access property */ + hid_t did1 = H5I_INVALID_HID, did2 = H5I_INVALID_HID; /* The dataset ID */ + hid_t sid = H5I_INVALID_HID; /* The dataspace ID */ + hid_t dapl = H5I_INVALID_HID; /* A copy of dataset access property */ + hid_t ddapl = H5I_INVALID_HID; /* The dataset access property of the opened dataset */ hsize_t boundary[3]; /* Boundary size */ unsigned count = 0; /* User data */ @@ -4476,14 +4476,14 @@ error: static int test_append_flush_dataset_multiple(hid_t in_fapl) { - hid_t fid = -1; /* file ID */ - hid_t fapl = -1; /* A copy of file access property */ - hid_t did1 = -1, did2 = -1; /* The dataset ID */ - hid_t sid = -1; /* The dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl1 = -1; /* A copy of dataset access property */ - hid_t dapl2 = -1; /* A copy of dataset access property */ - hid_t ddapl = -1; /* The dataset access property of the opened dataset */ + hid_t fid = H5I_INVALID_HID; /* file ID */ + hid_t fapl = H5I_INVALID_HID; /* A copy of file access property */ + hid_t did1 = H5I_INVALID_HID, did2 = H5I_INVALID_HID; /* The dataset ID */ + hid_t sid = H5I_INVALID_HID; /* The dataspace ID */ + hid_t dcpl = H5I_INVALID_HID; /* A copy of dataset creation property */ + hid_t dapl1 = H5I_INVALID_HID; /* A copy of dataset access property */ + hid_t dapl2 = H5I_INVALID_HID; /* A copy of dataset access property */ + hid_t ddapl = H5I_INVALID_HID; /* The dataset access property of the opened dataset */ hsize_t boundary1[3]; /* Boundary size */ hsize_t boundary2[3]; /* Boundary size */ @@ -4705,10 +4705,10 @@ error: static int test_file_lock_same(hid_t in_fapl) { - hid_t fid = -1, fid2 = -1; /* File IDs */ - hid_t fapl = -1; /* File access property list */ - unsigned intent; /* File access flags */ - char filename[NAME_BUF_SIZE]; /* file name */ + hid_t fid = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; /* File IDs */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + unsigned intent; /* File access flags */ + char filename[NAME_BUF_SIZE]; /* file name */ /* Output message about test being performed */ TESTING("File open with different combinations of flags--single process access"); @@ -5198,8 +5198,8 @@ test_file_lock_concur(hid_t H5_ATTR_UNUSED in_fapl) static int test_file_lock_concur(hid_t in_fapl) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ char filename[NAME_BUF_SIZE]; /* file name */ pid_t childpid = 0; /* Child process ID */ int child_status; /* Status passed to waitpid */ @@ -6611,8 +6611,8 @@ test_file_locking(hid_t in_fapl, bool turn_locking_on, bool env_var_override) HDputs(" Test skipped due to fork or waitpid not defined."); return 0; #else /* !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID)) */ - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ char filename[NAME_BUF_SIZE]; /* file name */ pid_t childpid = 0; /* Child process ID */ int child_status; /* Status passed to waitpid */ @@ -6860,10 +6860,10 @@ error: static int test_swmr_vfd_flag(void) { - hid_t fid = -1; /* file ID */ - hid_t sec2_fapl = -1; /* fapl ID of a VFD that supports SWMR writes (sec2) */ - hid_t bad_fapl = -1; /* fapl ID of a VFD that does not support SWMR writes (stdio) */ - char filename[NAME_BUF_SIZE]; /* file name */ + hid_t fid = H5I_INVALID_HID; /* file ID */ + hid_t sec2_fapl = H5I_INVALID_HID; /* fapl ID of a VFD that supports SWMR writes (sec2) */ + hid_t bad_fapl = H5I_INVALID_HID; /* fapl ID of a VFD that does not support SWMR writes (stdio) */ + char filename[NAME_BUF_SIZE]; /* file name */ TESTING("SWMR-enabled VFD flag functionality"); @@ -7101,9 +7101,9 @@ test_refresh_concur(hid_t in_fapl, bool new_format) int child_exit_val; /* Exit status of the child */ char filename[NAME_BUF_SIZE]; /* File name */ - hid_t did = -1; - hid_t sid = -1; - hid_t dcpl = -1; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; hsize_t chunk_dims[1] = {1}; hsize_t maxdims[1] = {H5S_UNLIMITED}; hsize_t dims[1] = {1}; @@ -7175,11 +7175,11 @@ test_refresh_concur(hid_t in_fapl, bool new_format) if ((childpid = fork()) < 0) FAIL_STACK_ERROR; - if (childpid == 0) { /* Child process */ - hid_t child_fid1 = -1; /* File ID */ - hid_t child_fid2 = -1; /* File ID */ - hid_t child_did1 = -1, child_did2 = -1; - hid_t child_sid = -1; + if (childpid == 0) { /* Child process */ + hid_t child_fid1 = H5I_INVALID_HID; /* File ID */ + hid_t child_fid2 = H5I_INVALID_HID; /* File ID */ + hid_t child_did1 = H5I_INVALID_HID, child_did2 = H5I_INVALID_HID; + hid_t child_sid = H5I_INVALID_HID; hsize_t tdims[1]; int rbuf[2] = {0, 0}; int child_notify = 0; @@ -7405,12 +7405,13 @@ error: static int test_multiple_same(hid_t in_fapl, bool new_format) { - hid_t fid = -1, fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ - hid_t fapl; /* File access property list */ - char filename[NAME_BUF_SIZE]; /* File name */ - hid_t did = -1, did1 = -1, did2 = -1, did3 = -1; - hid_t sid = -1; - hid_t dcpl = -1; + hid_t fid = H5I_INVALID_HID, fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID, + fid3 = H5I_INVALID_HID; /* File IDs */ + hid_t fapl; /* File access property list */ + char filename[NAME_BUF_SIZE]; /* File name */ + hid_t did = H5I_INVALID_HID, did1 = H5I_INVALID_HID, did2 = H5I_INVALID_HID, did3 = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; hsize_t chunk_dims[2] = {1, 2}; hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; hsize_t dims[2] = {1, 1}; |