[Linux-kernel-mentees] Alternative to checkpatch fix options
joe at perches.com
Mon Nov 23 11:48:37 UTC 2020
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
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.
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.
best of luck...
More information about the Linux-kernel-mentees