]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc: fix code quality findings
authorViktor Szakats <commit@vsz.me>
Thu, 23 Apr 2026 23:24:32 +0000 (01:24 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 24 Apr 2026 07:46:35 +0000 (09:46 +0200)
- fix counting errors. Update test1185 results accordingly.
- fix an error message.
- tidy up regexp syntax.

Pointed out by GitHub Code Quality

Closes #21429

scripts/checksrc.pl
tests/data/test1185

index 6c900dae1b14aee532f6944ab0f969f2e3b17f3b..6569c83bc061552a28869110ce85073c3c5fda75 100755 (executable)
@@ -273,8 +273,8 @@ sub readlocalfile {
 sub checkwarn {
     my ($name, $num, $col, $file, $line, $msg, $error) = @_;
 
-    my $w=$error ? "error" : "warning";
-    my $nowarn=0;
+    my $w = $error ? "error" : "warning";
+    my $nowarn = 0;
 
     #if(!$warnings{$name}) {
     #    print STDERR "Dev! there is no description for $name!\n";
@@ -297,20 +297,20 @@ sub checkwarn {
 
     if($nowarn) {
         $suppressed++;
-        if($w) {
-            $swarnings++;
+        if($error) {
+            $serrors++;
         }
         else {
-            $serrors++;
+            $swarnings++;
         }
         return;
     }
 
-    if($w) {
-        $warnings++;
+    if($error) {
+        $errors++;
     }
     else {
-        $errors++;
+        $warnings++;
     }
 
     $col++;
@@ -414,7 +414,7 @@ readlocalfile($file);
 do {
     if($wlist !~ / $file /) {
         my $fullname = $file;
-        $fullname = "$dir/$file" if($fullname !~ '^\.?\.?/');
+        $fullname = "$dir/$file" if($fullname !~ /^\.?\.?\//);
         scanfile($fullname);
     }
     $file = shift @ARGV;
@@ -443,7 +443,7 @@ sub checksrc_endoffile {
     for(keys %ignore_set) {
         if($ignore_set{$_} && !$ignore_used{$_}) {
             checkwarn("UNUSEDIGNORE", $ignore_set{$_},
-                      length($_)+11, $file,
+                      length($_) + 11, $file,
                       $ignore_line[$ignore_set{$_}],
                       "Unused ignore: $_");
         }
@@ -610,7 +610,7 @@ sub scanfile {
         if($l =~ /^(.*)\w\*\//) {
             checkwarn("COMMENTNOSPACEEND",
                       $line, length($1) + 1, $file, $l,
-                      "Missing space end comment end");
+                      "Missing space before comment end");
         }
 
         if($l =~ /(.*)(FIXME|TODO)/) {
index a24548c9a08899698e3a5a6afd80a2d622f48008..0bbc85900dbd7a74405a60ffff8482dd0a1f3106 100644 (file)
@@ -233,7 +233,7 @@ void startfunc(int a, int b) {
 ./%LOGDIR/code1185.c:1:1: error: Missing closing comment (OPENCOMMENT)
 %SP
  ^
-checksrc: 0 errors and 45 warnings
+checksrc: 3 errors and 42 warnings
 </stdout>
 <errorcode>
 5