diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2022-07-05 23:55:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-05 23:55:18 (GMT) |
commit | 5ceaf920eccbf5176065b0deeb27b124b821db76 (patch) | |
tree | 2bca04a4fd6fd27065c3e33335092970ef30b940 /test/vfd_swmr_attrdset_writer.c | |
parent | ac7bddf2af317d4bc34854f5565396da51ff12aa (diff) | |
download | hdf5-5ceaf920eccbf5176065b0deeb27b124b821db76.zip hdf5-5ceaf920eccbf5176065b0deeb27b124b821db76.tar.gz hdf5-5ceaf920eccbf5176065b0deeb27b124b821db76.tar.bz2 |
VFD SWMR: Warning fixes and minor cleanup (#1847)feature/vfd_swmr
* Normalization with develop
* Moves remaining datatype code changes over from develop
* Cleanup in examples files
* Warning cleanup in VFD SWMR code
* Committing clang-format changes
* Warning cleanup
* Warning reduction
* More warning fixes
* Committing clang-format changes
* Even more warning reduction in the VFD SWMR tests
* More warning fixes in the VFD SWMR tests
* Even more VFD SWMR test warning fixes
* Last warning fixes in VFD SWMR
* Committing clang-format changes
* Minor things missed from develop
* Warning fixes from GitHub build failures
* Committing clang-format changes
* Fix for warning due to weird bit shift type promotion
* Yet another attempt at fixing the integral promotion warning
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test/vfd_swmr_attrdset_writer.c')
-rw-r--r-- | test/vfd_swmr_attrdset_writer.c | 99 |
1 files changed, 60 insertions, 39 deletions
diff --git a/test/vfd_swmr_attrdset_writer.c b/test/vfd_swmr_attrdset_writer.c index 85ceb01..2602abe 100644 --- a/test/vfd_swmr_attrdset_writer.c +++ b/test/vfd_swmr_attrdset_writer.c @@ -66,16 +66,6 @@ typedef struct { hbool_t use_vfd_swmr; /* For -S option */ } state_t; -/* Initializations for state_t */ -#define ALL_HID_INITIALIZER \ - (state_t) \ - { \ - .file = H5I_INVALID_HID, .one_by_one_sid = H5I_INVALID_HID, .filename = "", \ - .filetype = H5T_NATIVE_UINT32, .asteps = 0, .csteps = 1, .dattrs = 0, .use_np = TRUE, \ - .use_vfd_swmr = TRUE, .compact = FALSE, .contig = FALSE, .chunked = FALSE, .vl_attr = FALSE, \ - .mod_attr = FALSE, .update_interval = READER_WAIT_TICKS \ - } - /* Structure to hold info for different dataset types */ typedef struct { hid_t compact_did; /* ID for compact dataset */ @@ -226,7 +216,23 @@ state_init(state_t *s, int argc, const char *const *argv) const char * s_opts = "pgkvmbqSNa:d:u:c:"; struct h5_long_options l_opts[] = {{NULL, 0, '\0'}}; - *s = ALL_HID_INITIALIZER; + s->file = H5I_INVALID_HID; + s->one_by_one_sid = H5I_INVALID_HID; + s->filetype = H5T_NATIVE_UINT32; + s->asteps = 0; + s->csteps = 1; + s->dattrs = 0; + s->use_np = TRUE; + s->use_vfd_swmr = TRUE; + s->compact = FALSE; + s->contig = FALSE; + s->chunked = FALSE; + s->vl_attr = FALSE; + s->mod_attr = FALSE; + s->update_interval = READER_WAIT_TICKS; + + HDmemset(s->filename, 0, PATH_MAX); + HDmemset(s->progname, 0, PATH_MAX); if (H5_basename(argv[0], &tfile) < 0) { HDprintf("H5_basename failed\n"); @@ -1956,21 +1962,30 @@ error: int main(int argc, char **argv) { - hid_t fapl = H5I_INVALID_HID; - hid_t fcpl = H5I_INVALID_HID; - hbool_t writer = FALSE; - state_t s; - const char * personality; - H5F_vfd_swmr_config_t config; - np_state_t np; - dsets_state_t ds; - - if (!state_init(&s, argc, (const char *const *)argv)) { + hid_t fapl = H5I_INVALID_HID; + hid_t fcpl = H5I_INVALID_HID; + hbool_t writer = FALSE; + state_t * s = NULL; + const char * personality; + H5F_vfd_swmr_config_t *config = NULL; + np_state_t np; + dsets_state_t ds; + + if (NULL == (s = HDcalloc(1, sizeof(state_t)))) { + HDprintf("memory allocation failed"); + TEST_ERROR; + } + if (NULL == (config = HDcalloc(1, sizeof(H5F_vfd_swmr_config_t)))) { + HDprintf("memory allocation failed"); + TEST_ERROR; + } + + if (!state_init(s, argc, (const char *const *)argv)) { HDprintf("state_init() failed\n"); TEST_ERROR; } - personality = HDstrstr(s.progname, "vfd_swmr_attrdset_"); + personality = HDstrstr(s->progname, "vfd_swmr_attrdset_"); if (personality != NULL && HDstrcmp(personality, "vfd_swmr_attrdset_writer") == 0) writer = TRUE; @@ -1984,10 +1999,10 @@ main(int argc, char **argv) /* config, tick_len, max_lag, presume_posix_semantics, writer, * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, * md_file_path, md_file_name, updater_file_path */ - init_vfd_swmr_config(&config, 4, 7, FALSE, writer, TRUE, FALSE, TRUE, 128, "./", "attrdset-shadow", NULL); + init_vfd_swmr_config(config, 4, 7, FALSE, writer, TRUE, FALSE, TRUE, 128, "./", "attrdset-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ - if ((fapl = vfd_swmr_create_fapl(TRUE, s.use_vfd_swmr, TRUE, 4096, &config)) < 0) { + if ((fapl = vfd_swmr_create_fapl(TRUE, s->use_vfd_swmr, TRUE, 4096, config)) < 0) { HDprintf("vfd_swmr_create_fapl() failed\n"); TEST_ERROR; } @@ -1999,41 +2014,41 @@ main(int argc, char **argv) } if (writer) { - if ((s.file = H5Fcreate(s.filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) { + if ((s->file = H5Fcreate(s->filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) { HDprintf("H5Fcreate failed\n"); TEST_ERROR; } - if (!create_dsets(&s, &ds)) { + if (!create_dsets(s, &ds)) { HDprintf("create_dsets() failed\n"); TEST_ERROR; } } else { - if ((s.file = H5Fopen(s.filename, H5F_ACC_RDONLY, fapl)) < 0) { + if ((s->file = H5Fopen(s->filename, H5F_ACC_RDONLY, fapl)) < 0) { HDprintf("H5Fopen failed\n"); TEST_ERROR; } - if (!open_dsets(&s, &ds)) { + if (!open_dsets(s, &ds)) { HDprintf("open_dsets() failed\n"); TEST_ERROR; } } /* Initiailze named pipes */ - if (s.use_np && !np_init(&np, writer)) { + if (s->use_np && !np_init(&np, writer)) { HDprintf("np_init() failed\n"); TEST_ERROR; } if (writer) { - if (!perform_dsets_operations(&s, &ds, &config, &np)) { + if (!perform_dsets_operations(s, &ds, config, &np)) { HDprintf("perform_dsets_operations() failed\n"); TEST_ERROR; } } else { - if (!verify_dsets_operations(&s, &ds, &config, &np)) { + if (!verify_dsets_operations(s, &ds, config, &np)) { HDprintf("verify_dsets_operations() failed\n"); TEST_ERROR; } @@ -2054,21 +2069,24 @@ main(int argc, char **argv) TEST_ERROR; } - if (H5Fclose(s.file) < 0) { + if (H5Fclose(s->file) < 0) { HDprintf("H5Fclose failed\n"); TEST_ERROR; } - if (H5Sclose(s.one_by_one_sid) < 0) { + if (H5Sclose(s->one_by_one_sid) < 0) { HDprintf("H5Sclose failed\n"); TEST_ERROR; } - if (s.use_np && !np_close(&np, writer)) { + if (s->use_np && !np_close(&np, writer)) { HDprintf("np_close() failed\n"); TEST_ERROR; } + HDfree(s); + HDfree(config); + return EXIT_SUCCESS; error: @@ -2076,22 +2094,25 @@ error: { H5Pclose(fapl); H5Pclose(fcpl); - H5Fclose(s.file); - H5Sclose(s.one_by_one_sid); + H5Fclose(s->file); + H5Sclose(s->one_by_one_sid); } H5E_END_TRY; - if (s.use_np && np.fd_writer_to_reader >= 0) + if (s->use_np && np.fd_writer_to_reader >= 0) HDclose(np.fd_writer_to_reader); - if (s.use_np && np.fd_reader_to_writer >= 0) + if (s->use_np && np.fd_reader_to_writer >= 0) HDclose(np.fd_reader_to_writer); - if (s.use_np && !writer) { + if (s->use_np && !writer) { HDremove(np.fifo_writer_to_reader); HDremove(np.fifo_reader_to_writer); } + HDfree(s); + HDfree(config); + return EXIT_FAILURE; } /* main */ |