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

Lukas Bulwahn lukas.bulwahn at gmail.com
Sat Nov 7 18:43:18 UTC 2020


On Sa., 7. Nov. 2020 at 15:49, Aditya <yashsri421 at gmail.com> wrote:

> 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;
> >               }
> >
> >
>

Why do you not implement a proper word wrap function?

A single commit tells us very little if this rule in checkpatch.pl really
is a good rule or not. A proper evaluation of typical cases of long commit
lines would help much more to improve this rule.

Lukas


> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/linux-kernel-mentees/attachments/20201107/ee3572fb/attachment-0001.html>


More information about the Linux-kernel-mentees mailing list