All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] checkpatch: Supress warning in function pointer typedefs
@ 2017-03-16 11:14 Vinzenz 'evilissimo' Feenstra
  2017-03-21 12:37 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Vinzenz 'evilissimo' Feenstra @ 2017-03-16 11:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, qemu-trivial, Vinzenz Feenstra

From: Vinzenz Feenstra <vfeenstr@redhat.com>

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`.

Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com>
---
 scripts/checkpatch.pl | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f084542..33bf585 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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);
 			}
 		}
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] checkpatch: Supress warning in function pointer typedefs
  2017-03-16 11:14 [Qemu-devel] [PATCH] checkpatch: Supress warning in function pointer typedefs Vinzenz 'evilissimo' Feenstra
@ 2017-03-21 12:37 ` Peter Maydell
  2017-03-21 13:01   ` Vinzenz Feenstra
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2017-03-21 12:37 UTC (permalink / raw)
  To: Vinzenz 'evilissimo' Feenstra
  Cc: QEMU Developers, QEMU Trivial, Paolo Bonzini

On 16 March 2017 at 11:14, Vinzenz 'evilissimo' Feenstra
<vfeenstr@redhat.com> wrote:
> From: Vinzenz Feenstra <vfeenstr@redhat.com>
>
> 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`.
>
> Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] checkpatch: Supress warning in function pointer typedefs
  2017-03-21 12:37 ` Peter Maydell
@ 2017-03-21 13:01   ` Vinzenz Feenstra
  0 siblings, 0 replies; 3+ messages in thread
From: Vinzenz Feenstra @ 2017-03-21 13:01 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, QEMU Trivial, Paolo Bonzini


> On Mar 21, 2017, at 1:37 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> 
> On 16 March 2017 at 11:14, Vinzenz 'evilissimo' Feenstra
> <vfeenstr@redhat.com> wrote:
>> From: Vinzenz Feenstra <vfeenstr@redhat.com>
>> 
>> 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`.
>> 
>> Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com>
> 
> 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 :-)

> 
> thanks
> -- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-21 13:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16 11:14 [Qemu-devel] [PATCH] checkpatch: Supress warning in function pointer typedefs Vinzenz 'evilissimo' Feenstra
2017-03-21 12:37 ` Peter Maydell
2017-03-21 13:01   ` Vinzenz Feenstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.