From 2037362e1665ce901b5ff085d3fa6bcaf2ac426c Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Fri, 7 Jul 2023 10:18:23 +0800 Subject: [PATCH] checkpatch: exclude POSIX headers from typedef rule The `NEW_TYPEDEFS` rule consistently generates false positives when implementing POSIX standard APIs. It makes sense to disable this check for the POSIX haders rather than requiring merge superpowers constantly. That way, we can merge as per usual after sufficient approvals rather than waiting for someone with merge superpowers to override / manually merge. Signed-off-by: Yong Cong Sin --- scripts/checkpatch.pl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 57ca4a17749..b34c2ad31d2 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4164,13 +4164,15 @@ sub process { # check for new typedefs, only function parameters and sparse annotations # make sense. - if ($line =~ /\btypedef\s/ && - $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ && - $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ && - $line !~ /\b$typeTypedefs\b/ && - $line !~ /\b__bitwise\b/) { - WARN("NEW_TYPEDEFS", - "do not add new typedefs\n" . $herecurr); + if ($realfile =~ /\/include\/zephyr\/posix\/*.h/) { + if ($line =~ /\btypedef\s/ && + $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ && + $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ && + $line !~ /\b$typeTypedefs\b/ && + $line !~ /\b__bitwise\b/) { + WARN("NEW_TYPEDEFS", + "do not add new typedefs\n" . $herecurr); + } } # * goes on variable not on type