]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Use format strings directly to prevent -Werror=format-security failures
authorTheodore Ts'o <tytso@mit.edu>
Tue, 20 Jan 2009 18:05:25 +0000 (13:05 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 20 Jan 2009 18:05:25 +0000 (13:05 -0500)
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" <tytso@mit.edu>
debugfs/dump.c
lib/ss/test_ss.c
tests/progs/test_icount.c

index 39a4166863dde01be93fa372984281feb365ac66..ab0d68b9d382afe7a0b571ef86690b2b664f9902 100644 (file)
@@ -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] <file> <output_file>";
        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] "
+                               "<file> <output_file>");
                        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;
index aba7cbcdc18a3a427d15ff1c2219f3f64969a17a..41d84ea7bef269f287afe5c57e1ee441123fd6ac 100644 (file)
@@ -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);
                }
        }
index bb4073e44666da28de8f64b2ec9c22ccc77f7211..aa9b93216f3b29815b8acc031204251fa0ac4781 100644 (file)
@@ -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);
                }
        }