[linux-nfc] [neard][PATCH v2 09/73] nfctool: pass the format as string literal
Krzysztof Kozlowski <[email protected]> Mon, 19 Jul 2021 13:07:15 +0200
| Newsgroups | org.01.lists.linux-nfc,dev.linux.lists.oe-linux-nfc |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]>
---
tools/nfctool/sniffer.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/nfctool/sniffer.c b/tools/nfctool/sniffer.c
index 3d1d230a50c5..6a38a213c74d 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;
--
2.27.0
_______________________________________________
Linux-nfc mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s