Re: [PATCH 0/7] Support for automatic checkpatch running in the kernel

From: Knut Omang
Date: Fri Nov 17 2017 - 04:09:47 EST


I realize the Cc: list for the cover letter probably should have included all
the relevant maintainers for this set, sorry about that!

For convenience I also put up a more reader friendly copy of the doc after patch 7 here:

http://heim.ifi.uio.no/~knuto/kernel/4.14/dev-tools/run-checkpatch.html

Thanks,
Knut

On Thu, 2017-11-16 at 18:01 +0100, Knut Omang wrote:
> This patch series implements features to facilitate running checkpatch on the
> entire kernel as part of automatic testing.
>
> This is done by by adding a few small features to checkpatch and put these
> features to use to implement support for a new Makefile environment variable
> P={1,2} following the pattern of sparse and the C={1,2} variable.ÂÂThe basic
> functionality + docs are in patch #1-4.
>
> It also fixes a minor issue with "checkpatch --fix-inplace" found during testing
> (patch #5).
>
> The most important checkpatch feature added is the --ignore-cfg feature, which
> takes a file argument and parses that file according to this minimal language:
>
> ÂÂÂÂÂÂÂ# comments
> ÂÂÂÂÂÂÂline_len <n>
> ÂÂÂÂÂÂÂexcept checkpatch_type [files ...]
> ÂÂÂÂÂÂÂpervasive checkpatch_type1 [checkpatch_type2 ...]
>
> With "make P=2" checkpatch is called with "--file" and "--ignore_cfg
> checkpatch.cfg" which causes it to look for a file named 'checkpatch.cfg' in the
> same directory as the source file. If that file exists, checkpatch will be run
> with an implicit --strict and with the @ignore list expanded with content from
> the configuration file.ÂÂIf it does not exist, make will simply silently ignore
> the file.
>
> Patches #6-7 enhances this behaviour to also scan the directories above a file
> until a match for the --file parameter is found.
>
> The idea is that the community can work to add checkpatch.cfg files to
> directories, serving both as documentation and as a way for subsystem
> maintainers to enforce policies and individual tastes as well as TODOs and/or
> priorities, to make it easier for newcomers to contribute in this area. By
> ignoring directories without such files, automation can start right away as it
> is trivially possible to run errorless with P=2 for the entire kernel.
>
> The patches includes a documentation file with some more details.
>
> This patch set has evolved from an earlier implementation I made that was just a
> wrapper script around checkpatch. That version have been used for a number of
> years on a driver project I worked on where we had automatic checkin regression
> testing. I extended that to also run checkpatch to avoid having to clean up
> frequent unintended whitespace changes and style violations from others...
>
> I have also tested this version on some directories I am familiar with.ÂÂThe
> result of that work is available in two patch sets of 10 and 11 patches, but we
> agreed that it would be better to post them as separate patch sets later.
>
> Those patch sets illustrates how I picture the "flow" from just "reining in" the
> checkpatch detections to actually fixing classes of checkpatch issues one by
> one, while updating the checkpatch.cfg file(s) to have 0 errors or warnings at
> any commit boundary.
>
> The combined set is available here:
>
> ÂÂÂgit://github.com/knuto/linux.gitÂÂbranch checkpatch
>
> Comments and suggestions appreciated!
>
> Thanks,
> Knut
>
> Knut Omang (7):
> Â checkpatch: Implement new --ignore-cfg parameter
> Â kbuild: Add P= command line flag to run checkpatch
> Â checkpatch: Add a few convenience options to disable/modify features
> Â Documentation: Add documentation for the new P= Makefile option
> Â checkpatch: Improve --fix-inplace for TABSTOP
> Â checkpatch: Make --ignore-cfg look recursively for the file
> Â Documentation: Update checkpatch --ignore-cfg description
>
> ÂDocumentation/dev-tools/index.rstÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ1 +-
> ÂDocumentation/dev-tools/run-checkpatch.rst | 109 ++++++++++++++++++++++-
> ÂMakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ20 +++-
> Âscripts/Makefile.buildÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ13 +++-
> Âscripts/checkpatch.plÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 108 +++++++++++++++++++++-
> Â5 files changed, 249 insertions(+), 2 deletions(-)
> Âcreate mode 100644 Documentation/dev-tools/run-checkpatch.rst
>
> base-commit: bebc6082da0a9f5d47a1ea2edc099bf671058bd4