mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Add uninitialized_var to the declaration_macro list
       [not found] <9084ad9a17844ed898132853d161b495@DB3PR05MB380.eurprd05.prod.outlook.com>
@ 2014-08-04  7:56 ` Joe Perches
  2014-08-04 16:02   ` Joe Perches
  2014-08-04 23:55 ` [PATCH V2] checkpatch: Update $declaration_macros, add uninitialized_var Joe Perches
  1 sibling, 1 reply; 3+ messages in thread
From: Joe Perches @ 2014-08-04  7:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Dotan Barak, Andy Whitcroft, linux-kernel

Using uninitialized_var reports a false positive for
"Missing blank line after declarations".

Fix it by adding uninitialized_var to the $declaration_macros
exceptions list.

Move the macro list after $Type is declared.

Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Dotan Barak <dotanb@mellanox.com>
---
 scripts/checkpatch.pl | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index da74e65..99cce04 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -423,11 +423,6 @@ foreach my $entry (@mode_permission_funcs) {
 	$mode_perms_search .= $entry->[0];
 }
 
-our $declaration_macros = qr{(?x:
-	(?:$Storage\s+)?(?:DECLARE|DEFINE)_[A-Z]+\s*\(|
-	(?:$Storage\s+)?LIST_HEAD\s*\(
-)};
-
 our $allowed_asm_includes = qr{(?x:
 	irq|
 	memory
@@ -490,6 +485,12 @@ our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
 our $LvalOrFunc	= qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*};
 our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)};
 
+our $declaration_macros = qr{(?x:
+	(?:$Storage\s+)?(?:DECLARE|DEFINE)_[A-Z]+\s*\(|
+	(?:$Storage\s+)?LIST_HEAD\s*\(|
+	(?:$Storage\s+)?$Type\s+uninitialized_var\s*\(
+)};
+
 sub deparenthesize {
 	my ($string) = @_;
 	return "" if (!defined($string));



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

* Re: [PATCH] checkpatch: Add uninitialized_var to the declaration_macro list
  2014-08-04  7:56 ` [PATCH] checkpatch: Add uninitialized_var to the declaration_macro list Joe Perches
@ 2014-08-04 16:02   ` Joe Perches
  0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2014-08-04 16:02 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Dotan Barak, Andy Whitcroft, linux-kernel

On Mon, 2014-08-04 at 00:56 -0700, Joe Perches wrote:
> Using uninitialized_var reports a false positive for
> "Missing blank line after declarations".
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> +our $declaration_macros = qr{(?x:
> +	(?:$Storage\s+)?(?:DECLARE|DEFINE)_[A-Z]+\s*\(|

Hey Andrew.

Dotan showed some variants that could be added to this
line.  Do you want it rolled into a V2 of this patch
or as a separate patch?



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

* [PATCH V2] checkpatch: Update $declaration_macros, add uninitialized_var
       [not found] <9084ad9a17844ed898132853d161b495@DB3PR05MB380.eurprd05.prod.outlook.com>
  2014-08-04  7:56 ` [PATCH] checkpatch: Add uninitialized_var to the declaration_macro list Joe Perches
@ 2014-08-04 23:55 ` Joe Perches
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2014-08-04 23:55 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Dotan Barak, Andy Whitcroft, linux-kernel

Using uninitialized_var reports a false positive for
"Missing blank line after declarations".

Fix it by adding uninitialized_var to the $declaration_macros
exceptions list.

Move the macro list after $Type is declared.

Add optional prefixes to DECLARE_<FOO> and DEFINE_<BAR>
macro declarations to allow forms like:
	MLX4_DECLARE_DOORBELL_LOCK

Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Dotan Barak <dotanb@mellanox.com>
---
V2: Update the DECLARE and DEFINE macros to
    allow prefixed use and clarify postfixes

 scripts/checkpatch.pl | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index da74e65..31a731e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -423,11 +423,6 @@ foreach my $entry (@mode_permission_funcs) {
 	$mode_perms_search .= $entry->[0];
 }
 
-our $declaration_macros = qr{(?x:
-	(?:$Storage\s+)?(?:DECLARE|DEFINE)_[A-Z]+\s*\(|
-	(?:$Storage\s+)?LIST_HEAD\s*\(
-)};
-
 our $allowed_asm_includes = qr{(?x:
 	irq|
 	memory
@@ -490,6 +485,12 @@ our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
 our $LvalOrFunc	= qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*};
 our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)};
 
+our $declaration_macros = qr{(?x:
+	(?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(|
+	(?:$Storage\s+)?LIST_HEAD\s*\(|
+	(?:$Storage\s+)?${Type}\s+uninitialized_var\s*\(
+)};
+
 sub deparenthesize {
 	my ($string) = @_;
 	return "" if (!defined($string));



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

end of thread, other threads:[~2014-08-04 23:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <9084ad9a17844ed898132853d161b495@DB3PR05MB380.eurprd05.prod.outlook.com>
2014-08-04  7:56 ` [PATCH] checkpatch: Add uninitialized_var to the declaration_macro list Joe Perches
2014-08-04 16:02   ` Joe Perches
2014-08-04 23:55 ` [PATCH V2] checkpatch: Update $declaration_macros, add uninitialized_var Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®