Checkpatch From Linux

Brief: checkpatch.pl is pearl script for detecting coding style errors in Linux source.
Since Linux kernel is a huge source with approximately 3431 directories, 48619 files so you can imagine the amount of code in it. So to get the coding style correct (uniform) across the complete source of Linux chekpatch.pl script is used.

Usage:

A> With a valid patch (by valid patch i mean it is created git-format patch command)

$ ./scripts/checkpatch.pl  <path to patch file>

For Example: $ ./scripts/checkpatch.pl  *.patch
Would run the script for all the patches in current directory.

B> With file (By the name you might feel it only tests patches no you can also run this on files)

$ ./scripts/checkpatch.pl --terse --file  <path to file>

Options:
--terse:  Specifies to report warining/error per line
--file/ -f: Specifies regular source file.
For Example: $ ./scripts/checkpatch.pl --terse --file  arch/arm/common/bL_switcher.c

arch/arm/common/bL_switcher.c:56: WARNING: Missing a blank line after declarations
total: 0 errors, 1 warnings, 822 lines checked

C> Using checkpatch for your files out of linux source.

$ ./scripts/checkpatch.pl --terse --file --no-tree my_application.c

Options:
--no-tree: Indicates to run without Linux kernel tree.

More Options:

--no-signoff: Indicates for not to check "Signed-off-by" line in the patch
--no-summary: Indicates to suppress the per-file summary
--summary-file: Indicates to include the filename in summary

D> Using checkpatch to check your applications not just kernel source

$ ./scripts/checkpatch.pl  --no-tree --terse --file <path to folder-1>/* <path to folder-2>/*

Assuming folder-1 and folder-2 contains C files and headers.


So this is short blog on usage on checkpatch there are several other options which I'll update in my future blogs.




Any  questions ? drop me a mail @ prabhakar.csengg@gmail.com
https://www.linkedin.com/in/prabhakarlad

Comments

Popular posts from this blog

Linux Bluetooth Pairing Device Using BlueZ5.X C Way

Linux mmap Based File Write