devtools: check %l format specifier
authorFerruh Yigit <ferruh.yigit@intel.com>
Wed, 19 May 2021 19:24:49 +0000 (21:24 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 21 May 2021 13:41:54 +0000 (15:41 +0200)
%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 <ferruh.yigit@intel.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
devtools/checkpatches.sh

index ba43f84..c30dadd 100755 (executable)
@@ -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, prefer %PRI*64 if type is [u]int64_t' \
+               -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)' \