scripts: kernel-doc: Disambiguate origin of warnings

Message ID 20231215001535.work.434-kees@kernel.org
State New
Headers
Series scripts: kernel-doc: Disambiguate origin of warnings |

Commit Message

Kees Cook Dec. 15, 2023, 12:15 a.m. UTC
  There's no prefix to warnings and errors reported by scripts/kernel-doc
which makes it frustrating to isolate errors reported from CI systems.
Add a "$0: " prefix to all the STDERR output.

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 scripts/kernel-doc | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
  

Comments

Randy Dunlap Dec. 15, 2023, 12:19 a.m. UTC | #1
On 12/14/23 16:15, Kees Cook wrote:
> There's no prefix to warnings and errors reported by scripts/kernel-doc
> which makes it frustrating to isolate errors reported from CI systems.
> Add a "$0: " prefix to all the STDERR output.
> 
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: linux-doc@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Matthew's reply to my patch with similar functionality, which I agree with:

https://lore.kernel.org/linux-doc/ZQke26HX9Am3k2sh@casper.infradead.org/

> ---
>  scripts/kernel-doc | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index 41f838042364..2a7b975b03e7 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -450,7 +450,7 @@ sub print_lineno {
>  sub emit_warning {
>      my $location = shift;
>      my $msg = shift;
> -    print STDERR "$location: warning: $msg";
> +    print STDERR "$0: $location: warning: $msg";
>      ++$warnings;
>  }
>  ##
> @@ -1292,7 +1292,7 @@ sub dump_struct($$) {
>  			   });
>      }
>      else {
> -	print STDERR "${file}:$.: error: Cannot parse struct or union!\n";
> +	print STDERR "$0: ${file}:$.: error: Cannot parse struct or union!\n";
>  	++$errors;
>      }
>  }
> @@ -1398,7 +1398,7 @@ sub dump_enum($$) {
>  			    'purpose' => $declaration_purpose
>  			   });
>      } else {
> -	print STDERR "${file}:$.: error: Cannot parse enum!\n";
> +	print STDERR "$0: ${file}:$.: error: Cannot parse enum!\n";
>  	++$errors;
>      }
>  }
> @@ -1469,7 +1469,7 @@ sub dump_typedef($$) {
>  			   });
>      }
>      else {
> -	print STDERR "${file}:$.: error: Cannot parse typedef!\n";
> +	print STDERR "$0: ${file}:$.: error: Cannot parse typedef!\n";
>  	++$errors;
>      }
>  }
> @@ -1993,7 +1993,7 @@ sub process_export_file($) {
>      my $file = map_filename($orig_file);
>  
>      if (!open(IN,"<$file")) {
> -	print STDERR "Error: Cannot open file $file\n";
> +	print STDERR "$0: Error: Cannot open file $file\n";
>  	++$errors;
>  	return;
>      }
> @@ -2102,7 +2102,7 @@ sub process_name($$) {
>  	}
>  
>  	if ($verbose) {
> -	    print STDERR "${file}:$.: info: Scanning doc for $decl_type $identifier\n";
> +	    print STDERR "$0: ${file}:$.: info: Scanning doc for $decl_type $identifier\n";
>  	}
>      } else {
>  	emit_warning("${file}:$.", "Cannot understand $_ on line $. - I thought it was a doc line\n");
> @@ -2320,7 +2320,7 @@ sub process_file($) {
>      $file = map_filename($orig_file);
>  
>      if (!open(IN_FILE,"<$file")) {
> -	print STDERR "Error: Cannot open file $file\n";
> +	print STDERR "$0: Error: Cannot open file $file\n";
>  	++$errors;
>  	return;
>      }
> @@ -2410,14 +2410,14 @@ foreach (@ARGV) {
>      process_file($_);
>  }
>  if ($verbose && $errors) {
> -  print STDERR "$errors errors\n";
> +  print STDERR "$0: $errors errors\n";
>  }
>  if ($verbose && $warnings) {
> -  print STDERR "$warnings warnings\n";
> +  print STDERR "$0: $warnings warnings\n";
>  }
>  
>  if ($Werror && $warnings) {
> -    print STDERR "$warnings warnings as Errors\n";
> +    print STDERR "$0: $warnings warnings as Errors\n";
>      exit($warnings);
>  } else {
>      exit($output_mode eq "none" ? 0 : $errors)
  
Kees Cook Dec. 15, 2023, 1 a.m. UTC | #2
On Thu, Dec 14, 2023 at 04:19:34PM -0800, Randy Dunlap wrote:
> 
> 
> On 12/14/23 16:15, Kees Cook wrote:
> > There's no prefix to warnings and errors reported by scripts/kernel-doc
> > which makes it frustrating to isolate errors reported from CI systems.
> > Add a "$0: " prefix to all the STDERR output.
> > 
> > Cc: Jonathan Corbet <corbet@lwn.net>
> > Cc: linux-doc@vger.kernel.org
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> 
> Matthew's reply to my patch with similar functionality, which I agree with:
> 
> https://lore.kernel.org/linux-doc/ZQke26HX9Am3k2sh@casper.infradead.org/

I guess that's true, but it's really confusing to figure out if it's
kernel-doc or Sphinx reporting errors. Ah well! I can live without it.

-Kees
  

Patch

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 41f838042364..2a7b975b03e7 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -450,7 +450,7 @@  sub print_lineno {
 sub emit_warning {
     my $location = shift;
     my $msg = shift;
-    print STDERR "$location: warning: $msg";
+    print STDERR "$0: $location: warning: $msg";
     ++$warnings;
 }
 ##
@@ -1292,7 +1292,7 @@  sub dump_struct($$) {
 			   });
     }
     else {
-	print STDERR "${file}:$.: error: Cannot parse struct or union!\n";
+	print STDERR "$0: ${file}:$.: error: Cannot parse struct or union!\n";
 	++$errors;
     }
 }
@@ -1398,7 +1398,7 @@  sub dump_enum($$) {
 			    'purpose' => $declaration_purpose
 			   });
     } else {
-	print STDERR "${file}:$.: error: Cannot parse enum!\n";
+	print STDERR "$0: ${file}:$.: error: Cannot parse enum!\n";
 	++$errors;
     }
 }
@@ -1469,7 +1469,7 @@  sub dump_typedef($$) {
 			   });
     }
     else {
-	print STDERR "${file}:$.: error: Cannot parse typedef!\n";
+	print STDERR "$0: ${file}:$.: error: Cannot parse typedef!\n";
 	++$errors;
     }
 }
@@ -1993,7 +1993,7 @@  sub process_export_file($) {
     my $file = map_filename($orig_file);
 
     if (!open(IN,"<$file")) {
-	print STDERR "Error: Cannot open file $file\n";
+	print STDERR "$0: Error: Cannot open file $file\n";
 	++$errors;
 	return;
     }
@@ -2102,7 +2102,7 @@  sub process_name($$) {
 	}
 
 	if ($verbose) {
-	    print STDERR "${file}:$.: info: Scanning doc for $decl_type $identifier\n";
+	    print STDERR "$0: ${file}:$.: info: Scanning doc for $decl_type $identifier\n";
 	}
     } else {
 	emit_warning("${file}:$.", "Cannot understand $_ on line $. - I thought it was a doc line\n");
@@ -2320,7 +2320,7 @@  sub process_file($) {
     $file = map_filename($orig_file);
 
     if (!open(IN_FILE,"<$file")) {
-	print STDERR "Error: Cannot open file $file\n";
+	print STDERR "$0: Error: Cannot open file $file\n";
 	++$errors;
 	return;
     }
@@ -2410,14 +2410,14 @@  foreach (@ARGV) {
     process_file($_);
 }
 if ($verbose && $errors) {
-  print STDERR "$errors errors\n";
+  print STDERR "$0: $errors errors\n";
 }
 if ($verbose && $warnings) {
-  print STDERR "$warnings warnings\n";
+  print STDERR "$0: $warnings warnings\n";
 }
 
 if ($Werror && $warnings) {
-    print STDERR "$warnings warnings as Errors\n";
+    print STDERR "$0: $warnings warnings as Errors\n";
     exit($warnings);
 } else {
     exit($output_mode eq "none" ? 0 : $errors)