diff options
| author | Mark Wielaard <[email protected]> | 2014-01-23 00:56:41 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2014-01-30 10:17:15 +0100 |
| commit | f48eb6b15fee66e54b488d71738979fc608f25ee (patch) | |
| tree | 22be2f2780909d8d61df125b29de5f3f60e52e97 /src/strings.c | |
| parent | 13968d9aa9990d53999b14494ed55c2d68d4ead5 (diff) | |
Use -Wformat=2 by default for all files.
This just makes sure that all format strings are given as literals to
printf like functions so the compiler can see and check them. Remove
all no_Wformat, add -Wformat=2 unconditionally to AM_CFLAGS.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src/strings.c')
| -rw-r--r-- | src/strings.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/strings.c b/src/strings.c index 084eb999..37210a74 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1,5 +1,5 @@ /* Print the strings of printable characters in files. - Copyright (C) 2005-2010, 2012 Red Hat, Inc. + Copyright (C) 2005-2010, 2012, 2014 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper <[email protected]>, 2005. @@ -116,8 +116,15 @@ static bool char_7bit; /* True if file names should be printed before strings. */ static bool print_file_name; -/* Location print format string. */ -static const char *locfmt; +/* Radix for printed numbers. */ +static enum +{ + radix_none = 0, + radix_decimal, + radix_hex, + radix_octal +} radix = radix_none; + /* Page size in use. */ static size_t ps; @@ -279,16 +286,16 @@ parse_opt (int key, char *arg, switch (arg[0]) { case 'd': - locfmt = "%7" PRId64 " "; + radix = radix_decimal; break; case 'o': octfmt: - locfmt = "%7" PRIo64 " "; + radix = radix_octal; break; case 'x': - locfmt = "%7" PRIx64 " "; + radix = radix_hex; break; default: @@ -355,8 +362,11 @@ process_chunk_mb (const char *fname, const unsigned char *buf, off64_t to, fputs_unlocked (": ", stdout); } - if (unlikely (locfmt != NULL)) - printf (locfmt, (int64_t) to - len - (buf - start)); + if (unlikely (radix != radix_none)) + printf ((radix == radix_octal ? "%7" PRIo64 " " + : (radix == radix_decimal ? "%7" PRId64 " " + : "%7" PRIx64 " ")), + (int64_t) to - len - (buf - start)); if (unlikely (*unprinted != NULL)) { @@ -420,8 +430,11 @@ process_chunk (const char *fname, const unsigned char *buf, off64_t to, fputs_unlocked (": ", stdout); } - if (likely (locfmt != NULL)) - printf (locfmt, (int64_t) to - len - (buf - start)); + if (likely (radix != radix_none)) + printf ((radix == radix_octal ? "%7" PRIo64 " " + : (radix == radix_decimal ? "%7" PRId64 " " + : "%7" PRIx64 " ")), + (int64_t) to - len - (buf - start)); if (unlikely (*unprinted != NULL)) { |
