Skip to contentSkip to conversation

checkpatch: Supress warning in function pointer typedefs

PATCH In review Vinzenz 'evilissimo' Feenstra 2 participants 3 messages Mar 21, 2017 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: Supress warning in function pointer typedefs

From: Vinzenz Feenstra <[email protected]>

When importing dynamically functions via GetProcAddress in windows related code, it is quite common to make a typedef for the resulting function pointer. When the function to be imported, has a stdcall calling convention, usually the WINAPI macro is used. This patch adds an exception in the checkpatch.pl script to allow the calling convention specification in function pointer typedefs, to be WINAPI.

---
 scripts/checkpatch.pl | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +8 -1
index f084542..33bf585 100755
@@ -1774,7 +1774,14 @@ sub process {
 			# likely a typedef for a function.
 			} elsif ($ctx =~ /$Type$/) {
 
-			} else {
+            # If this is a typedef we need to allow WINAPI as a calling
+            # convention. Even though there should be only one space around the
+            # star, we allow none or any, to suppress the following warning.
+            # The check for the number of spaces around the star is checked
+            # elsewhere.
+			} elsif($ctx =~ /^\s*typedef\s+$Type\(WINAPI\s*\*\s*$Ident\)/) {
+
+            } else {
 				ERROR("space prohibited between function name and open parenthesis '('\n" . $herecurr);
 			}
 		}
Signature · 1 line
2.9.3
#1 lore raw
Quoted 10 lines · Vinzenz 'evilissimo' Feenstra

From: Vinzenz Feenstra <[email protected]>

When importing dynamically functions via GetProcAddress in windows related code, it is quite common to make a typedef for the resulting function pointer. When the function to be imported, has a stdcall calling convention, usually the WINAPI macro is used. This patch adds an exception in the checkpatch.pl script to allow the calling convention specification in function pointer typedefs, to be WINAPI.

Could you provide an example of the kind of source line that provokes the incorrect warning and the checkpatch output that results, please?

thanks
-- PMM

#2 lore raw
Quoted 14 lines · Peter Maydell
Quoted 9 lines · Vinzenz 'evilissimo' Feenstra

From: Vinzenz Feenstra <[email protected]>

When importing dynamically functions via GetProcAddress in windows related code, it is quite common to make a typedef for the resulting function pointer. When the function to be imported, has a stdcall calling convention, usually the WINAPI macro is used. This patch adds an exception in the checkpatch.pl script to allow the calling convention specification in function pointer typedefs, to be WINAPI.

Quoted 5 lines
Quoted 1 line

Could you provide an example of the kind of source line that provokes the incorrect warning and the checkpatch output that results, please?

Hmm I just realize that it is working now, but I figured out now what is the real problem and that my patch is wrong. Please discard this patch and thanks for making me think again :-)

Quoted 3 lines

thanks
-- PMM