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

Message ID 1707849292-19519-22-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series use C11 alignof |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Tyler Retzlaff Feb. 13, 2024, 6:34 p.m. UTC
  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@linux.microsoft.com>
---
 devtools/checkpatches.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
  

Patch

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)\\>' \