Skip to content

Commit 504de82

Browse files
fcneufjengelh
authored andcommitted
mbop: cure instances of -Wformat-security compiler warning
``` tools/mbop.hpp: In instantiation of ‘int mbop_fprintf(Args&& ...) [with Args = {_IO_FILE*&, const char (&)[19]}]’: tools/mbop_main.cpp:268:17: required from here 268 | mbop_fprintf(stderr, "Property is unset\n"); tools/mbop.hpp:38:23: warning: format not a string literal and no format arguments [-Wformat-security] 38 | return fprintf(std::forward<Args>(args)...); ```
1 parent 231eeda commit 504de82

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tools/mbop.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ extern unsigned int g_continuous_mode, g_verbose_mode, g_command_num;
3131

3232
}
3333

34-
template<typename... Args> int mbop_fprintf(Args &&...args)
34+
template<typename... Args> int mbop_fprintf(FILE *f, Args &&...args)
3535
{
3636
if (global::g_verbose_mode)
3737
fprintf(stderr, "%s [cmd %d]: ", g_storedir, global::g_command_num);
38-
return fprintf(std::forward<Args>(args)...);
38+
#ifdef __GNUC__
39+
#pragma GCC diagnostic push
40+
#pragma GCC diagnostic ignored "-Wformat-security"
41+
#endif
42+
return fprintf(f, args...);
43+
#ifdef __GNUC__
44+
#pragma GCC diagnostic pop
45+
#endif
3946
}
4047

4148
extern void mbop_help_cb(const struct HXoptcb *);

0 commit comments

Comments
 (0)