Thread (8 messages) 8 messages, 2 authors, 2021-05-21

[dpdk-dev] [PATCH v2] devtools: check %l format specifier

From: Thomas Monjalon <hidden>
Date: 2021-05-19 19:25:01
Subsystem: the rest · Maintainer: Linus Torvalds

From: Ferruh Yigit <redacted>

%lx or %llx tend to be wrong for 32-bit platform
if used for fixed size variable like uint64_t.
A checkpatch warning will avoid this common mistake.

Signed-off-by: Ferruh Yigit <redacted>
Signed-off-by: Thomas Monjalon <redacted>
---
v2: proposal to reword the message and comment
---
 devtools/checkpatches.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index db4c7d8301..0e09b2cab8 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -69,6 +69,14 @@ check_forbidden_additions() { # <patch>
 		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
 		"$1" || res=1
 
+	# check %l or %ll format specifier
+	awk -v FOLDERS='lib drivers app examples' \
+		-v EXPRESSIONS='%ll*[xud]' \
+		-v RET_ON_FAIL=1 \
+		-v MESSAGE='Using %l format, should it be %PRI*64?' \
+		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+		"$1" || res=1
+
 	# forbid variable declaration inside "for" loop
 	awk -v FOLDERS='.' \
 		-v EXPRESSIONS='for[[:space:]]*\\((char|u?int|unsigned|s?size_t)' \
-- 
2.31.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help