diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2022-07-11 17:28:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 17:28:02 (GMT) |
commit | e269f9036474b9d5b3c88d865e7bb20ecad5c54c (patch) | |
tree | aa5313f198b044605d6b135cd4499cc2f91eacee /tools | |
parent | 0412d3f292b255da700d865fd1eb990e05c038bb (diff) | |
download | hdf5-e269f9036474b9d5b3c88d865e7bb20ecad5c54c.zip hdf5-e269f9036474b9d5b3c88d865e7bb20ecad5c54c.tar.gz hdf5-e269f9036474b9d5b3c88d865e7bb20ecad5c54c.tar.bz2 |
Misc clang warning fixes (#1869)
* Minor clang warning fixes in src and test
* Fixes clang warnings in high-level library
* clang format-nonliteral warning fixes
* Committing clang-format changes
* Fixed int -> float clang cast warnings in h5diff
* Quiets some warnings in flex/bison generated code
* Suppress overlong string warning for libinfo on clang
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lib/h5diff_array.c | 12 | ||||
-rw-r--r-- | tools/lib/h5tools_dump.c | 4 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 28 | ||||
-rw-r--r-- | tools/src/h5import/h5import.c | 30 | ||||
-rw-r--r-- | tools/src/h5perf/pio_perf.c | 2 | ||||
-rw-r--r-- | tools/src/h5perf/sio_engine.c | 2 | ||||
-rw-r--r-- | tools/src/h5perf/sio_perf.c | 2 | ||||
-rw-r--r-- | tools/src/misc/h5repart.c | 2 | ||||
-rw-r--r-- | tools/test/perform/zip_perf.c | 2 |
9 files changed, 69 insertions, 15 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 9fa3ccc..0c28789 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -2734,7 +2734,7 @@ diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, di HDmemcpy(&temp2_long, mem2, sizeof(long)); /* -d and !-p */ if (opts->delta_bool && !opts->percent_bool) { - if (ABS(temp1_long - temp2_long) > opts->delta) { + if (ABS(temp1_long - temp2_long) > (long)opts->delta) { opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2776,7 +2776,7 @@ diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, di } nfound++; } - else if (per > opts->percent && ABS(temp1_long - temp2_long) > opts->delta) { + else if (per > opts->percent && ABS(temp1_long - temp2_long) > (long)opts->delta) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2822,7 +2822,7 @@ diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, d HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); /* -d and !-p */ if (opts->delta_bool && !opts->percent_bool) { - if (PDIFF(temp1_ulong, temp2_ulong) > opts->delta) { + if (PDIFF(temp1_ulong, temp2_ulong) > (unsigned long)opts->delta) { opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2866,7 +2866,7 @@ diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, d } nfound++; } - else if (per > opts->percent && PDIFF(temp1_ulong, temp2_ulong) > opts->delta) { + else if (per > opts->percent && PDIFF(temp1_ulong, temp2_ulong) > (unsigned long)opts->delta) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2913,7 +2913,7 @@ diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, d /* -d and !-p */ if (opts->delta_bool && !opts->percent_bool) { - if (ABS(temp1_llong - temp2_llong) > opts->delta) { + if (ABS(temp1_llong - temp2_llong) > (long long)opts->delta) { opts->print_percentage = 0; print_pos(opts, elem_idx, 0); if (print_data(opts)) { @@ -2957,7 +2957,7 @@ diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, d } nfound++; } - else if (per > opts->percent && ABS(temp1_llong - temp2_llong) > opts->delta) { + else if (per > opts->percent && ABS(temp1_llong - temp2_llong) > (long long)opts->delta) { opts->print_percentage = 1; print_pos(opts, elem_idx, 0); if (print_data(opts)) { diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 78dd3ff..e76328f 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -740,8 +740,10 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, FILE *strea for (indx = 0; indx < nblocks; indx++) { unsigned loop_indx; + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") h5tools_str_append(buffer, outputformat.dset_blockformat_pre, indx ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)indx); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") /* Start coordinates and opposite corner */ for (loop_indx = 0; loop_indx < ndims; loop_indx++) @@ -1097,8 +1099,10 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, FILE *strea for (indx = 0; indx < npoints; indx++) { unsigned loop_indx; + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") h5tools_str_append(buffer, outputformat.dset_ptformat_pre, indx ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)indx); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") for (loop_indx = 0; loop_indx < ndims; loop_indx++) h5tools_str_append(buffer, "%s%" PRIuHSIZE, loop_indx ? "," : "(", diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 5ade61f..ff7e233 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -264,7 +264,9 @@ h5tools_str_fmt(h5tools_str_t *str /*in,out*/, size_t start, const char *fmt) /* Reset the output string and append a formatted version */ h5tools_str_trunc(str, start); + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") h5tools_str_append(str, fmt, temp); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") /* Free the temp buffer if we allocated one */ if (temp != _temp) @@ -300,11 +302,18 @@ h5tools_str_prefix(h5tools_str_t *str /*in,out*/, const h5tool_format_t *info, h if (i) h5tools_str_append(str, "%s", OPT(info->idx_sep, ",")); + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") h5tools_str_append(str, OPT(info->idx_n_fmt, "%" PRIuHSIZE), (hsize_t)ctx->pos[i]); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") } } - else /* Scalar */ + else { + /* Scalar */ + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") h5tools_str_append(str, OPT(info->idx_n_fmt, "%" PRIuHSIZE), (hsize_t)elmtno); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") + } + H5TOOLS_DEBUG("str=%s", str->s); H5TOOLS_ENDDEBUG(" "); @@ -341,11 +350,18 @@ h5tools_str_region_prefix(h5tools_str_t *str /*in,out*/, const h5tool_format_t * if (i) h5tools_str_append(str, "%s", OPT(info->idx_sep, ",")); + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") h5tools_str_append(str, OPT(info->idx_n_fmt, "%" PRIuHSIZE), (hsize_t)ctx->pos[i]); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") } } - else /* Scalar */ + else { + /* Scalar */ + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") h5tools_str_append(str, OPT(info->idx_n_fmt, "%" PRIuHSIZE), (hsize_t)0); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") + } + H5TOOLS_DEBUG("str=%s", str->s); H5TOOLS_ENDDEBUG(" "); @@ -463,6 +479,7 @@ h5tools_str_dump_space_blocks(h5tools_str_t *str, hid_t rspace, const h5tool_for for (u = 0; u < nblocks; u++) { unsigned v; + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") h5tools_str_append(str, info->dset_blockformat_pre, u ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)u); @@ -474,6 +491,7 @@ h5tools_str_dump_space_blocks(h5tools_str_t *str, hid_t rspace, const h5tool_for h5tools_str_append(str, "%s%" PRIuHSIZE, v ? "," : ")-(", ptdata[u * 2 * ndims + v + ndims]); h5tools_str_append(str, ")"); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") } HDfree(ptdata); @@ -522,6 +540,7 @@ h5tools_str_dump_space_points(h5tools_str_t *str, hid_t rspace, const h5tool_for for (u = 0; u < npoints; u++) { unsigned v; + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") h5tools_str_append(str, info->dset_ptformat_pre, u ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)u); @@ -529,6 +548,7 @@ h5tools_str_dump_space_points(h5tools_str_t *str, hid_t rspace, const h5tool_for h5tools_str_append(str, "%s%" PRIuHSIZE, v ? "," : "(", (ptdata[u * ndims + v])); h5tools_str_append(str, ")"); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") } HDfree(ptdata); @@ -657,6 +677,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai H5T_class_t type_class; char * ret_value = NULL; + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") + H5TOOLS_START_DEBUG(" "); /* Build default formats for long long types */ if (!fmt_llong[0]) { @@ -1320,6 +1342,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai ret_value = h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s")); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") + H5TOOLS_ENDDEBUG(" with %s", ret_value); return ret_value; } diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c index 317db81..9da348a 100644 --- a/tools/src/h5import/h5import.c +++ b/tools/src/h5import/h5import.c @@ -91,6 +91,8 @@ main(int argc, char *argv[]) const char *err9 = "Cannot specify more than 30 input files in one call to h5import.\n"; const char *err10 = "Length of output file name limited to 255 chars.\n"; + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") + h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -236,6 +238,8 @@ main(int argc, char *argv[]) if (process(opt) == -1) goto err; + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") + for (i = 0; i < opt->fcount; i++) { in = &(opt->infiles[i].in); if (in->sizeOfDimension) @@ -364,6 +368,8 @@ processDataFile(char *infile, struct Input *in, hid_t file_id) const char *err11 = "Error in reading string data.\n"; int retval = -1; + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") + /*------------------------------------------------------------------------- * special case for opening binary classes in H5_HAVE_WIN32_API * "FP" denotes a floating point binary file, @@ -450,13 +456,15 @@ processDataFile(char *infile, struct Input *in, hid_t file_id) goto error; } + H5_GCC_CLANG_DIAG_ON("format-nonliteral") + /* Set success return value */ retval = 0; error: if (strm) HDfclose(strm); - return (retval); + return retval; } static int @@ -1429,10 +1437,12 @@ processConfigurationFile(char *infile, struct Input *in) const char *err19 = "Unable to get integer value.\n"; const char *err20 = "Unable to get subset values.\n"; - /* create vector to map which keywords have been found - check vector after each keyword to check for violation - at the end check vector to see if required fields have been provided - process the output file according to the options + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") + + /* - create vector to map which keywords have been found + * - check vector after each keyword to check for violation + * - at the end check vector to see if required fields have been provided + * - process the output file according to the options */ /* Initialize machine endian */ @@ -2429,13 +2439,15 @@ processConfigurationFile(char *infile, struct Input *in) } } + H5_GCC_CLANG_DIAG_ON("format-nonliteral") + /* Set success return value */ retval = 0; error: if (strm) HDfclose(strm); - return (retval); + return retval; } static int @@ -4610,6 +4622,8 @@ process(struct Options *opt) "Error in creating the output data set. Dataset with the same name may exist at the specified path\n"; const char *err6 = "Error in writing the output data set.\n"; + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") + H5E_BEGIN_TRY { if ((file_id = H5Fopen(opt->outfile, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { @@ -4742,8 +4756,10 @@ process(struct Options *opt) } /* STR */ + H5_GCC_CLANG_DIAG_ON("format-nonliteral") + H5Fclose(file_id); - return (0); + return 0; } uint16_t diff --git a/tools/src/h5perf/pio_perf.c b/tools/src/h5perf/pio_perf.c index 2e82dd4..5f09e15 100644 --- a/tools/src/h5perf/pio_perf.c +++ b/tools/src/h5perf/pio_perf.c @@ -1087,7 +1087,9 @@ output_report(const char *fmt, ...) va_list ap; HDva_start(ap, fmt); + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") HDvfprintf(output, fmt, ap); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") HDva_end(ap); } } diff --git a/tools/src/h5perf/sio_engine.c b/tools/src/h5perf/sio_engine.c index 7781f80..eff5f61 100644 --- a/tools/src/h5perf/sio_engine.c +++ b/tools/src/h5perf/sio_engine.c @@ -1298,7 +1298,9 @@ do_cleanupfile(iotype iot, char *filename) if (driver == H5FD_FAMILY) { for (j = 0; /*void*/; j++) { + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") HDsnprintf(temp, temp_sz, filename, j); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") if (HDaccess(temp, F_OK) < 0) break; diff --git a/tools/src/h5perf/sio_perf.c b/tools/src/h5perf/sio_perf.c index 6da073a..2a0db61 100644 --- a/tools/src/h5perf/sio_perf.c +++ b/tools/src/h5perf/sio_perf.c @@ -647,7 +647,9 @@ output_report(const char *fmt, ...) va_list ap; HDva_start(ap, fmt); + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") HDvfprintf(output, fmt, ap); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") HDva_end(ap); } diff --git a/tools/src/misc/h5repart.c b/tools/src/misc/h5repart.c index 078883d..89be169 100644 --- a/tools/src/misc/h5repart.c +++ b/tools/src/misc/h5repart.c @@ -151,6 +151,7 @@ get_size(const char *progname, int *argno, int argc, char *argv[]) * *------------------------------------------------------------------------- */ +H5_GCC_CLANG_DIAG_OFF("format-nonliteral") int main(int argc, char *argv[]) { @@ -507,3 +508,4 @@ main(int argc, char *argv[]) HDfree(buf); return EXIT_SUCCESS; } /* end main */ +H5_GCC_CLANG_DIAG_ON("format-nonliteral") diff --git a/tools/test/perform/zip_perf.c b/tools/test/perform/zip_perf.c index 87a7122..24b3754 100644 --- a/tools/test/perform/zip_perf.c +++ b/tools/test/perform/zip_perf.c @@ -87,7 +87,9 @@ error(const char *fmt, ...) va_start(ap, fmt); HDfprintf(stderr, "%s: error: ", prog); + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") HDvfprintf(stderr, fmt, ap); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") HDfprintf(stderr, "\n"); va_end(ap); HDexit(EXIT_FAILURE); |