lkml.org 
[lkml]   [2013]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: checkpatch guide for newbies
From
Date
On Mon, 2013-09-23 at 11:06 -0700, Joe Perches wrote:
> Maybe I'll submit some auto-neatening script eventually
> and see what you think.

Maybe something like:

From: Joe Perches <joe@perches.com>
Subject: [PATCH] scripts/fix_with_checkpatch.sh: Add a trivial script to fix simple style defects

Add a few whitespace and style corrections to individual files.

Create git commits for those changes too.

Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/fix_with_checkpatch.sh | 52 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
create mode 100755 scripts/fix_with_checkpatch.sh

diff --git a/scripts/fix_with_checkpatch.sh b/scripts/fix_with_checkpatch.sh
new file mode 100755
index 0000000..c47b111b
--- /dev/null
+++ b/scripts/fix_with_checkpatch.sh
@@ -0,0 +1,50 @@
+#/bin/sh
+
+whitespace_types="spacing space_before_tab pointer_location"
+changecode_types="c99_comments prefer_packed prefer_aligned avoid_externs parenthesis_alignment"
+
+checkpatch_update ()
+{
+ local file="$1"
+ type="$2"
+
+ ./scripts/checkpatch.pl --file --fix --strict --types=$type $file
+ if [ ! -f $file.EXPERIMENTAL-checkpatch-fixes ] ; then
+ return;
+ fi
+
+ mv $file.EXPERIMENTAL-checkpatch-fixes $file
+
+ git diff --stat -p $file | cat
+
+ obj="$(echo $file|sed 's/\.c$/\.o/')"
+
+ make $obj
+
+ tmpfile=$(mktemp git_commit.XXXXXX)
+ echo "$file: checkpatch neatening for $2" > $tmpfile
+ echo "" >> $tmpfile
+ echo "" >> $tmpfile
+
+ git commit -s -F $tmpfile -e $file
+
+ rm -f $tmpfile
+}
+
+for file in "$@"
+do
+
+ if [ ! -f $file ] ; then
+ echo "Argument '$file' is not a file"
+ continue
+ fi
+
+ for type in $whitespace_types ; do
+ checkpatch_update $file $type
+ done
+
+ for type in $changecode_types ; do
+ checkpatch_update $file $type
+ done
+
+done
--
1.8.1.2.459.gbcd45b4.dirty




\
 
 \ /
  Last update: 2013-09-23 22:41    [W:0.147 / U:3.720 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site