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

Aditya yashsri421 at gmail.com
Sun Nov 1 11:04:05 UTC 2020


On 31/10/20 6:55 pm, Aditya Srivastava wrote:
> Currently, if a line exceeds 75 characters in a commit message,
> checkpatch.pl gives a warning corresponding to the same.
> 
> E.g., running checkpatch on commit a1af2afbd244 ("drm/nouveau/volt:Fix
> for some cards having 0 maximum voltage") reports this warning:
> 
> WARNING: Possible unwrapped commit description (prefer a maximum 75
> chars per line)
> 
> Some, mostly Fermi, vbioses appear to have zero max voltage. That causes Nouveau to not parse voltage entries, thus users not being able to set higher clocks.
> 
> Fix this warning by truncating the line after 75 chars, and push the
> remaining content to the next line
> 
> Signed-off-by: Aditya Srivastava <yashsri421 at gmail.com>
> ---
>  scripts/checkpatch.pl | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 5329927fc1c1..a0107ed257d1 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2881,8 +2881,20 @@ sub process {
>  		      $line =~ /^\s*(?:Fixes:|Link:)/i ||
>  					# A Fixes: or Link: line
>  		      $commit_log_possible_stack_dump)) {
> -			WARN("COMMIT_LOG_LONG_LINE",
> -			     "Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr);
> +			if (WARN("COMMIT_LOG_LONG_LINE",
> +			     	 "Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr) &&
> +			    $fix) {
> +				fix_delete_line($fixlinenr, $rawline);
> +				my $curr_line = $rawline;
> +				my $fixedline;
> +				while (length($curr_line) > 0) {
> +					# trim current line for any unnecessary spaces
> +					$curr_line = trim($curr_line);
> +					$fixedline = substr($curr_line, 0, 75);
> +					fix_insert_line($fixlinenr+1, $fixedline);
> +					$curr_line =~ s/$fixedline//;
> +				}
> +			}
>  			$commit_log_long_line = 1;
>  		}
>  
> 

Hi Sir
Seeking your feedback on this one

Thanks
Aditya


More information about the Linux-kernel-mentees mailing list