checkpatch.pl - Coding Style, Spell Check

checkpatch.pl is perl script present in scripts folder of the Linux Source code. It is used by the developers to verify the patches follows Linux Coding Style or not before upstreaming them.

E.g. $ ./scripts/checkpatch.pl <patchfile.patch>

To see what all options are supported by checkpatch, run "checkpatch.pl --help"

How to use checkpatch.pl to verify coding style of our own C Source files?

$ ./checkpatch.pl --no-tree --file mychardriver.c

--no-tree option allows to run without a kernel tree
--file option tells checkpatch to treat this as a file instead of patch.

To list all the various messages it supports, run

$ ./checkpatch.pl --list-types


You can look more info about each message in checkpatch.pl file



You can use checkpatch.pl to check for spellings and typos, for that you need to have codespell package installed, if you dont' have install it with the following command:

sudo apt-get install codespell

And enable codespell parameter: $ ./checkpatch.pl --codespell --no-tree --file mychardriver.c

./checkpatch.pl also have experimental feature to auto correct some errors, using "--fix" or "--fix-inplace" options

Comments

Popular posts from this blog

bb.utils.contains yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig

PR, PN and PV Variable in Yocto