diff mbox series

[RFC,v1,12/31] checkpatch: added support for struct MOCK(foo) syntax

Message ID 20181016235120.138227-13-brendanhiggins@google.com (mailing list archive)
State Superseded, archived
Headers show
Series kunit: Introducing KUnit, the Linux kernel unit testing framework | expand

Commit Message

Brendan Higgins Oct. 16, 2018, 11:51 p.m. UTC
This adds struct MOCK(foo) as a NonptrType so that it is recognized
correctly in declarations.

Signed-off-by: Brendan Higgins <brendanhiggins@google.com>
---
 scripts/checkpatch.pl | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Joe Perches Oct. 16, 2018, 11:59 p.m. UTC | #1
On Tue, 2018-10-16 at 16:51 -0700, Brendan Higgins wrote:
> This adds struct MOCK(foo) as a NonptrType so that it is recognized
> correctly in declarations.

I think this commit message is lacking context.


> Signed-off-by: Brendan Higgins <brendanhiggins@google.com>
> ---
>  scripts/checkpatch.pl | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 447857ffaf6be..9806f190796de 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -745,6 +745,10 @@ sub build_types {
>  			(?:
>  				(?:typeof|__typeof__)\s*\([^\)]*\)|
>  				(?:$typeTypedefs\b)|
> +				# Matching a \b breaks struct MOCK(foo) syntax,
> +				# so we need to have it not lumped in with the
> +				# types in @typeList.
> +				(?:struct\s+MOCK\($Ident\))|
>  				(?:${all}\b)
>  			)
>  			(?:\s+$Modifier|\s+const)*
Brendan Higgins Oct. 17, 2018, 12:03 a.m. UTC | #2
On Tue, Oct 16, 2018 at 4:59 PM Joe Perches <joe@perches.com> wrote:
>
> On Tue, 2018-10-16 at 16:51 -0700, Brendan Higgins wrote:
> > This adds struct MOCK(foo) as a NonptrType so that it is recognized
> > correctly in declarations.
>
> I think this commit message is lacking context.

Oh sorry, you are right. We added macros for generating mocks from
types, so we decided to name the generated mock types struct MOCK(foo)
(where the base type is struct foo); this commit makes checkpatch not
complain at this new syntax.
diff mbox series

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 447857ffaf6be..9806f190796de 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -745,6 +745,10 @@  sub build_types {
 			(?:
 				(?:typeof|__typeof__)\s*\([^\)]*\)|
 				(?:$typeTypedefs\b)|
+				# Matching a \b breaks struct MOCK(foo) syntax,
+				# so we need to have it not lumped in with the
+				# types in @typeList.
+				(?:struct\s+MOCK\($Ident\))|
 				(?:${all}\b)
 			)
 			(?:\s+$Modifier|\s+const)*