summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2022-07-11 17:28:02 (GMT)
committerGitHub <noreply@github.com>2022-07-11 17:28:02 (GMT)
commite269f9036474b9d5b3c88d865e7bb20ecad5c54c (patch)
treeaa5313f198b044605d6b135cd4499cc2f91eacee /tools/lib
parent0412d3f292b255da700d865fd1eb990e05c038bb (diff)
downloadhdf5-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/lib')
-rw-r--r--tools/lib/h5diff_array.c12
-rw-r--r--tools/lib/h5tools_dump.c4
-rw-r--r--tools/lib/h5tools_str.c28
3 files changed, 36 insertions, 8 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;
}