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

Lukas Bulwahn lukas.bulwahn at gmail.com
Mon Nov 23 09:33:58 UTC 2020


Dear Aditya and Dwaipayan,

For creating fix options to checkpatch rules, please note that:

Checkpatch has rules to check the commit message and the file diff.
For the commit message, checkpatch is currently the only tool that
checks that content and hence, it is the only tool with which fixes
and fix options can be proposed. For the code style, certain code
conventions, syntactic/semantic bug classes on code/documentation and
the respective file diff, we have many other tools that can check and
suggest/provide fixes.

Currently, I see the prominent option to always consider if a very
limited specific configuration of clang-format would actually address
and fix the rule violation that checkpatch points out. So rather than
trying to implement the fix option in checkpatch with all the
challenges of getting this right (with quite a limited C parsing
functionality in checkpatch), we could simply investigate if one
clang-format invocation on the diff, with a specific formatting rule,
would lead to the same result. If clang-format cannot be configured to
do the right formatting correction for a specific warning, we can move
forward and implement it in checkpatch.

By the way, Joe and Miguel already discussed clang-format (multiple
times); I am not suggesting to make clang-format "the final tool" or
fully replace checkpatch, but 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?

>From a practical perspective, checkpatch could simply emit or invoke
the clang-format command that needs to be run on the patch to do the
fixes. It might take a bit more time in the beginning to understand
how checkpatch rules and clang-format configurations are related and
how to establish a proper synergy between those two tools, but I am
sure that proposing fixes with clang-format is much faster
"configured" than trying to implement them in checkpatch, once the
initial learning curve is overcome.

Lukas


More information about the Linux-kernel-mentees mailing list