[Linux-kernel-mentees] [PATCH] checkpatch: ignore files not following NETWORKING_BLOCK_COMMENT_STYLE

Aditya yashsri421 at gmail.com
Sun Dec 20 18:54:37 UTC 2020


On 21/12/20 12:03 am, Aditya Srivastava wrote:
> Currently checkpatch.pl gives warning for NETWORKING_BLOCK_COMMENT_STYLE
> for files in net/ and drivers/net which do not follow the networking
> comment style.
> But some of these files seem to follow the generic comment style instead
> of networking style and some rather mixed style of comment.
> 
> For e.g., drivers/net/wireless/ralink/rt2x00 largely follows generic
> kernel comment style in spite of being inside drivers/net.
> 
> Provide an ignore file(".networking_block_comment_styles.ignore"), where
> users can add the files they want to ignore this warning.
> 
> Signed-off-by: Aditya Srivastava <yashsri421 at gmail.com>
> ---
>  .gitignore                              |  1 +
>  .networking_block_comment_styles.ignore |  1 +
>  scripts/checkpatch.pl                   | 25 ++++++++++++++++++++++++-
>  3 files changed, 26 insertions(+), 1 deletion(-)
>  create mode 100644 .networking_block_comment_styles.ignore
> 
> diff --git a/.gitignore b/.gitignore
> index d01cda8e1177..3cd6074d1fb0 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -94,6 +94,7 @@ modules.order
>  !.gitattributes
>  !.gitignore
>  !.mailmap
> +!.networking_block_comment_styles.ignore
>  
>  #
>  # Generated include files
> diff --git a/.networking_block_comment_styles.ignore b/.networking_block_comment_styles.ignore
> new file mode 100644
> index 000000000000..2022dd619901
> --- /dev/null
> +++ b/.networking_block_comment_styles.ignore
> @@ -0,0 +1 @@
> +drivers/net/wireless/ralink/rt2x00
> \ No newline at end of file
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 00085308ed9d..875e572df5dc 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -832,6 +832,28 @@ sub read_words {
>  	return 0;
>  }
>  
> +my @files_ignoring_networking_comment;
> +my $ignore_file = which_conf(".networking_block_comment_styles.ignore");
> +if(-f $ignore_file) {
> +	open(my $ignore, '<', "$ignore_file")
> +	    or warn "$P: Can't find a readable .networking_block_comment_styles.ignore file $!\n";
> +	while(<$ignore>) {
> +		my $line = "$_";
> +		$line = trim($line);
> +		next if ($line =~ /^\s*$/);
> +		push(@files_ignoring_networking_comment, $line);
> +	}
> +	close($ignore);
> +}
> +
> +sub ignore_networking_comment_style {
> +	my ($realfile) = "@_";
> +	foreach my $file (@files_ignoring_networking_comment) {
> +		return 1 if ($realfile =~ m@^$file@);
> +	}
> +	return 0;
> +}
> +
>  my $const_structs;
>  if (show_type("CONST_STRUCT")) {
>  	read_words(\$const_structs, $conststructsfile)
> @@ -3701,7 +3723,8 @@ sub process {
>  		if ($realfile =~ m@^(drivers/net/|net/)@ &&
>  		    $prevrawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
>  		    $rawline =~ /^\+[ \t]*\*/ &&
> -		    $realline > 3) { # Do not warn about the initial copyright comment block after SPDX-License-Identifier
> +		    $realline > 3 &&  # Do not warn about the initial copyright comment block after SPDX-License-Identifier
> +		    !ignore_networking_comment_style($realfile)) {
>  			WARN("NETWORKING_BLOCK_COMMENT_STYLE",
>  			     "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
>  		}
> 

Hi Lukas
I have made this patch as I last proposed for how certain files can
avoid this warning by adding in a common .ignore file.

For the start, I have added only one directory name ie,
"drivers/net/wireless/ralink/rt2x00".

In this time, I also found out that users can also use --ignore
NETWORKING_BLOCK_COMMENT_STYLE with checkpatch and it will also result
in ignoring this style.
I don't know though which way is more preferred for the MAINTAINERS.

What do you think?

Thanks
Aditya


More information about the Linux-kernel-mentees mailing list