summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2022-02-04 16:53:55 (GMT)
committerGitHub <noreply@github.com>2022-02-04 16:53:55 (GMT)
commit36d9a165e428eb883f9fd72b6707555536292845 (patch)
tree61848a7a985725dcbb52daab3a986ff490cf909c /tools
parent856de93673f2bd097b90e2803475ef4fc3d689fa (diff)
downloadhdf5-36d9a165e428eb883f9fd72b6707555536292845.zip
hdf5-36d9a165e428eb883f9fd72b6707555536292845.tar.gz
hdf5-36d9a165e428eb883f9fd72b6707555536292845.tar.bz2
Fix a few issues noted by LGTM (#1421)
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/h5diff_array.c6
-rw-r--r--tools/lib/h5diff_attr.c2
-rw-r--r--tools/lib/h5tools.c2
-rw-r--r--tools/lib/h5tools_dump.c4
-rw-r--r--tools/src/h5dump/h5dump_ddl.c4
-rw-r--r--tools/src/h5dump/h5dump_xml.c13
-rw-r--r--tools/src/h5perf/sio_perf.c2
7 files changed, 19 insertions, 14 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 1b0d36f..e8cfacb 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -2063,7 +2063,7 @@ diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
opts->print_percentage = 0;
print_pos(opts, elem_idx, 0);
if (print_data(opts)) {
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
@@ -2110,7 +2110,7 @@ diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
opts->print_percentage = 0;
print_pos(opts, elem_idx, 0);
if (print_data(opts)) {
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
@@ -2157,7 +2157,7 @@ diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
opts->print_percentage = 0;
print_pos(opts, elem_idx, 0);
if (print_data(opts)) {
- parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
}
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 5c1777a..63b6d8f 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -292,7 +292,7 @@ build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t **table_out,
}
if (opts->mode_verbose_level >= 1)
- parallel_print("Attributes status: %d common, %d only in obj1, %d only in obj2\n",
+ parallel_print("Attributes status: %zu common, %zu only in obj1, %zu only in obj2\n",
table_lp->nattrs - table_lp->nattrs_only1 - table_lp->nattrs_only2,
table_lp->nattrs_only1, table_lp->nattrs_only2);
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index db8df16..da55136 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -945,7 +945,7 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_spec
* as TRUE, we should return failure now since the file couldn't be opened with
* the VFL driver/VOL connector that was set on the FAPL by the caller.
*/
- if (fid < 0 && use_specific_driver)
+ if (use_specific_driver)
H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to open file using specified FAPL");
/*
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 0fc5d2d..b8c9a19 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -2486,7 +2486,7 @@ found_string_type:
ctx->need_prefix = TRUE;
h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "OPAQUE_SIZE \"%s\";", size);
+ h5tools_str_append(buffer, "OPAQUE_SIZE \"%zu\";", size);
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
(hsize_t)0);
}
@@ -2996,7 +2996,7 @@ h5tools_dump_oid(FILE *stream, const h5tool_format_t *info, h5tools_context_t *c
ctx->need_prefix = TRUE;
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %s %d %s", OBJID, BEGIN, oid, END);
+ h5tools_str_append(&buffer, "%s %s %" PRId64 " %s", OBJID, BEGIN, oid, END);
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c
index 37bb82d..b0bce0c 100644
--- a/tools/src/h5dump/h5dump_ddl.c
+++ b/tools/src/h5dump/h5dump_ddl.c
@@ -1318,7 +1318,7 @@ attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *a
j = (int)HDstrlen(op_name) - 1;
/* find the last / */
while (j >= 0) {
- if (op_name[j] == '/' && (j == 0 || (j > 0 && op_name[j - 1] != '\\')))
+ if (op_name[j] == '/' && (j == 0 || (op_name[j - 1] != '\\')))
break;
j--;
}
@@ -1541,7 +1541,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5
/* find the last / */
while (j >= 0) {
- if (attr[j] == '/' && (j == 0 || (j > 0 && attr[j - 1] != '\\')))
+ if (attr[j] == '/' && (j == 0 || (attr[j - 1] != '\\')))
break;
j--;
}
diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c
index 19efd6f..5f64d6c 100644
--- a/tools/src/h5dump/h5dump_xml.c
+++ b/tools/src/h5dump/h5dump_xml.c
@@ -591,6 +591,8 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen
if (outlen < 22)
return 1;
+ H5_CHECK_OVERFLOW(outlen, int, size_t);
+
lookup_ret = ref_path_table_lookup(str, &obj_token);
if (lookup_ret < 0) {
if (HDstrlen(str) == 0) {
@@ -600,7 +602,7 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen
ref_path_table_gen_fake(str, &obj_token);
H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str);
- HDsnprintf(outstr, outlen, "xid_%s", obj_tok_str);
+ HDsnprintf(outstr, (size_t)outlen, "xid_%s", obj_tok_str);
H5free_memory(obj_tok_str);
return 0;
@@ -615,7 +617,7 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen
ref_path_table_gen_fake(str, &obj_token);
H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str);
- HDsnprintf(outstr, outlen, "xid_%s", obj_tok_str);
+ HDsnprintf(outstr, (size_t)outlen, "xid_%s", obj_tok_str);
H5free_memory(obj_tok_str);
return 0;
@@ -627,7 +629,7 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen
}
H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str);
- HDsnprintf(outstr, outlen, "xid_%s", obj_tok_str);
+ HDsnprintf(outstr, (size_t)outlen, "xid_%s", obj_tok_str);
H5free_memory(obj_tok_str);
return 0;
@@ -3598,7 +3600,10 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "\"");
for (i = 0; i < sz; i++) {
- h5tools_str_append(&buffer, "%x ", *(unsigned int *)buf + (i * sizeof(unsigned int)));
+ unsigned long val = *(unsigned int *)buf + (i * sizeof(unsigned int));
+
+ H5_CHECK_OVERFLOW(val, unsigned long, unsigned);
+ h5tools_str_append(&buffer, "%x ", (unsigned)val);
}
h5tools_str_append(&buffer, "\"");
h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
diff --git a/tools/src/h5perf/sio_perf.c b/tools/src/h5perf/sio_perf.c
index f245b92..87b9d65 100644
--- a/tools/src/h5perf/sio_perf.c
+++ b/tools/src/h5perf/sio_perf.c
@@ -277,7 +277,7 @@ run_test_loop(struct options *opts)
}
/* print size information */
- output_report("Transfer Buffer Size (bytes): %d\n", buf_bytes);
+ output_report("Transfer Buffer Size (bytes): %zu\n", buf_bytes);
output_report("File Size(MB): %.2f\n", ((double)parms.num_bytes) / ONE_MB);
print_indent(0);