All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: kernelnewbies@lists.kernelnewbies.org
Subject: Re: [PATCH] reformat_with_checkpatch: Add automation to checkpatch
Date: Sat, 12 Jul 2014 01:53:27 +0000	[thread overview]
Message-ID: <20140712015327.GA26496@kroah.com> (raw)
In-Reply-To: <1405128087.6751.12.camel@joe-AO725>

On Fri, Jul 11, 2014 at 06:21:27PM -0700, Joe Perches wrote:
> A simple script to run checkpatch --fix for various types of
> of cleanups.
> 
> This script is useful primarily for staging.
> 
> This reformats code to a more CodingStyle conforming style,
> compiles it, verifies that the object code hasn't changed,
> and git commits it too.
> 
> You must have the necessary development tools, git, and a
> recent git tree.  Ideally use Greg KH's staging-next, which
> can be retrieved via these commands:
> 
> git clone git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
> git checkout staging-next
> 
> To use this script try a sequence of commands like:
> 
> 	cd <linux_repository>
> 	git checkout -b <your_branch>
> 	make allyesconfig
> 	mkdir patches
> 	./scripts/reformat_with_checkpatch.sh drivers/staging/<dir>/*.[ch]
> 	git format-patch --cover-letter -o patches/<your_branch> staging-next
> 	git send-email patches/<your_branch>
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  scripts/reformat_with_checkpatch.sh | 141 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 141 insertions(+)
>  create mode 100755 scripts/reformat_with_checkpatch.sh
> 
> diff --git a/scripts/reformat_with_checkpatch.sh b/scripts/reformat_with_checkpatch.sh
> new file mode 100755
> index 0000000..5415a8e
> --- /dev/null
> +++ b/scripts/reformat_with_checkpatch.sh
> @@ -0,0 +1,141 @@
> +#!/bin/bash
> +# (c) 2014, Joe Perches <joe@perches.com>
> +#
> +# Automate checkpatch modifications and git commits to
> +# neaten code that doesn't conform to CodingStyle.
> +# Useful primarily for files in drivers/staging
> +#
> +# Licensed under the terms of the GNU GPL License version 2
> +
> +declare -ar whitespace_types=(	\
> +    'whitespace_neatening:spacing,space_before_tab,pointer_location,trailing_whitespace,bracket_space'	\
> +    'remove_spaces_before_tabs:space_before_tab'		\
> +    'fix_label_positions:indented_label'		\
> +    'align_arguments_to_parenthesis:parenthesis_alignment'	\
> +)
> +
> +declare -ar changecode_types=(	\
> +    'fix_brace_positions:open_brace,braces,else_after_brace,while_after_brace'		\
> +    'fix_blank_lines:line_spacing'		\
> +    'use_standard_attributes:prefer_packed,prefer_aligned'		\
> +    'remove_unnecessary_externs:avoid_externs'		\
> +    'update_c90_comment_style:c99_comments'		\
> +)
> +
> +checkpatch_update ()
> +{
> +    file=$1
> +
> +    desc=$(echo $2 | cut -f1 -d: | sed 's/_/ /g')
> +    types=$(echo $2 | cut -f2- -d:)
> +
> +    echo "file: <$file> description: <$desc> types:<$types>"
> +
> +    ./scripts/checkpatch.pl --file --fix-inplace --strict --types="$types" $file
> +
> +    checkpatch_fixes=$file.diff
> +    git diff --stat -p --exit-code $file > $checkpatch_fixes
> +    if [ $? = 0 ] ; then
> +	rm -f $checkpatch_fixes
> +	return
> +    fi
> +
> +    basename=$(basename $file)
> +    if [ "${basename##*.}" = "c" ] ; then
> +
> +	git checkout $file
> +	obj="$(echo $file | sed 's/\.c$/\.o/')"
> +	if [ -e $obj ] ; then
> +	    rm -f $obj
> +	fi
> +
> +	echo "Compiling original version..."
> +
> +	${CROSS_COMPILE}make $obj

This fails for when a cflags option is set (like an include path).  Now,
I could argue that having an include path override in a kernel Makefile
is a bug, but well, it's staging...

Anyway, try running this script on
drivers/staging/lustre/lnet/lnet/acceptor.c to see how this build fails.

thanks,

greg k-h

WARNING: multiple messages have this Message-ID (diff)
From: gregkh@linuxfoundation.org (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: [PATCH] reformat_with_checkpatch: Add automation to checkpatch
Date: Fri, 11 Jul 2014 18:53:27 -0700	[thread overview]
Message-ID: <20140712015327.GA26496@kroah.com> (raw)
In-Reply-To: <1405128087.6751.12.camel@joe-AO725>

On Fri, Jul 11, 2014 at 06:21:27PM -0700, Joe Perches wrote:
> A simple script to run checkpatch --fix for various types of
> of cleanups.
> 
> This script is useful primarily for staging.
> 
> This reformats code to a more CodingStyle conforming style,
> compiles it, verifies that the object code hasn't changed,
> and git commits it too.
> 
> You must have the necessary development tools, git, and a
> recent git tree.  Ideally use Greg KH's staging-next, which
> can be retrieved via these commands:
> 
> git clone git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
> git checkout staging-next
> 
> To use this script try a sequence of commands like:
> 
> 	cd <linux_repository>
> 	git checkout -b <your_branch>
> 	make allyesconfig
> 	mkdir patches
> 	./scripts/reformat_with_checkpatch.sh drivers/staging/<dir>/*.[ch]
> 	git format-patch --cover-letter -o patches/<your_branch> staging-next
> 	git send-email patches/<your_branch>
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  scripts/reformat_with_checkpatch.sh | 141 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 141 insertions(+)
>  create mode 100755 scripts/reformat_with_checkpatch.sh
> 
> diff --git a/scripts/reformat_with_checkpatch.sh b/scripts/reformat_with_checkpatch.sh
> new file mode 100755
> index 0000000..5415a8e
> --- /dev/null
> +++ b/scripts/reformat_with_checkpatch.sh
> @@ -0,0 +1,141 @@
> +#!/bin/bash
> +# (c) 2014, Joe Perches <joe@perches.com>
> +#
> +# Automate checkpatch modifications and git commits to
> +# neaten code that doesn't conform to CodingStyle.
> +# Useful primarily for files in drivers/staging
> +#
> +# Licensed under the terms of the GNU GPL License version 2
> +
> +declare -ar whitespace_types=(	\
> +    'whitespace_neatening:spacing,space_before_tab,pointer_location,trailing_whitespace,bracket_space'	\
> +    'remove_spaces_before_tabs:space_before_tab'		\
> +    'fix_label_positions:indented_label'		\
> +    'align_arguments_to_parenthesis:parenthesis_alignment'	\
> +)
> +
> +declare -ar changecode_types=(	\
> +    'fix_brace_positions:open_brace,braces,else_after_brace,while_after_brace'		\
> +    'fix_blank_lines:line_spacing'		\
> +    'use_standard_attributes:prefer_packed,prefer_aligned'		\
> +    'remove_unnecessary_externs:avoid_externs'		\
> +    'update_c90_comment_style:c99_comments'		\
> +)
> +
> +checkpatch_update ()
> +{
> +    file=$1
> +
> +    desc=$(echo $2 | cut -f1 -d: | sed 's/_/ /g')
> +    types=$(echo $2 | cut -f2- -d:)
> +
> +    echo "file: <$file> description: <$desc> types:<$types>"
> +
> +    ./scripts/checkpatch.pl --file --fix-inplace --strict --types="$types" $file
> +
> +    checkpatch_fixes=$file.diff
> +    git diff --stat -p --exit-code $file > $checkpatch_fixes
> +    if [ $? == 0 ] ; then
> +	rm -f $checkpatch_fixes
> +	return
> +    fi
> +
> +    basename=$(basename $file)
> +    if [ "${basename##*.}" == "c" ] ; then
> +
> +	git checkout $file
> +	obj="$(echo $file | sed 's/\.c$/\.o/')"
> +	if [ -e $obj ] ; then
> +	    rm -f $obj
> +	fi
> +
> +	echo "Compiling original version..."
> +
> +	${CROSS_COMPILE}make $obj

This fails for when a cflags option is set (like an include path).  Now,
I could argue that having an include path override in a kernel Makefile
is a bug, but well, it's staging...

Anyway, try running this script on
drivers/staging/lustre/lnet/lnet/acceptor.c to see how this build fails.

thanks,

greg k-h

WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <gregkh@linuxfoundation.org>
To: Joe Perches <joe@perches.com>
Cc: devel@driverdev.osuosl.org,
	kernel-janitors <kernel-janitors@vger.kernel.org>,
	kernelnewbies@kernelnewbies.org,
	LKML <linux-kernel@vger.kernel.org>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] reformat_with_checkpatch: Add automation to checkpatch
Date: Fri, 11 Jul 2014 18:53:27 -0700	[thread overview]
Message-ID: <20140712015327.GA26496@kroah.com> (raw)
In-Reply-To: <1405128087.6751.12.camel@joe-AO725>

On Fri, Jul 11, 2014 at 06:21:27PM -0700, Joe Perches wrote:
> A simple script to run checkpatch --fix for various types of
> of cleanups.
> 
> This script is useful primarily for staging.
> 
> This reformats code to a more CodingStyle conforming style,
> compiles it, verifies that the object code hasn't changed,
> and git commits it too.
> 
> You must have the necessary development tools, git, and a
> recent git tree.  Ideally use Greg KH's staging-next, which
> can be retrieved via these commands:
> 
> git clone git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
> git checkout staging-next
> 
> To use this script try a sequence of commands like:
> 
> 	cd <linux_repository>
> 	git checkout -b <your_branch>
> 	make allyesconfig
> 	mkdir patches
> 	./scripts/reformat_with_checkpatch.sh drivers/staging/<dir>/*.[ch]
> 	git format-patch --cover-letter -o patches/<your_branch> staging-next
> 	git send-email patches/<your_branch>
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  scripts/reformat_with_checkpatch.sh | 141 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 141 insertions(+)
>  create mode 100755 scripts/reformat_with_checkpatch.sh
> 
> diff --git a/scripts/reformat_with_checkpatch.sh b/scripts/reformat_with_checkpatch.sh
> new file mode 100755
> index 0000000..5415a8e
> --- /dev/null
> +++ b/scripts/reformat_with_checkpatch.sh
> @@ -0,0 +1,141 @@
> +#!/bin/bash
> +# (c) 2014, Joe Perches <joe@perches.com>
> +#
> +# Automate checkpatch modifications and git commits to
> +# neaten code that doesn't conform to CodingStyle.
> +# Useful primarily for files in drivers/staging
> +#
> +# Licensed under the terms of the GNU GPL License version 2
> +
> +declare -ar whitespace_types=(	\
> +    'whitespace_neatening:spacing,space_before_tab,pointer_location,trailing_whitespace,bracket_space'	\
> +    'remove_spaces_before_tabs:space_before_tab'		\
> +    'fix_label_positions:indented_label'		\
> +    'align_arguments_to_parenthesis:parenthesis_alignment'	\
> +)
> +
> +declare -ar changecode_types=(	\
> +    'fix_brace_positions:open_brace,braces,else_after_brace,while_after_brace'		\
> +    'fix_blank_lines:line_spacing'		\
> +    'use_standard_attributes:prefer_packed,prefer_aligned'		\
> +    'remove_unnecessary_externs:avoid_externs'		\
> +    'update_c90_comment_style:c99_comments'		\
> +)
> +
> +checkpatch_update ()
> +{
> +    file=$1
> +
> +    desc=$(echo $2 | cut -f1 -d: | sed 's/_/ /g')
> +    types=$(echo $2 | cut -f2- -d:)
> +
> +    echo "file: <$file> description: <$desc> types:<$types>"
> +
> +    ./scripts/checkpatch.pl --file --fix-inplace --strict --types="$types" $file
> +
> +    checkpatch_fixes=$file.diff
> +    git diff --stat -p --exit-code $file > $checkpatch_fixes
> +    if [ $? == 0 ] ; then
> +	rm -f $checkpatch_fixes
> +	return
> +    fi
> +
> +    basename=$(basename $file)
> +    if [ "${basename##*.}" == "c" ] ; then
> +
> +	git checkout $file
> +	obj="$(echo $file | sed 's/\.c$/\.o/')"
> +	if [ -e $obj ] ; then
> +	    rm -f $obj
> +	fi
> +
> +	echo "Compiling original version..."
> +
> +	${CROSS_COMPILE}make $obj

This fails for when a cflags option is set (like an include path).  Now,
I could argue that having an include path override in a kernel Makefile
is a bug, but well, it's staging...

Anyway, try running this script on
drivers/staging/lustre/lnet/lnet/acceptor.c to see how this build fails.

thanks,

greg k-h

  parent reply	other threads:[~2014-07-12  1:53 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-12  1:21 [PATCH] reformat_with_checkpatch: Add automation to checkpatch Joe Perches
2014-07-12  1:21 ` Joe Perches
2014-07-12  1:21 ` Joe Perches
2014-07-12  1:34 ` Greg KH
2014-07-12  1:34   ` Greg KH
2014-07-12  1:34   ` Greg KH
2014-07-12  1:40   ` Joe Perches
2014-07-12  1:40     ` Joe Perches
2014-07-12  1:40     ` Joe Perches
2014-07-12  2:34     ` Greg KH
2014-07-12  2:34       ` Greg KH
2014-07-12  2:34       ` Greg KH
2014-07-12  9:30     ` Dan Carpenter
2014-07-12  9:30       ` Dan Carpenter
2014-07-12  9:30       ` Dan Carpenter
2014-07-12 17:55       ` Greg KH
2014-07-12 17:55         ` Greg KH
2014-07-12 17:55         ` Greg KH
2014-07-12 18:29         ` Joe Perches
2014-07-12 18:29           ` Joe Perches
2014-07-12 18:29           ` Joe Perches
2014-07-12 19:28           ` Greg KH
2014-07-12 19:28             ` Greg KH
2014-07-12 19:28             ` Greg KH
2014-07-13  3:06             ` Joe Perches
2014-07-13  3:06               ` Joe Perches
2014-07-13  3:06               ` Joe Perches
2014-07-12  1:39 ` Greg KH
2014-07-12  1:39   ` Greg KH
2014-07-12  1:39   ` Greg KH
2014-07-12  1:46   ` Joe Perches
2014-07-12  1:46     ` Joe Perches
2014-07-12  1:46     ` Joe Perches
2014-07-12  1:57     ` Greg KH
2014-07-12  2:01       ` Greg KH
2014-07-12  2:01       ` Greg KH
2014-07-12  2:05       ` Greg KH
2014-07-12  2:05         ` Greg KH
2014-07-12  2:05         ` Greg KH
2014-07-12  2:09         ` [PATCH] checkpatch: Remove unnecessary + after {8,8} Joe Perches
2014-07-12  2:09           ` Joe Perches
2014-07-12  2:09           ` Joe Perches
2014-07-12  2:23           ` Greg KH
2014-07-12  2:23             ` Greg KH
2014-07-12  2:23             ` Greg KH
2014-08-31 20:58           ` Sören Brinkmann
2014-08-31 20:58             ` Sören Brinkmann
2014-08-31 20:58             ` Sören Brinkmann
2014-09-01 16:55         ` [PATCH - resend] " Joe Perches
2014-09-01 16:55           ` Joe Perches
2014-09-01 16:55           ` Joe Perches
2014-10-30 11:12           ` Borislav Petkov
2014-10-30 11:12             ` Borislav Petkov
2014-10-30 11:12             ` Borislav Petkov
2014-10-30 11:15             ` Borislav Petkov
2014-10-30 11:15               ` Borislav Petkov
2014-10-30 11:15               ` Borislav Petkov
2014-07-12  1:43 ` [PATCH] reformat_with_checkpatch: Add automation to checkpatch Greg KH
2014-07-12  1:43   ` Greg KH
2014-07-12  1:43   ` Greg KH
2014-07-12  1:50   ` Joe Perches
2014-07-12  1:50     ` Joe Perches
2014-07-12  1:50     ` Joe Perches
2014-07-12  1:53 ` Greg KH [this message]
2014-07-12  1:53   ` Greg KH
2014-07-12  1:53   ` Greg KH
2014-07-12  1:57   ` Joe Perches
2014-07-12  1:57     ` Joe Perches
2014-07-12  1:57     ` Joe Perches
2014-07-12  2:15     ` Greg KH
2014-07-12  2:15       ` Greg KH
2014-07-12  2:15       ` Greg KH
2014-07-12  8:08     ` Greg KH
2014-07-12  8:08       ` Greg KH
2014-07-12  8:08       ` Greg KH
2014-07-12  8:18 ` Greg KH
2014-07-12  8:18   ` Greg KH
2014-07-12  8:18   ` Greg KH
2014-07-12 10:13   ` Joe Perches
2014-07-12 10:13     ` Joe Perches
2014-07-12 10:13     ` Joe Perches

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=20140712015327.GA26496@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=kernelnewbies@lists.kernelnewbies.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.