[Linux-kernel-mentees] [PATCH] checkpatch: add fix option for NETWORKING_BLOCK_COMMENT_STYLE

Aditya yashsri421 at gmail.com
Wed Nov 18 17:13:50 UTC 2020


On 18/11/20 10:39 pm, Aditya Srivastava wrote:
> Currently, checkpatch warns us if we use an empty '/*' line for comment
> and contents of the comment are in next line.
> 
> E.g., running checkpatch on commit 0d52497ac8ee ("iwlwifi: pcie: remove
> the refs / unrefs from the transport") reports this warning:
> 
> WARNING: networking block comments don't use an empty /* line, use /* Comment...
> +		/*
> +		 * If the TXQ is active, then set the timer, if not,
> 
> Provide a fix by appending the current line contents to previous line
> and deleting the current line
> 
> Signed-off-by: Aditya Srivastava <yashsri421 at gmail.com>
> ---
>  scripts/checkpatch.pl | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index f61ac7456151..90e863d63097 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3629,8 +3629,14 @@ sub process {
>  		    $prevrawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
>  		    $rawline =~ /^\+[ \t]*\*/ &&
>  		    $realline > 3) { # Do not warn about the initial copyright comment block after SPDX-License-Identifier
> -			WARN("NETWORKING_BLOCK_COMMENT_STYLE",
> -			     "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
> +			if (WARN("NETWORKING_BLOCK_COMMENT_STYLE",
> +				 "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev) &&\
> +			    $fix) {
> +				if ($rawline =~ /^\+[ \t]*\*\s*(.*)/) {
> +					fix_delete_line($fixlinenr, $rawline);
> +					$fixed[$fixlinenr - 1] .= " $1";
> +				}
> +			}
>  		}
>  
>  # Block comments use * on subsequent lines
> 

I have generated the warnings occurring for this class of warnings
(over 4.13..5.8):
https://github.com/AdityaSrivast/kernel-tasks/blob/master/random/networking_block_comments/warnings.txt

My initial tests at these warnings found the fix to be working fine.


Thanks
Aditya


More information about the Linux-kernel-mentees mailing list