diff options
author | Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> | 2021-07-12 11:21:01 +0200 |
---|---|---|
committer | Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> | 2021-07-19 12:34:21 +0200 |
commit | 5ec78b7eb08bf1c857383ce627e8b65e1d67e902 (patch) | |
tree | a78966df3d1d7fa9c8f4b9999bafd8d64c8fc192 | |
parent | 1b11e44c3e54afe7a2162ec3ff9cc056fbd06637 (diff) | |
download | neard-5ec78b7eb08bf1c857383ce627e8b65e1d67e902.tar.gz |
nfctool: pass the format as string literal
clang v11 has troubles detecting that sprintf() format is passed in
sniffer_print_hexdump() as string literal. Remove the local "fmt"
variable and call sprintf() in two branches of if, to satisfy clang and
fix warnings like:
tools/nfctool/sniffer.c:206:18: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
sprintf(line, fmt, offset);
^~~
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
-rw-r--r-- | tools/nfctool/sniffer.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/nfctool/sniffer.c b/tools/nfctool/sniffer.c index 3d1d230..6a38a21 100644 --- a/tools/nfctool/sniffer.c +++ b/tools/nfctool/sniffer.c @@ -168,7 +168,6 @@ void sniffer_print_hexdump(FILE *file, guint8 *data, guint32 len, gchar *hexa = NULL, *human = NULL; guint8 offset_len; guint8 human_offset; - gchar *fmt; if (len == 0) return; @@ -185,11 +184,9 @@ void sniffer_print_hexdump(FILE *file, guint8 *data, guint32 len, if (output_len > 0xFFFF) { offset_len = 8; human_offset = HUMAN_READABLE_OFFSET + 4; - fmt = "%08X: "; } else { offset_len = 4; human_offset = HUMAN_READABLE_OFFSET; - fmt = "%04X: "; } if (print_len) { @@ -203,7 +200,10 @@ void sniffer_print_hexdump(FILE *file, guint8 *data, guint32 len, if (digits == 0) { memset(line, ' ', human_offset); - sprintf(line, fmt, offset); + if (offset_len == 8) + sprintf(line, "%08X: ", offset); + else + sprintf(line, "%04X: ", offset); offset += 16; |