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

Aditya yashsri421 at gmail.com
Sat Nov 7 14:49:25 UTC 2020


On 7/11/20 5:47 pm, Aditya Srivastava wrote:
> Currently, when 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") we get 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.
> 
> Provide a fix by consuming first 70 chars of the corresponding line,
> then stop at the next whitespace, and substitute it with the consumed
> chars and a newline char.
> 
> Signed-off-by: Aditya Srivastava <yashsri421 at gmail.com>
> ---
>  scripts/checkpatch.pl | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 5a1096a4e220..ee665208ef02 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2881,8 +2881,11 @@ 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) {
> +				$fixed[$fixlinenr] =~ s/(.{70}[^\s]*)\s+/$1\n/g;
> +			}
>  			$commit_log_long_line = 1;
>  		}
>  
> 

Changes made in v2:
- Changing newline at whitespace instead of abrupt termination
- The special line cases such as 'Link', 'Fixes' or code addition
lines, etc. seem to be already excluded from this warning in the
if-block statements above the warning statement.


Thanks
Aditya


More information about the Linux-kernel-mentees mailing list