From 5299580c1ced39e7a6d7ac2717a3d6a3cab299b0 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 20 Jan 2009 13:05:25 -0500 Subject: [PATCH] Use format strings directly to prevent -Werror=format-security failures Gcc is too stupid to realize that: const char *usage="String which has no percent signs"; com_err(progname, 0, usage); is OK. I refuse to bow to stupidity with: com_err(progname, 0, "%s", usage); but I will use the string directly for the sake of people who like to build with -Werror=format-security. Signed-off-by: "Theodore Ts'o" --- debugfs/dump.c | 11 +++++------ lib/ss/test_ss.c | 4 ++-- tests/progs/test_icount.c | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/debugfs/dump.c b/debugfs/dump.c index 39a4166..ab0d68b 100644 --- a/debugfs/dump.c +++ b/debugfs/dump.c @@ -145,7 +145,6 @@ void do_dump(int argc, char **argv) int fd; int c; int preserve = 0; - const char *dump_usage = "Usage: dump_inode [-p] "; char *in_fn, *out_fn; reset_getopt(); @@ -155,14 +154,14 @@ void do_dump(int argc, char **argv) preserve++; break; default: - com_err(argv[0], 0, dump_usage); + print_usage: + com_err(argv[0], 0, "Usage: dump_inode [-p] " + " "); return; } } - if (optind != argc-2) { - com_err(argv[0], 0, dump_usage); - return; - } + if (optind != argc-2) + goto print_usage; if (check_fs_open(argv[0])) return; diff --git a/lib/ss/test_ss.c b/lib/ss/test_ss.c index aba7cbc..41d84ea 100644 --- a/lib/ss/test_ss.c +++ b/lib/ss/test_ss.c @@ -87,7 +87,6 @@ int main(int argc, char **argv) char *cmd_file = 0; int sci_idx; int exit_status = 0; - const char *usage = "Usage: test_ss [-R request] [-f cmd_file]"; while ((c = getopt (argc, argv, "wR:f:")) != EOF) { switch (c) { @@ -98,7 +97,8 @@ int main(int argc, char **argv) cmd_file = optarg; break; default: - com_err(argv[0], 0, usage); + com_err(argv[0], 0, "Usage: test_ss [-R request] " + "[-f cmd_file]"); exit(1); } } diff --git a/tests/progs/test_icount.c b/tests/progs/test_icount.c index bb4073e..aa9b932 100644 --- a/tests/progs/test_icount.c +++ b/tests/progs/test_icount.c @@ -296,7 +296,6 @@ int main(int argc, char **argv) { int retval; int sci_idx; - const char *usage = "Usage: test_icount [-R request] [-f cmd_file]"; int c; char *request = 0; int exit_status = 0; @@ -327,7 +326,8 @@ int main(int argc, char **argv) cmd_file = optarg; break; default: - com_err(argv[0], 0, usage); + com_err(argv[0], 0, "Usage: test_icount " + "[-R request] [-f cmd_file]"); exit(1); } } -- 1.8.3.1