[Linux-kernel-mentees] Alternative to checkpatch fix options

Dwaipayan Ray dwaipayanray1 at gmail.com
Mon Nov 23 13:18:19 UTC 2020


On Mon, Nov 23, 2020 at 5:37 PM Lukas Bulwahn <lukas.bulwahn at gmail.com> wrote:
>
> On Mon, Nov 23, 2020 at 12:48 PM Joe Perches <joe at perches.com> wrote:
> >
> > On Mon, 2020-11-23 at 10:33 +0100, Lukas Bulwahn wrote:
> > > Dear Aditya and Dwaipayan,
> > >
> > > For creating fix options to checkpatch rules, please note that:
> > []
> > > it simply might be easier to invoke
> > > clang-format with a limited rule set for specific formatting fixes
> > > rather than trying to implement all of those syntactic fixes in
> > > checkpatch itself.
> > >
> > > Aditya, Dwaipayan, can you please consider that option and investigate
> > > the clang-format capability to do the fix before implementing that in
> > > checkpatch?
> >
> > Which could be extremely cool if clang-format works on patch contexts.
> > But as far as I know it does not.  clang-format-diff does.
> >
>
> I used the term "clang-format" in my mail as the overall term for
> "clang-format" and "clang-format-diff".
>
> > What maybe could happen is integration with checkpatch and the actual
> > application of the patch to a temporary file and then using
> > clang-format on the modified block similar to the integration of
> > clang-format and vim or emacs with selected contexts.
> >
> > Maybe the integration of clang-format-diff could be done, but my
> > reading of its help file seems to show the newly added line needs to
> > be extracted without context. (ie: using -U0)
> >
> > Anyway, please do investigate the integration because as you've
> > probably noticed, adding --fix rules to checkpatch can be painful.
> >
> > I'm not in any way against this concept or integration, but I do not
> > expect this clang-format-diff integration to go particularly well
> > unless the patch context provided is an entire statement.
> >
> > Maybe checkpatch could learn to apply patch series or could be
> > integrated along with git to apply patch series to a test branch
> > and clang-format-diff and the entire statement or function around
> > any change could be extracted and again run through clang-format.
> >
> > I suggest you play with it and see what you can do.
> >
>
> I agree. It is by no means straightforward to run clang-format on a
> patch (or on a git commit) and integrate it with checkpatch... it will
> need a bit of exploration, investigation along those lines you
> suggested.
>
> Aditya, Dwaipayan, feel free to explore and use the mentees list to
> exchange ideas and investigations.
>
Thanks Joe and Lukas for the insight. I shall try to bring up
something.

Regards,
Dwaipayan.


More information about the Linux-kernel-mentees mailing list