Search notes:

scripts/checkpatch.pl

$ scripts/checkpatch.pl [option]… [file]…
scripts/checkpatch.pl checks for trivial style violations in patches and optionally corrects them.
The script can also be run on file contexts and without the kernel tree (option --no-tree)
The output of checkpatch.pl is not always right.

Examples

Warnings and errors

$ scripts/checkpatch.pl patch
WARNING: patch prefix 'Documentation' exists, appears to be a -p0 patch

WARNING: Missing commit description - Add an appropriate one

ERROR: Missing Signed-off-by: line(s)

total: 1 errors, 2 warnings, 8 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

patch.2 has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Better

$ scripts/checkpatch.pl patch
total: 0 errors, 0 warnings, 8 lines checked

patch has no obvious style problems and is ready for submission.

Options

-q --quiet quiet
-v --verbose verbose mode
--no-tree run without a kernel tree
--no-signoff do not check for the Signed-off-by line
--patch treat FILE as patchfile. Since this options is the default option, it needs not be explicitly specified.
--emacs emacs compile window format
--terse one line per report
--showfile emit diffed file position, not input file position
-g --git treat FILE as a single commit or git revision range (single commit: <rev>, <rev>^ or <rev>~n, multiple commits: <rev1>..<rev2>, <rev1>...<rev2> or <rev>-<count>). Git mergesa are ignored.
-f --file treat FILE as regular source file. This option must be used when running checkpatch on source files in the kernel.
--subjective, --strict enable stricter tests. By default the tests emitted as CHECK do not activate by default. Use this flag to activate the CHECK tests.
--list-types Every message emitted by checkpatch has an associated type. With this option list the possible message types are listed (and FILE is not read). Compare with --types and --ignore
--types TYPE(,TYPE2…) show only these comma separated message types. Compare with --list-types and --ignore
--ignore TYPE(,TYPE2…) ignore various comma separated message types. Compare with --list-types and --types
--show-types show the specific message type in the output. Compare with --list-types etc.
--max-line-length=n set the maximum line length, (default $max_line_length) if exceeded, warn on patches requires --strict for use with --file
--min-conf-desc-length=n set the min description length, if shorter, warn
--tab-size=n set the number of spaces for tab (default $tabsize)
--root=PATH PATH to the kernel tree root. This option must be specified if invoking checkpatch.pl from outside the kernel root.
--no-summary suppress the per-file summary
--mailback only produce a report in case of warnings/errors
--summary-file include the filename in summary
--debug KEY=[0|1] turn on/off debugging of KEY where KEY is one of values, possible, type and att' (default is all off)
--test-only=WORD report only warnings/errors containing WORD literally
--fix Experimental: tries to correct correctable errors to the preferred checkpatch style and writes FILE.EXPERIMENTAL-checkpatch-fixes. May create horrible results If correctable single-line errors exist
--fix-inplace Experimental - may create horrible results Is the same as --fix, but overwrites the input file. It's your fault if there's no backup or git
--ignore-perl-version Override checking of perl version. Expect runtime errors.
--codespell Use the codespell dictionary for spelling/typos (default:$codespellfile)
--codespellfile Use this codespell dictionary
--typedefsfile Read additional types from this file
--color[=WHEN] Use colors 'always', 'never', or only when output is a terminal ('auto'). Default is 'auto'.
--kconfig-prefix=WORD use WORD as a prefix for Kconfig symbols (default ${CONFIG_})
-h --help, --version display this help and exit

See also

The scripts cleanpatch and cleanfile.
Documentation/dev-tools/checkpatch.rst
The CHECKPATCH section in MAINTAINERS.
The parent directory scripts/

Index