mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: checkpatch guide for newbies
Date: Mon, 23 Sep 2013 13:17:24 -0700	[thread overview]
Message-ID: <1379967444.3575.56.camel@joe-AO722> (raw)
In-Reply-To: <1379959611.3575.40.camel@joe-AO722>

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




  reply	other threads:[~2013-09-23 20:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-23  9:01 Dan Carpenter
2013-09-23 12:46 ` Peter Senna Tschudin
2013-09-23 13:29   ` Dan Carpenter
2013-09-23 14:04   ` Geert Uytterhoeven
2013-09-23 18:06 ` Joe Perches
2013-09-23 20:17   ` Joe Perches [this message]
2013-09-23 18:35 ` bojan prtvar
2013-09-24 16:36 ` Bjorn Helgaas
2013-09-24 17:26   ` Alexander Holler
2013-09-24 17:43     ` Alexander Holler
2013-09-24 18:50       ` Alexander Holler
2013-09-24 19:29     ` Peter Senna Tschudin
2013-09-24 19:59       ` Dan Carpenter
2013-09-24 20:13       ` Bjorn Helgaas
2013-09-24 22:10         ` Alexander Holler
2013-09-26  2:11           ` Al Viro
2013-09-26  2:52             ` Alexander Holler
2013-09-26  2:57               ` Alexander Holler
2013-09-26  3:04                 ` Al Viro
2013-09-26  3:27                   ` Alexander Holler
2013-09-26  3:48                     ` Al Viro
2013-09-26  4:21                       ` Alexander Holler
2013-09-26  5:53                     ` Julia Lawall
2013-09-26  9:55                       ` Alexander Holler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379967444.3575.56.camel@joe-AO722 \
    --to=joe@perches.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®