diff mbox

[1/2] checkpatch.pl: do not require kstrtoint

Message ID 1459178612-10830-1-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov March 28, 2016, 3:23 p.m. UTC
For one line sscanf checkpatch requires kernels kstrtoint
helper function. Comment this check out.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 scripts/checkpatch.pl | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

Comments

Mike Holmes March 28, 2016, 4:17 p.m. UTC | #1
On 28 March 2016 at 11:23, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> For one line sscanf checkpatch requires kernels kstrtoint

> helper function. Comment this check out.

>


I dont think we should patch check-patch, why is this not covered with the
.checkpatch.conf ?

I sent a patch for disabling this via the normal mechanism last year
"checkpatch.conf add SSCANF_TO_KSTRTO exception"


>

> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

> ---

>  scripts/checkpatch.pl | 38 +++++++++++++++++++-------------------

>  1 file changed, 19 insertions(+), 19 deletions(-)

>

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl

> index 16316b9..8882757 100755

> --- a/scripts/checkpatch.pl

> +++ b/scripts/checkpatch.pl

> @@ -5093,25 +5093,25 @@ sub process {

>                 }

>

>  # check for simple sscanf that should be kstrto<foo>

> -               if ($^V && $^V ge 5.10.0 &&

> -                   defined $stat &&

> -                   $line =~ /\bsscanf\b/) {

> -                       my $lc = $stat =~ tr@\n@@;

> -                       $lc = $lc + $linenr;

> -                       my $stat_real = raw_line($linenr, 0);

> -                       for (my $count = $linenr + 1; $count <= $lc;

> $count++) {

> -                               $stat_real = $stat_real . "\n" .

> raw_line($count, 0);

> -                       }

> -                       if ($stat_real =~

> /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) {

> -                               my $format = $6;

> -                               my $count = $format =~ tr@%@%@;

> -                               if ($count == 1 &&

> -                                   $format =~

> /^"\%(?i:ll[udxi]|[udxi]ll|ll|[hl]h?[udxi]|[udxi][hl]h?|[hl]h?|[udxi])"$/) {

> -                                       WARN("SSCANF_TO_KSTRTO",

> -                                            "Prefer kstrto<type> to

> single variable sscanf\n" . "$here\n$stat_real\n");

> -                               }

> -                       }

> -               }

> +#              if ($^V && $^V ge 5.10.0 &&

> +#                  defined $stat &&

> +#                  $line =~ /\bsscanf\b/) {

> +#                      my $lc = $stat =~ tr@\n@@;

> +#                      $lc = $lc + $linenr;

> +#                      my $stat_real = raw_line($linenr, 0);

> +#                      for (my $count = $linenr + 1; $count <= $lc;

> $count++) {

> +#                              $stat_real = $stat_real . "\n" .

> raw_line($count, 0);

> +#                      }

> +#                      if ($stat_real =~

> /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) {

> +#                              my $format = $6;

> +#                              my $count = $format =~ tr@%@%@;

> +#                              if ($count == 1 &&

> +#                                  $format =~

> /^"\%(?i:ll[udxi]|[udxi]ll|ll|[hl]h?[udxi]|[udxi][hl]h?|[hl]h?|[udxi])"$/) {

> +#                                      WARN("SSCANF_TO_KSTRTO",

> +#                                           "Prefer kstrto<type> to

> single variable sscanf\n" . "$here\n$stat_real\n");

> +#                              }

> +#                      }

> +#              }

>

>  # check for new externs in .h files.

>                 if ($realfile =~ /\.h$/ &&

> --

> 2.7.1.250.gff4ea60

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> https://lists.linaro.org/mailman/listinfo/lng-odp

>




-- 
Mike Holmes
Technical Manager - Linaro Networking Group
Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"
Maxim Uvarov March 28, 2016, 5:28 p.m. UTC | #2
Ok, Mike thanks, I merged that patch.

Please consider only v2 for review.

Maxim.

On 03/28/16 19:17, Mike Holmes wrote:
>
>
> On 28 March 2016 at 11:23, Maxim Uvarov <maxim.uvarov@linaro.org 
> <mailto:maxim.uvarov@linaro.org>> wrote:
>
>     For one line sscanf checkpatch requires kernels kstrtoint
>     helper function. Comment this check out.
>
>
> I dont think we should patch check-patch, why is this not covered with 
> the .checkpatch.conf ?
>
> I sent a patch for disabling this via the normal mechanism last year 
> "checkpatch.conf add SSCANF_TO_KSTRTO exception"
>
>
>     Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org
>     <mailto:maxim.uvarov@linaro.org>>
>     ---
>      scripts/checkpatch.pl <http://checkpatch.pl> | 38
>     +++++++++++++++++++-------------------
>      1 file changed, 19 insertions(+), 19 deletions(-)
>
>     diff --git a/scripts/checkpatch.pl <http://checkpatch.pl>
>     b/scripts/checkpatch.pl <http://checkpatch.pl>
>     index 16316b9..8882757 100755
>     --- a/scripts/checkpatch.pl <http://checkpatch.pl>
>     +++ b/scripts/checkpatch.pl <http://checkpatch.pl>
>     @@ -5093,25 +5093,25 @@ sub process {
>                     }
>
>      # check for simple sscanf that should be kstrto<foo>
>     -               if ($^V && $^V ge 5.10.0 &&
>     -                   defined $stat &&
>     -                   $line =~ /\bsscanf\b/) {
>     -                       my $lc = $stat =~ tr@\n@@;
>     -                       $lc = $lc + $linenr;
>     -                       my $stat_real = raw_line($linenr, 0);
>     -                       for (my $count = $linenr + 1; $count <=
>     $lc; $count++) {
>     -                               $stat_real = $stat_real . "\n" .
>     raw_line($count, 0);
>     -                       }
>     -                       if ($stat_real =~
>     /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) {
>     -                               my $format = $6;
>     -                               my $count = $format =~ tr@%@%@;
>     -                               if ($count == 1 &&
>     -                                   $format =~
>     /^"\%(?i:ll[udxi]|[udxi]ll|ll|[hl]h?[udxi]|[udxi][hl]h?|[hl]h?|[udxi])"$/)
>     {
>     -  WARN("SSCANF_TO_KSTRTO",
>     -                                            "Prefer kstrto<type>
>     to single variable sscanf\n" . "$here\n$stat_real\n");
>     -                               }
>     -                       }
>     -               }
>     +#              if ($^V && $^V ge 5.10.0 &&
>     +#                  defined $stat &&
>     +#                  $line =~ /\bsscanf\b/) {
>     +#                      my $lc = $stat =~ tr@\n@@;
>     +#                      $lc = $lc + $linenr;
>     +#                      my $stat_real = raw_line($linenr, 0);
>     +#                      for (my $count = $linenr + 1; $count <=
>     $lc; $count++) {
>     +#                              $stat_real = $stat_real . "\n" .
>     raw_line($count, 0);
>     +#                      }
>     +#                      if ($stat_real =~
>     /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) {
>     +#                              my $format = $6;
>     +#                              my $count = $format =~ tr@%@%@;
>     +#                              if ($count == 1 &&
>     +#                                  $format =~
>     /^"\%(?i:ll[udxi]|[udxi]ll|ll|[hl]h?[udxi]|[udxi][hl]h?|[hl]h?|[udxi])"$/)
>     {
>     +# WARN("SSCANF_TO_KSTRTO",
>     +#                                           "Prefer kstrto<type>
>     to single variable sscanf\n" . "$here\n$stat_real\n");
>     +#                              }
>     +#                      }
>     +#              }
>
>      # check for new externs in .h files.
>                     if ($realfile =~ /\.h$/ &&
>     --
>     2.7.1.250.gff4ea60
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> -- 
> Mike Holmes
> Technical Manager - Linaro Networking Group
> Linaro.org <http://www.linaro.org/>***│ *Open source software for ARM SoCs
> "Work should be fun and collaborative, the rest follows"
>
diff mbox

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 16316b9..8882757 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5093,25 +5093,25 @@  sub process {
 		}
 
 # check for simple sscanf that should be kstrto<foo>
-		if ($^V && $^V ge 5.10.0 &&
-		    defined $stat &&
-		    $line =~ /\bsscanf\b/) {
-			my $lc = $stat =~ tr@\n@@;
-			$lc = $lc + $linenr;
-			my $stat_real = raw_line($linenr, 0);
-		        for (my $count = $linenr + 1; $count <= $lc; $count++) {
-				$stat_real = $stat_real . "\n" . raw_line($count, 0);
-			}
-			if ($stat_real =~ /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) {
-				my $format = $6;
-				my $count = $format =~ tr@%@%@;
-				if ($count == 1 &&
-				    $format =~ /^"\%(?i:ll[udxi]|[udxi]ll|ll|[hl]h?[udxi]|[udxi][hl]h?|[hl]h?|[udxi])"$/) {
-					WARN("SSCANF_TO_KSTRTO",
-					     "Prefer kstrto<type> to single variable sscanf\n" . "$here\n$stat_real\n");
-				}
-			}
-		}
+#		if ($^V && $^V ge 5.10.0 &&
+#		    defined $stat &&
+#		    $line =~ /\bsscanf\b/) {
+#			my $lc = $stat =~ tr@\n@@;
+#			$lc = $lc + $linenr;
+#			my $stat_real = raw_line($linenr, 0);
+#		        for (my $count = $linenr + 1; $count <= $lc; $count++) {
+#				$stat_real = $stat_real . "\n" . raw_line($count, 0);
+#			}
+#			if ($stat_real =~ /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) {
+#				my $format = $6;
+#				my $count = $format =~ tr@%@%@;
+#				if ($count == 1 &&
+#				    $format =~ /^"\%(?i:ll[udxi]|[udxi]ll|ll|[hl]h?[udxi]|[udxi][hl]h?|[hl]h?|[udxi])"$/) {
+#					WARN("SSCANF_TO_KSTRTO",
+#					     "Prefer kstrto<type> to single variable sscanf\n" . "$here\n$stat_real\n");
+#				}
+#			}
+#		}
 
 # check for new externs in .h files.
 		if ($realfile =~ /\.h$/ &&