login
Header Space

 
 

Checkpatch and Checkfiles

October 5, 2007 - 4:32pm
Submitted by Jeremy on October 5, 2007 - 4:32pm.
Linux news

"This patch series also introduces a new small shell script wrapper, called scripts/checkfiles, that checks the compliance of source files (not in diff format); the script can operate on any mix of files and directories (recursively checking)," Erez Zadok stated describing a patch posted to the Linux Kernel mailing list. The small script works by recursively walking through a specified directory, running checkpatch on a diff of each source file against /dev/null. Erez added, "I ran the above script and it found nearly 1.5 million reported warnings/errors, with drivers being the largest abuser, not surprisingly." He then offered a breakdown of the warnings within each top level directory, summarizing, "1,464,313 total, any volunteers? :-)"


From: Erez Zadok <ezk@...>
Subject: [PATCH] 0/3 checkpatch updates, new checkfiles script
Date: Oct 5, 12:56 pm 2007

This series of patches adds a -t option to checkpatch, so it can print terse
messages one per line, in a format compatible with g/cc
(filename:linenumber:message).  This format can be parsed by various tools
and editors that can help show the errors in one window and the offending
file+line in another window.

This patch series also introduces a new small shell script wrapper, called
scripts/checkfiles, that checks the compliance of source files (not in diff
format); the script can operate on any mix of files and directories
(recursively checking).  For example, to check the entire Linux kernel, run:

$ ./scripts/checkfiles .

So, I ran the above script and it found nearly 1.5 million reported
warnings/errors, with drivers being the largest abuser, not surprisingly.
Here's the sorted breakdown per top-level subsystem:

     32 usr
    162 init
    266 block
    293 Documentation
    471 ipc
    819 mm
   1115 security
   1915 scripts
   1948 kernel
   4569 lib
   4793 crypto
  13851 net
  80025 sound
  86484 include
 115789 arch
 116623 fs
1035158 drivers
-------+-------
1464313 TOTAL

Any volunteers? :-)


Erez Zadok (3):
      CHECKPATCH: update usage string for checkpatch.pl
      CHECKPATCH: add terse output option to checkpatch.pl
      CHECKFILES: new small shell script to check multiple source files

 checkfiles    |   34 ++++++++++++++++++++++++++++++++++
 checkpatch.pl |   21 +++++++++++++++++----
 2 files changed, 51 insertions(+), 4 deletions(-)

---
Erez Zadok
ezk@cs.sunysb.edu
-

From: Erez Zadok <ezk@...> Subject: [PATCH 3/3] CHECKFILES: new small shell script to check multiple source files Date: Oct 5, 12:56 pm 2007 Examples: ./scripts/checkfiles fs/foo/bar.c ./scripts/checkfiles fs/foo/*.c ./scripts/checkfiles fs/foo # check all sources under fs/foo ./scripts/checkfiles . # check entire kernel Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu> --- scripts/checkfiles | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-) create mode 100644 scripts/checkfiles diff --git a/scripts/checkfiles b/scripts/checkfiles new file mode 100644 index 0000000..bd5d3f0 --- /dev/null +++ b/scripts/checkfiles @@ -0,0 +1,34 @@ +#!/bin/sh +# (c) 2007, Erez Zadok <ezk@cs.sunysb.edu> (initial version) +# Licensed under the terms of the GNU GPL License version 2 +# +# Check source files for compliance with coding standards, using terse +# output in the style that g/cc produces. This output can be easily parsed +# within text editors (e.g., emacs/vim) which can produce a split text +# screen showing in one screen the error message, and in another screen the +# corresponding source file, with the cursor placed on the offending line. +# See for example the documentation for Emacs's "next-error" command, often +# bound to M-x ` (ESC x back-tick). + +# Usage: checkfiles file [files...] +# if "file" is a directory, will check all *.[hc] files recursively + +# check usage +usage() { + echo "Usage: checkfiles file [files...]" + echo "(if \"file\" is a directory, check recursively for all C sources/headers)" + exit 1 +} +if test -z "" ; then + usage +fi +if ! test -f scripts/checkpatch.pl ; then + echo "checkfiles: must run from top level source tree" + exit 1 +fi + +# check coding-style compliance of each source file found, using terse output +find "$@" -type f -name '*.[hc]' | \ +while read f ; do + diff -u /dev/null $f | perl scripts/checkpatch.pl -t - +done -- 1.5.2.2 -


speck-geostationary