linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkpatch: debugfs_remove() can take NULL
@ 2012-11-17 12:33 Constantine Shulyupin
  2012-11-17 13:30 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Constantine Shulyupin @ 2012-11-17 12:33 UTC (permalink / raw)
  To: linux-kernel, gregkh, Andy Whitcroft; +Cc: Constantine Shulyupin

From: Constantine Shulyupin <const@MakeLinux.com>

debugfs_remove() can take a NULL, so let's check and warn about that.

Signed-off-by: Constantine Shulyupin <const@MakeLinux.com>
---
 scripts/checkpatch.pl |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f18750e..c062476 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3221,6 +3221,14 @@ sub process {
 				     "kfree(NULL) is safe this check is probably not required\n" . $hereprev);
 			}
 		}
+# check for needless debugfs_remove() checks
+		if ($prevline =~ /\bif\s*\(([^\)]*)\)/) {
+			my $expr = $1;
+			if ($line =~ /\bdebugfs_remove\(\Q$expr\E\);/) {
+				WARN("NEEDLESS_DEBUGFS_REMOVE",
+				     "debugfs_remove(NULL) is safe this check is probably not required\n" . $hereprev);
+			}
+		}
 # check for needless usb_free_urb() checks
 		if ($prevline =~ /\bif\s*\(([^\)]*)\)/) {
 			my $expr = $1;
-- 
1.7.9.5


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

* Re: [PATCH] checkpatch: debugfs_remove() can take NULL
  2012-11-17 12:33 [PATCH] checkpatch: debugfs_remove() can take NULL Constantine Shulyupin
@ 2012-11-17 13:30 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2012-11-17 13:30 UTC (permalink / raw)
  To: Constantine Shulyupin; +Cc: linux-kernel, gregkh, Andy Whitcroft

On Sat, 2012-11-17 at 14:33 +0200, Constantine Shulyupin wrote:
> From: Constantine Shulyupin <const@MakeLinux.com>
> 
> debugfs_remove() can take a NULL, so let's check and warn about that.
> 
> Signed-off-by: Constantine Shulyupin <const@MakeLinux.com>
> ---
>  scripts/checkpatch.pl |    8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index f18750e..c062476 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3221,6 +3221,14 @@ sub process {
>  				     "kfree(NULL) is safe this check is probably not required\n" . $hereprev);
>  			}
>  		}
> +# check for needless debugfs_remove() checks
> +		if ($prevline =~ /\bif\s*\(([^\)]*)\)/) {
> +			my $expr = $1;
> +			if ($line =~ /\bdebugfs_remove\(\Q$expr\E\);/) {
> +				WARN("NEEDLESS_DEBUGFS_REMOVE",
> +				     "debugfs_remove(NULL) is safe this check is probably not required\n" . $hereprev);
> +			}
> +		}
>  # check for needless usb_free_urb() checks
>  		if ($prevline =~ /\bif\s*\(([^\)]*)\)/) {
>  			my $expr = $1;

Perhaps debugfs_remove_recursive should be added too.

Please create a consolidated block of tests for these
checks of:

	if (foo)
		something_with(foo)

and add kfree, usb_free_urb and your debugfs_remove (and
debugfs_remove_recursive?) to that block so that the
"if ($prevline..." test is done only once per patch line.




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

end of thread, other threads:[~2012-11-17 13:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-17 12:33 [PATCH] checkpatch: debugfs_remove() can take NULL Constantine Shulyupin
2012-11-17 13:30 ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).