[PATCH v2 21/21] devtools: forbid direct use of compiler alignof and typeof

Tyler Retzlaff roretzla at linux.microsoft.com
Tue Feb 13 19:34:52 CET 2024


Add 2 checks forbidding direct use of __alignof__ and __typeof__ instead
C11 alignof and rte_common.h typeof macros should be used.

Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
---
 devtools/checkpatches.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index c9e466f..e379700 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -151,6 +151,22 @@ check_forbidden_additions() { # <patch>
 		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
 		"$1" || res=1
 
+	# forbid use of __alignof__
+	awk -v FOLDERS="lib drivers app examples" \
+		-v EXPRESSIONS='\\<__alignof__\\>' \
+		-v RET_ON_FAIL=1 \
+		-v MESSAGE='Using __alignof__, prefer C11 alignof' \
+		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+		"$1" || res=1
+
+	# forbid use of __typeof__
+	awk -v FOLDERS="lib drivers app examples" \
+		-v EXPRESSIONS='\\<__typeof__\\>' \
+		-v RET_ON_FAIL=1 \
+		-v MESSAGE='Using __typeof__, prefer typeof' \
+		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+		"$1" || res=1
+
 	# forbid use of non abstracted bit count operations
 	awk -v FOLDERS="lib drivers app examples" \
 		-v EXPRESSIONS='\\<__builtin_(clz|clzll|ctz|ctzll|popcount|popcountll)\\>' \
-- 
1.8.3.1



More information about the dev mailing list