mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] checkpatch: fix USLEEP_RANGE test
@ 2013-01-30 19:15 Bruce Allan
  2013-01-31  4:55 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Bruce Allan @ 2013-01-30 19:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andy Whitcroft

Do not test udelay() for a value less than 10usec when passed a variable
instead of a hard-coded number; there is no way for checkpatch to know the
value of the variable.  As it is today, it will complain about variables
with alphanumeric characters plus '_', e.g. foo_bar, but not variables with
other characters, eg. foo->bar.

Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Cc: Andy Whitcroft <apw@canonical.com>
---
 scripts/checkpatch.pl |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4d2c7df..adfb2f6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3237,9 +3237,9 @@ sub process {
 		}
 
 # prefer usleep_range over udelay
-		if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) {
+		if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
 			# ignore udelay's < 10, however
-			if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) {
+			if (! ($1 < 10) ) {
 				CHK("USLEEP_RANGE",
 				    "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line);
 			}


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

* Re: [PATCH] checkpatch: fix USLEEP_RANGE test
  2013-01-30 19:15 [PATCH] checkpatch: fix USLEEP_RANGE test Bruce Allan
@ 2013-01-31  4:55 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2013-01-31  4:55 UTC (permalink / raw)
  To: Bruce Allan, Andrew Morton; +Cc: linux-kernel, Andy Whitcroft

On Wed, 2013-01-30 at 11:15 -0800, Bruce Allan wrote:
> Do not test udelay() for a value less than 10usec when passed a variable
> instead of a hard-coded number;
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3237,9 +3237,9 @@ sub process {
[]
>  # prefer usleep_range over udelay
> -		if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) {
> +		if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
>  			# ignore udelay's < 10, however
> -			if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) {
> +			if (! ($1 < 10) ) {
>  				CHK("USLEEP_RANGE",
>  				    "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line);
>  			}

Thanks Bruce.

Just a trivial comment:

Maybe this would be a little neater as

		if ($line =~ \budelay\s*\(\s*(\d+)\s*\) &&
		    $1 >= 10) {
			CHK(etc...)
		}

No worries though.


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

end of thread, other threads:[~2013-01-31  4:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-30 19:15 [PATCH] checkpatch: fix USLEEP_RANGE test Bruce Allan
2013-01-31  4:55 ` 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®