]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc: handle zero scoped ignore commands
authorDaniel Gustafsson <daniel@yesql.se>
Fri, 5 Oct 2018 11:33:21 +0000 (13:33 +0200)
committerDaniel Gustafsson <daniel@yesql.se>
Fri, 5 Oct 2018 11:33:21 +0000 (13:33 +0200)
If a !checksrc! disable command specified to ignore zero errors, it was
still added to the ignore block even though nothing was ignored. While
there were no blocks ignored that shouldn't be ignored, the processing
ended with with a warning:

<filename>:<line>:<col>: warning: Unused ignore: LONGLINE (UNUSEDIGNORE)
 /* !checksrc! disable LONGLINE 0 */
                    ^
Fix by instead treating a zero ignore as a a badcommand and throw a
warning for that one.

Closes #3096
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
lib/checksrc.pl

index 1af6bbd72972369b68839d896f9ef34466663d64..15e9aff8ee1635e181f8b645961915ead7200801 100755 (executable)
@@ -249,7 +249,16 @@ sub checksrc {
                 $scope=999999;
             }
 
-            if($ignore_set{$warn}) {
+            # Comparing for a literal zero rather than the scalar value zero
+            # covers the case where $scope contains the ending '*' from the
+            # comment. If we use a scalar comparison (==) we induce warnings
+            # on non-scalar contents.
+            if($scope eq "0") {
+                checkwarn("BADCOMMAND",
+                          $line, 0, $file, $l,
+                          "Disable zero not supported, did you mean to enable?");
+            }
+            elsif($ignore_set{$warn}) {
                 checkwarn("BADCOMMAND",
                           $line, 0, $file, $l,
                           "$warn already disabled from line $ignore_set{$warn}");