Skip to content

Commit

Permalink
Fixes for format string warnings raised by -Wformat=2/-Wformat-securi…
Browse files Browse the repository at this point in the history
…ty (#1489)
  • Loading branch information
derobins authored Mar 11, 2022
1 parent 01209d2 commit 1f92283
Showing 7 changed files with 13 additions and 30 deletions.
1 change: 0 additions & 1 deletion config/clang-warnings/developer-general
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
-Wformat-nonliteral
-Wmissing-noreturn
-Wsometimes-uninitialized
-Wswitch-enum
16 changes: 5 additions & 11 deletions config/clang-warnings/general
Original file line number Diff line number Diff line change
@@ -8,19 +8,13 @@
-Wformat=2
-Wframe-larger-than=16384
-Wimplicit-fallthrough
#
# NOTE: Due to the divergence in the C and C++, we're dropping support for
# compiling the C library with a C++ compiler and dropping the -Wc++-compat
# warning.
#
-Wno-c++-compat
#
# NOTE: Disable the -Wformat-nonliteral from -Wformat=2 here and re-add
# it to the developer flags.
#
-Wno-format-nonliteral
-Wnull-dereference
-Wunused-const-variable
-Wwrite-strings
-Wpedantic
-Wvolatile-register-var
# NOTE: Due to the divergence in the C and C++, we're dropping support for
# compiling the C library with a C++ compiler and dropping the -Wc++-compat
# warning.
#
-Wno-c++-compat
1 change: 0 additions & 1 deletion config/gnu-warnings/cxx-general
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@
-Winit-self
-Winvalid-pch
-Wmissing-include-dirs
-Wno-format-nonliteral
-Wnon-virtual-dtor
-Wold-style-cast
-Woverloaded-virtual
3 changes: 0 additions & 3 deletions config/gnu-warnings/developer-general
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# (suggestions from gcc, not code problems)
# NOTE: -Wformat-nonliteral added back in here (from being disabled in
# H5_CFLAGS)
-Waggregate-return
-Wdisabled-optimization
-Wformat-nonliteral
-Winline
-Wmissing-format-attribute
-Wmissing-noreturn
14 changes: 4 additions & 10 deletions config/gnu-warnings/general
Original file line number Diff line number Diff line change
@@ -15,18 +15,12 @@
-Winit-self
-Winvalid-pch
-Wmissing-include-dirs
#
-Wshadow
-Wundef
-Wwrite-strings
-pedantic
# NOTE: Due to the divergence in the C and C++, we're dropping support for
# compiling the C library with a C++ compiler and dropping the -Wc++-compat
# warning.
#
-Wno-c++-compat
#
# NOTE: Disable the -Wformat-nonliteral from -Wformat=2 here and re-add
# it to the developer flags.
#
-Wno-format-nonliteral
-Wshadow
-Wundef
-Wwrite-strings
-pedantic
2 changes: 1 addition & 1 deletion tools/lib/h5tools_str.c
Original file line number Diff line number Diff line change
@@ -1051,7 +1051,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai

H5TOOLS_DEBUG("H5T_ENUM");
if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0)
h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name)));
h5tools_str_append(str, "%s", h5tools_escape(enum_name, sizeof(enum_name)));
else {
size_t i;
if (1 == nsize)
6 changes: 3 additions & 3 deletions tools/src/h5ls/h5ls.c
Original file line number Diff line number Diff line change
@@ -2299,7 +2299,7 @@ list_lnk(const char *name, const H5L_info2_t *linfo, void *_iter)
iter->symlink_list->dangle_link = TRUE;

h5tools_str_append(&buffer, "Soft Link {");
h5tools_str_append(&buffer, buf);
h5tools_str_append(&buffer, "%s", buf);
h5tools_str_append(&buffer, "}");
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
(hsize_t)0, (hsize_t)0);
@@ -2367,11 +2367,11 @@ list_lnk(const char *name, const H5L_info2_t *linfo, void *_iter)
goto done;

h5tools_str_append(&buffer, "External Link {");
h5tools_str_append(&buffer, filename);
h5tools_str_append(&buffer, "%s", filename);
h5tools_str_append(&buffer, "/");
if (*path != '/')
h5tools_str_append(&buffer, "/");
h5tools_str_append(&buffer, path);
h5tools_str_append(&buffer, "%s", path);
h5tools_str_append(&buffer, "}");
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
(hsize_t)0, (hsize_t)0);

0 comments on commit 1f92283

Please sign in to comment.