From 55844f79e94d49f7ccc8fff1fa3d80f153bb13ea Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 10 May 2020 09:48:30 -0700 Subject: Misc warning fixes. --- test/del_many_dense_attrs.c | 22 +++++++++++----------- test/fillval.c | 31 ++++++++++++++++++++++++++----- test/use.h | 2 +- test/use_common.c | 2 +- utils/mirror_vfd/mirror_server.c | 2 +- utils/mirror_vfd/mirror_server_stop.c | 12 ++++++------ 6 files changed, 46 insertions(+), 25 deletions(-) diff --git a/test/del_many_dense_attrs.c b/test/del_many_dense_attrs.c index 4c1efae..6f48901 100644 --- a/test/del_many_dense_attrs.c +++ b/test/del_many_dense_attrs.c @@ -62,17 +62,17 @@ static void catch_signal(int H5_ATTR_UNUSED signo) int main(void) { - hid_t fid = -1; /* HDF5 File ID */ - hid_t gid = -1; /* Group ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t tid = -1; /* Datatype ID */ - hid_t fapl = -1; /* File access property lists */ - hid_t gcpl = -1; /* Group creation property list */ - char aname[50]; /* Name of attribute */ - char *basename="attr"; /* Name prefix for attribute */ - char filename[100]; /* File name */ - int i; /* Local index variable */ + hid_t fid = -1; /* HDF5 File ID */ + hid_t gid = -1; /* Group ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t tid = -1; /* Datatype ID */ + hid_t fapl = -1; /* File access property lists */ + hid_t gcpl = -1; /* Group creation property list */ + char aname[50]; /* Name of attribute */ + const char *basename="attr"; /* Name prefix for attribute */ + char filename[100]; /* File name */ + int i; /* Local index variable */ /* Testing setup */ h5_reset(); diff --git a/test/fillval.c b/test/fillval.c index 019744a..72b8dcb 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -1453,12 +1453,16 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, void *val_rd, *odd_val; const void *init_val, *should_be, *even_val; int val_rd_i, init_val_i = 9999; - comp_vl_datatype init_val_c = {87, "baz", "mumble", 129}; + comp_vl_datatype init_val_c = {87, NULL, NULL, 129}; comp_vl_datatype val_rd_c; void *buf = NULL; unsigned odd; /* Whether an odd or even coord. was read */ unsigned i, j; /* Local index variables */ + /* Set vl datatype init value strings */ + init_val_c.a = HDstrdup("baz"); + init_val_c.b = HDstrdup("mumble"); + /* Make copy of dataset creation property list */ if((dcpl = H5Pcopy(_dcpl)) < 0) TEST_ERROR @@ -1802,8 +1806,10 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, /* Release elements & memory buffer */ for(i = 0; i < nelmts; i++) release_rtn((void *)((char *)buf + (val_size * i))); + + HDfree(init_val_c.a); + HDfree(init_val_c.b); HDfree(buf); - buf = NULL; /* Cleanup IDs */ if(H5Pclose(dcpl) < 0) TEST_ERROR @@ -1813,8 +1819,10 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, return 0; error: - if(buf) - HDfree(buf); + HDfree(init_val_c.a); + HDfree(init_val_c.b); + HDfree(buf); + H5E_BEGIN_TRY { H5Pclose(dcpl); H5Dclose(dset); @@ -1856,7 +1864,7 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) #else int fillval_i = 0x4c70f1cd; #endif - comp_vl_datatype fillval_c = {32, "foo", "bar", 64}; /* Fill value for compound+vl datatype tests */ + comp_vl_datatype fillval_c = {32, NULL, NULL, 64}; /* Fill value for compound+vl datatype tests */ char filename[1024]; /* Print testing message */ @@ -1865,6 +1873,10 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) else TESTING("contiguous dataset extend") + /* Set vl datatype fill value strings */ + fillval_c.a = HDstrdup("foo"); + fillval_c.b = HDstrdup("bar"); + /* Create dataset creation property list */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR if(H5D_CHUNKED == layout) @@ -1945,11 +1957,17 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) if(H5Pclose(dcpl) < 0) TEST_ERROR if(H5Fclose(file) < 0) TEST_ERROR + HDfree(fillval_c.a); + HDfree(fillval_c.b); + PASSED(); return 0; error: + HDfree(fillval_c.a); + HDfree(fillval_c.b); + H5E_BEGIN_TRY { H5Tclose(cmpd_vl_tid); H5Pclose(dcpl); @@ -1958,6 +1976,9 @@ error: return 1; skip: + HDfree(fillval_c.a); + HDfree(fillval_c.b); + H5E_BEGIN_TRY { H5Pclose(dcpl); H5Fclose(file); diff --git a/test/use.h b/test/use.h index e5eced2..52537d6 100644 --- a/test/use.h +++ b/test/use.h @@ -47,7 +47,7 @@ typedef struct options_t { hbool_t use_swmr; /* use swmr open (1) or not */ int iterations; /* iterations, default 1 */ hid_t fapl_id; /* instance-specific FAPL ID */ - char *progname; /* Program name (used in usage and dset name) */ + const char *progname; /* Program name (used in usage and dset name) */ } options_t; /* prototype declarations */ diff --git a/test/use_common.c b/test/use_common.c index b537741..7e19167 100644 --- a/test/use_common.c +++ b/test/use_common.c @@ -70,7 +70,7 @@ parse_option(int argc, char * const argv[], options_t * opts) exit(EXIT_SUCCESS); break; case 'f': /* usecase data file name */ - opts->filename = optarg; + opts->filename = HDstrdup(optarg); break; case 'i': /* iterations */ if ((opts->iterations = HDatoi(optarg)) <= 0) { diff --git a/utils/mirror_vfd/mirror_server.c b/utils/mirror_vfd/mirror_server.c index 2583e60..db7cf04 100644 --- a/utils/mirror_vfd/mirror_server.c +++ b/utils/mirror_vfd/mirror_server.c @@ -656,7 +656,7 @@ main(int argc, char **argv) #else /* H5_HAVE_MIRROR_VFD */ int -main(int argc, char **argv) +main(void) { HDprintf("Mirror VFD was not built -- cannot launch server.\n"); HDexit(EXIT_FAILURE); diff --git a/utils/mirror_vfd/mirror_server_stop.c b/utils/mirror_vfd/mirror_server_stop.c index ccd5824..f2414e0 100644 --- a/utils/mirror_vfd/mirror_server_stop.c +++ b/utils/mirror_vfd/mirror_server_stop.c @@ -184,20 +184,20 @@ main(int argc, char **argv) if (parse_args(argc, argv, &opts) < 0) { HDprintf("Unable to parse arguments\n"); - return EXIT_FAILURE; + HDexit(EXIT_FAILURE); } if (opts.help) { usage(); - return EXIT_SUCCESS; + HDexit(EXIT_FAILURE); } if (send_shutdown(&opts) < 0) { HDprintf("Unable to send shutdown command\n"); - return EXIT_FAILURE; + HDexit(EXIT_FAILURE); } - return EXIT_SUCCESS; + HDexit(EXIT_SUCCESS); } /* end main() */ #else /* H5_HAVE_MIRROR_VFD */ @@ -205,10 +205,10 @@ main(int argc, char **argv) /* ------------------------------------------------------------------------- */ int -main(int argc, char **argv) +main(void) { HDprintf("Mirror VFD not built -- unable to perform shutdown.\n"); - return EXIT_FAILURE; + HDexit(EXIT_FAILURE); } #endif /* H5_HAVE_MIRROR_VFD */ -- cgit v0.12