I am very new to Linux and Git. I want to know what exactly checkpatch.pl
script does. I know there is a source code available on the Internet but it's a Perl script and I don't know Perl.
So, can anyone here explain me here what exactly does it do?
Checkpatch (scripts/checkpatch.pl) is a perl script which checks for trivial style violations in patches and optionally corrects them. Checkpatch can also be run on file contexts and without the kernel tree.
$ chmod +c checkpatch.pl $ ./checkpatch.pl --no-tree -f sample_module.c –no-tree : By default checkpatch must be run from the top-level dir. of a kernel tree. This option overrides the default behaviour.
By default checkpatch utility checks if a patch is well formated and conforms to Linux Kernel Coding Style Rules. If you want to check a file instead of a patch, you need to use -f option. If your file is not located in a regular kernel tree, you need --no-tree option. So./checkpatch.pl -f --no-tree mychardriver.c should do the job.
-f : By default checkpatch verifies kernel patches. This option instructs it to treat the file as a regular source file.
It is a tool to check your coding style match Linux coding style or not. You can use -help to see what options you can use. After it check your file, the tool prints a result like compile result. The result show you which line has coding style errors and warnings, and reminds you how to modify your code. And also you can modify the script tool to match your own coding style.
checkpatch.pl is a script in the kernel tree that facilitates better kernel code, and can be used to check many coding style rules. This script applies on patch files by default, but can also process complete source files using the -f
or --file
option.
See:
scripts/checkpatch.pl -h # running from kernel source root
or
checkpatch.pl -h --no-tree # when pwd ≠ root of the kernel source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With