reformat_with_checkpatch: Add automation to checkpatch
Subsystems (3)
Joe Perches
maintainerPATCH 1/1 reformat_with_checkpatch: Add automation to checkpatch
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>
--- scripts/reformat_with_checkpatch.sh | 141 ++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100755 scripts/reformat_with_checkpatch.sh
scripts/reformat_with_checkpatch.sh new file +141 -0
@@ -0,0 +1,141 @@ +#!/bin/bash +# (c) 2014, Joe Perches <[email protected]> +# +# 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 + + ${CROSS_COMPILE}objdump -D $obj | \ + sed "s/^[[:space:]]\+[0-9a-f]\+//" > $obj.old + + patch -p1 < $checkpatch_fixes + + echo "Compiling modified version..." + + ${CROSS_COMPILE}make $obj + + ${CROSS_COMPILE}objdump -D $obj | \ + sed "s/^[[:space:]]\+[0-9a-f]\+//" > $obj.new + + echo "Comparing objects..." + diff -Nurd $obj.new $obj.old + if [ $? -ne 0 ] ; then + echo "Object differences exist! - Verify changes before commit!" + read -s -p "Press the 'enter' key to continue: " + else + echo "No object differences found" + fi + rm -f $obj.old + rm -f $obj.new + fi + + echo "running checkpatch on possible checkpatch fixes..." + + ./scripts/checkpatch.pl --no-summary --no-signoff $checkpatch_fixes + rm -f $checkpatch_fixes + + echo "Verify checkpatch output and make any necessary changes" + echo "Edit '$file' if appropriate" + read -s -p "Press the 'enter' key to continue: " + + commit_log_file=$(mktemp git_commit.XXXXXX) + + if [ -e $commit_log_file ] ; then + rm -f $commit_log_file + fi + + if [[ $file =~ ^drivers/staging/ ]] ; then + echo -n "staging: " >> $commit_log_file + fi + echo "$(basename $(dirname $file)): checkpatch cleanup: $desc" >> $commit_log_file + echo "" >> $commit_log_file + git diff --exit-code -w $file > /dev/null + if [ $? = 0 ] ; then + echo "whitespace changes only - git diff -w shows no difference" >> $commit_log_file + fi + + git diff $file | cat + + echo "Ready to commit - First verify all diffs and make any necessary changes" + echo "" + read -r -p "Would you like to commit these changes <y>: " response + response=${response,,} + if [[ $response =~ ^(yes|y|)$ ]] ; then + git commit -s -F $commit_log_file -e $file + else + git checkout $file + fi + + rm -f $commit_log_file +} + +which git > /dev/null +if [ $? -ne 0 ] || [ ! -e .git ] ; then + echo "git or git directory not found - run this from the top of the source tree" + exit 1 +fi + +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
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
Greg KH
maintainerQuoted 8 lines · Joe Perches
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.
And 'git commits' it? Heh, I should just run this myself to clean up staging and beat everyone else to it...
I know some people already have private versions of these things, might as well make it public for all to abuse :)
thanks,
greg k-h
Joe Perches
maintainerQuoted 11 lines · Greg KH
Quoted 8 lines · Joe Perches
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.
And 'git commits' it?
The thought I had was to made it easier to submit "my first kernel patch" correctly. like that tuxradar article you wrote a few years ago.
http://www.tuxradar.com/content/newbies-guide-hacking-linux-kernel
Quoted 2 lines
Heh, I should just run this myself to clean up
staging and beat everyone else to it...
At least for the whitespace noise, you could but I hope it'll encourage a few more people to try kernel patching instead.
Quoted 2 lines
I know some people already have private versions of these things, might as well make it public for all to abuse :)
And I hope they can improve it too as it's just a brainless little script.
Greg KH
maintainerQuoted 11 lines · Joe Perches
Quoted 10 lines · Greg KH
Quoted 8 lines · Joe Perches
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.
Quoted 8 lines
Quoted 1 line
And 'git commits' it?
The thought I had was to made it easier to
submit "my first kernel patch" correctly.
like that tuxradar article you wrote a few
years ago.http://www.tuxradar.com/content/newbies-guide-hacking-linux-kernel
Yeah, but it's good for people to actually understand the change they are making, and edit it themselves. Or at least I think so, but I know others don't, so I don't mind this script.
thanks,
greg k-h
Quoted 18 lines · Joe Perches
Quoted 11 lines · Greg KH
Quoted 8 lines · Joe Perches
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.
And 'git commits' it?
The thought I had was to made it easier to submit "my first kernel patch" correctly. like that tuxradar article you wrote a few years ago.
Quoted 8 lines
http://www.tuxradar.com/content/newbies-guide-hacking-linux-kernel
Quoted 2 lines
Heh, I should just run this myself to clean up
staging and beat everyone else to it...At least for the whitespace noise, you could but I hope it'll encourage a few more people to try kernel patching instead.
I have always hate the idea of automated patches from random people because I don't trust them to not be malicious so I have to review them manually. There is a story that back in the day the US government paid someone to send tons of checkpatch style patches to BSD. The guy thought he was "cleaning up the code" but actually he was part of a larger scheme to flood the maintainers with patches so another person could slip in some malicious code.
It's better if someone just ran this on all new staging code before adding it to the tree.
regards,
dan carpenter
Greg KH
maintainerQuoted 28 lines · Dan Carpenter
Quoted 18 lines · Joe Perches
Quoted 11 lines · Greg KH
Quoted 8 lines · Joe Perches
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.
And 'git commits' it?
The thought I had was to made it easier to submit "my first kernel patch" correctly. like that tuxradar article you wrote a few years ago.
Quoted 8 lines
http://www.tuxradar.com/content/newbies-guide-hacking-linux-kernel
Quoted 2 lines
Heh, I should just run this myself to clean up
staging and beat everyone else to it...At least for the whitespace noise, you could but I hope it'll encourage a few more people to try kernel patching instead.
Quoted 7 lines
I have always hate the idea of automated patches from random people because I don't trust them to not be malicious so I have to review them manually. There is a story that back in the day the US government paid someone to send tons of checkpatch style patches to BSD. The guy thought he was "cleaning up the code" but actually he was part of a larger scheme to flood the maintainers with patches so another person could slip in some malicious code.
Based on some of the patches that I get sent, I wouldn't be surprised if that's already happening :(
Quoted 2 lines
It's better if someone just ran this on all new staging code before adding it to the tree.
I spent some time messing with this script today, and while it is "fun" to run, I don't think it's all that useful.
One example, before running the script:
~/linux/work/staging $ ./scripts/checkpatch.pl --terse --file drivers/staging/android/binder.c | tail -n 1
total: 0 errors, 103 warnings, 3670 lines checked
After running it:
~/linux/work/staging $ ./scripts/checkpatch.pl --terse --file drivers/staging/android/binder.c | tail -n 1
total: 0 errors, 125 warnings, 3670 lines checked
And that was after the script created two patches, with the resulting diffstat of:
drivers/staging/android/binder.c | 124 +++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 62 deletions(-)
So 2 patches, 60+ lines to review, and 22 more warnings from checkpatch as the end result?
Yes, the warnings are all due to line-length, but Joe, you shouldn't add a patch that causes more checkpatch warnings than before :)
I know people have scripts like this of their own, and while it might be nice to "standardize" them, I am really reluctant to put this script in the kernel tree itself. There's a barrier of entry to write your own type of script here that honestly, I like.
We already have the example of someone who obviously does not know the C language at all, running through the kernel tree at the moment, creating horrible patches that are flat-out wrong and annoying maintainers with their result. I've had to kill-file them for now, as it was just too annoying and maintainer time is what we have the least of.
While I always want to see more developers get involved with kernel development, there should be a minimum barrier to entry. And that barrier is the knowledge of the C language, and knowledge of how to edit a text file, and use git. This script takes that barrier away, for whitespace cleanups, with not much real use overall.
So, I'll keep my local copy of this script now, just to have fun with at times when I'm bored. But I don't think it should be merged, as-is.
thanks,
greg k-h
Joe Perches
maintainerQuoted 2 lines · Greg KH
Yes, the warnings are all due to line-length, but Joe, you shouldn't add a patch that causes more checkpatch warnings than before :)
Yeah, that was intentional though.
This script does a series of relatively discrete changes.
Lindent would more or less work, but it's _horrible_ at wrapping overlong lines and merges all types of changes together.
For now, people are probably better at line wrapping in an acceptable way.
Quoted 8 lines
While I always want to see more developers get involved with kernel development, there should be a minimum barrier to entry. And that barrier is the knowledge of the C language, and knowledge of how to edit a text file, and use git. This script takes that barrier away, for whitespace cleanups, with not much real use overall.
So, I'll keep my local copy of this script now, just to have fun with at times when I'm bored. But I don't think it should be merged, as-is.
Dunno, I still think it's useful.
Maybe when you get new code, you might run it through a script like this before committing it.
Greg KH
maintainerQuoted 11 lines · Joe Perches
Quoted 2 lines · Greg KH
Yes, the warnings are all due to line-length, but Joe, you shouldn't add a patch that causes more checkpatch warnings than before :)
Yeah, that was intentional though.
This script does a series of relatively discrete changes.
Lindent would more or less work, but it's _horrible_ at wrapping overlong lines and merges all types of changes together.
Oh I agree, I don't want to see Lindent, but maybe, if the patch adds checkpatch warnings, it should be at least "flagged" as maybe a problem?
Quoted 10 lines
Quoted 8 lines
While I always want to see more developers get involved with kernel development, there should be a minimum barrier to entry. And that barrier is the knowledge of the C language, and knowledge of how to edit a text file, and use git. This script takes that barrier away, for whitespace cleanups, with not much real use overall.
So, I'll keep my local copy of this script now, just to have fun with at times when I'm bored. But I don't think it should be merged, as-is.
Dunno, I still think it's useful.
For you, and me, but the world?
Would you want to be on the receiving end of this patch script? I don't, and I'm willing to take almost any patch cleanup for staging code. I think that says something :)
Quoted 2 lines
Maybe when you get new code, you might run it through a script like this before committing it.
I will keep it for me, like I said.
thanks,
greg k-h
Joe Perches
maintainerQuoted 7 lines · Greg KH
Quoted 6 lines · Joe Perches
Quoted 2 lines · Greg KH
Yes, the warnings are all due to line-length, but Joe, you shouldn't add a patch that causes more checkpatch warnings than before :)
Yeah, that was intentional though.
Quoted 8 lines
Quoted 5 lines
This script does a series of relatively discrete changes.
Lindent would more or less work, but it's _horrible_ at wrapping overlong lines and merges all types of changes together.
Oh I agree, I don't want to see Lindent, but maybe, if the patch adds checkpatch warnings, it should be at least "flagged" as maybe a problem?
The script I submitted does run checkpatch
before any commit is done.
Quoted 1 line
Would you want to be on the receiving end of this patch script?
You might have noticed I don't have a kernel.org
account.
Greg KH
maintainerQuoted 26 lines · Joe Perches
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-nextTo 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.shdrivers/staging/<dir>/*.[ch] git format-patch --cover-letter -o patches/<your_branch> staging-next git send-email patches/<your_branch>
Quoted 5 lines
Signed-off-by Joe Perches <[email protected]>--- scripts/reformat_with_checkpatch.sh | 141 ++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100755 scripts/reformat_with_checkpatch.sh
No --help option?
How do I run this thing?
I ran it on a file that had no problems and got a mess, all I think due to something odd in checkpatch itself right now:
$ ./scripts/checkpatch.pl --file drivers/staging/lustre/include/linux/lnet/api.h
Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at ./scripts/checkpatch.pl line 2217.
total: 0 errors, 0 warnings, 220 lines checkedWhat's with that 'Useless use..." error? perl 5.20 in use, is that the issue?
Anyway, running this script on the file gave me this:
$ ./reformat_with_checkpatch drivers/staging/lustre/include/linux/lnet/api.h
file: <drivers/staging/lustre/include/linux/lnet/api.h> description: <whitespace neatening> types:<spacing,space_before_tab,pointer_location,trailing_whitespace,bracket_space>
Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at ./scripts/checkpatch.pl line 2217.
total: 0 errors, 0 warnings, 0 checks, 220 lines checkedNOTE: Used message types: BRACKET_SPACE POINTER_LOCATION SPACE_BEFORE_TAB SPACING TRAILING_WHITESPACE
drivers/staging/lustre/include/linux/lnet/api.h has no obvious style problems and is ready for submission.
file: <drivers/staging/lustre/include/linux/lnet/api.h> description: <remove spaces before tabs> types:<space_before_tab> Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at ./scripts/checkpatch.pl line 2217.
total: 0 errors, 0 warnings, 0 checks, 220 lines checked
NOTE: Used message types: SPACE_BEFORE_TAB
drivers/staging/lustre/include/linux/lnet/api.h has no obvious style problems and is ready for submission.
file: <drivers/staging/lustre/include/linux/lnet/api.h> description: <fix label positions> types:<indented_label> Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at ./scripts/checkpatch.pl line 2217.
total: 0 errors, 0 warnings, 0 checks, 220 lines checked
NOTE: Used message types: INDENTED_LABEL
drivers/staging/lustre/include/linux/lnet/api.h has no obvious style problems and is ready for submission.
file: <drivers/staging/lustre/include/linux/lnet/api.h> description: <align arguments to parenthesis> types:<parenthesis_alignment> Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at ./scripts/checkpatch.pl line 2217.
total: 0 errors, 0 warnings, 0 checks, 220 lines checked
NOTE: Used message types: PARENTHESIS_ALIGNMENT
drivers/staging/lustre/include/linux/lnet/api.h has no obvious style problems and is ready for submission.
file: <drivers/staging/lustre/include/linux/lnet/api.h> description: <fix brace positions> types:<open_brace,braces,else_after_brace,while_after_brace> Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at ./scripts/checkpatch.pl line 2217.
total: 0 errors, 0 warnings, 0 checks, 220 lines checked
NOTE: Used message types: BRACES ELSE_AFTER_BRACE OPEN_BRACE WHILE_AFTER_BRACE
drivers/staging/lustre/include/linux/lnet/api.h has no obvious style problems and is ready for submission.
file: <drivers/staging/lustre/include/linux/lnet/api.h> description: <fix blank lines> types:<line_spacing>
Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at ./scripts/checkpatch.pl line 2217.
total: 0 errors, 0 warnings, 0 checks, 220 lines checked
NOTE: Used message types: LINE_SPACING
drivers/staging/lustre/include/linux/lnet/api.h has no obvious style problems and is ready for submission.
file: <drivers/staging/lustre/include/linux/lnet/api.h> description: <use standard attributes> types:<prefer_packed,prefer_aligned> Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at ./scripts/checkpatch.pl line 2217.
total: 0 errors, 0 warnings, 0 checks, 220 lines checked
NOTE: Used message types: PREFER_ALIGNED PREFER_PACKED
drivers/staging/lustre/include/linux/lnet/api.h has no obvious style problems and is ready for submission.
file: <drivers/staging/lustre/include/linux/lnet/api.h> description: <remove unnecessary externs> types:<avoid_externs> Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at ./scripts/checkpatch.pl line 2217.
total: 0 errors, 0 warnings, 0 checks, 220 lines checked
NOTE: Used message types: AVOID_EXTERNS
drivers/staging/lustre/include/linux/lnet/api.h has no obvious style problems and is ready for submission.
file: <drivers/staging/lustre/include/linux/lnet/api.h> description: <update c90 comment style> types:<c99_comments> Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at ./scripts/checkpatch.pl line 2217.
total: 0 errors, 0 warnings, 0 checks, 220 lines checked
NOTE: Used message types: C99_COMMENTS
drivers/staging/lustre/include/linux/lnet/api.h has no obvious style problems and is ready for submission.
Is that expected?
thanks,
greg k-h
Joe Perches
maintainerQuoted 3 lines · Greg KH
Quoted 2 lines · Joe Perches
A simple script to run checkpatch --fix for various types of of cleanups.
]
Quoted 3 lines
drivers/staging/lustre/include/linux/lnet/api.hhas no obvious style problems and is ready for submission.
file: <drivers/staging/lustre/include/linux/lnet/api.h> description: <update c90 comment style> types:<c99_comments> Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at./scripts/checkpatch.plline 2217.
[]
Quoted 1 line
drivers/staging/lustre/include/linux/lnet/api.hhas no obvious style problems and is ready for submission.
[]
Quoted 1 line
Is that expected?
No, I haven't seen that.
Can you tell me what git tree you're working on? Also, can you use the scripts/checkpatch from -next tag next-20140711
My system has:
$ perl --version
This is perl 5, version 18, subversion 2 (v5.18.2) built for i686-linux-gnu-thread-multi-64int (with 41 registered patches, see perl -V for more detail)
Copyright 1987-2013, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
and using that:
$ ./scripts/checkpatch.pl -f --strict drivers/staging/lustre/include/linux/lnet/api.h --typesÉ9_comments total: 0 errors, 0 warnings, 0 checks, 220 lines checked
NOTE: Used message types: C99_COMMENTS
drivers/staging/lustre/include/linux/lnet/api.h has no obvious style problems and is ready for submission.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Greg KH
maintainerQuoted 8 lines · Joe Perches
Quoted 3 lines · Greg KH
Quoted 2 lines · Joe Perches
A simple script to run checkpatch --fix for various types of of cleanups.
]
Quoted 3 lines
drivers/staging/lustre/include/linux/lnet/api.hhas no obvious style problems and is ready for submission.
file: <drivers/staging/lustre/include/linux/lnet/api.h> description: <update c90 comment style> types:<c99_comments> Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at./scripts/checkpatch.plline 2217.
Quoted 8 lines
[]
Quoted 1 line
drivers/staging/lustre/include/linux/lnet/api.hhas no obvious style problems and is ready for submission.[]
Quoted 1 line
Is that expected?
No, I haven't seen that.
Can you tell me what git tree you're working on?
My staging-next branch of staging.git on git.kernel.org
Quoted 2 lines
Also, can you use the
scripts/checkpatchfrom -next tag next-20140711
that will take a bit to checkout, I'll do that afterward.
Quoted 6 lines
My system has:
$ perl --versionThis is perl 5, version 18, subversion 2 (v5.18.2) built for i686-linux-gnu-thread-multi-64int (with 41 registered patches, see perl -V for more detail)
I think this started showing up for me for perl 5.20. Let me go checkout linux-next and see if that fixes anything or not...
thanks,
greg k-h
Greg KH
maintainerQuoted 27 lines · Greg KH
Quoted 8 lines · Joe Perches
Quoted 3 lines · Greg KH
Quoted 2 lines · Joe Perches
A simple script to run checkpatch --fix for various types of of cleanups.
]
Quoted 3 lines
drivers/staging/lustre/include/linux/lnet/api.hhas no obvious style problems and is ready for submission.
file: <drivers/staging/lustre/include/linux/lnet/api.h> description: <update c90 comment style> types:<c99_comments> Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at./scripts/checkpatch.plline 2217.Quoted 8 lines
[]
Quoted 1 line
drivers/staging/lustre/include/linux/lnet/api.hhas no obvious style problems and is ready for submission.[]
Quoted 1 line
Is that expected?
No, I haven't seen that.
Can you tell me what git tree you're working on?
My staging-next branch of staging.git on git.kernel.org
Quoted 2 lines
Also, can you use the
scripts/checkpatchfrom -next tag next-20140711that will take a bit to checkout, I'll do that afterward.
Quoted 2 lines
My system has:
Quoted 7 lines
Quoted 4 lines
$ perl --versionThis is perl 5, version 18, subversion 2 (v5.18.2) built for i686-linux-gnu-thread-multi-64int (with 41 registered patches, see perl -V for more detail)
I think this started showing up for me for perl 5.20. Let me go checkout linux-next and see if that fixes anything or not...
Ok, with linux-next I get the same thing:
~/linux/tmp/linux-next $ ./scripts/checkpatch.pl -f --strict drivers/staging/lustre/include/linux/lnet/api.h --types=c99_comments Useless use of greediness modifier '+' in regex; marked by <-- HERE in m/(^\+.*) {8,8}+ <-- HERE \t/ at ./scripts/checkpatch.pl line 2358.
total: 0 errors, 0 warnings, 0 checks, 220 lines checked
NOTE: Used message types: C99_COMMENTS
drivers/staging/lustre/include/linux/lnet/api.h has no obvious style problems and is ready for submission.
Joe Perches
maintainerPATCH 1/1 checkpatch: Remove unnecessary + after {8,8}
There's a useless "+" use that needs to be removed as perl 5.20 emits a "Useless use of greediness modifier '+'" message each time it's hit.
---
Quoted 1 line · Greg KH
Ok, with linux-next I get the same thing:
Thanks Greg.
scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
@@ -2376,7 +2376,7 @@ sub process { "please, no space before tabs\n" . $herevet) && $fix) { while ($fixed[$fixlinenr] =~ - s/(^\+.*) {8,8}+\t/$1\t\t/) {} + s/(^\+.*) {8,8}\t/$1\t\t/) {} while ($fixed[$fixlinenr] =~ s/(^\+.*) +\t/$1\t/) {} }
Re: [PATCH] checkpatch: Remove unnecessary + after {8,8}
Quoted 11 lines · Joe Perches
There's a useless "+" use that needs to be removed as perl 5.20 emits a "Useless use of greediness modifier '+'" message each time it's hit.
Reported-by Greg KH <[email protected]>Signed-off-by Joe Perches <[email protected]>---
Quoted 1 line · Greg KH
Ok, with linux-next I get the same thing:
Thanks Greg.
Very nice, thanks for this:
Re: [PATCH] checkpatch: Remove unnecessary + after {8,8}
In reply to Joe PerchesHi Joe,
Quoted 3 lines · Joe Perches
There's a useless "+" use that needs to be removed as perl 5.20 emits a "Useless use of greediness modifier '+'" message each time it's hit.
I saw this Perl warning today as well and wondered whether this patch is coming or not. Apparently it's not in linux-next (yet).
Thanks,
Sören
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Joe Perches
maintainerPATCH RESEND 1/1 checkpatch: Remove unnecessary + after {8,8}
In reply to Greg KHThere's a useless "+" use that needs to be removed as perl 5.20 emits a "Useless use of greediness modifier '+'" message each time it's hit.
---
Resending, maybe Andrew's all-seeing eye blinked...
Quoted 1 line · Greg KH
Ok, with linux-next I get the same thing:
Thanks Greg.
scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
@@ -2376,7 +2376,7 @@ sub process { "please, no space before tabs\n" . $herevet) && $fix) { while ($fixed[$fixlinenr] =~ - s/(^\+.*) {8,8}+\t/$1\t\t/) {} + s/(^\+.*) {8,8}\t/$1\t\t/) {} while ($fixed[$fixlinenr] =~ s/(^\+.*) +\t/$1\t/) {} }
Re: [PATCH - resend] checkpatch: Remove unnecessary + after {8,8}
Hey Andrew,
can we get this one applied already - I'm seeing this warning at least since before my summer vacation started! :-P
Thanks.
Quoted 40 lines · Joe Perches
There's a useless "+" use that needs to be removed as perl 5.20 emits a "Useless use of greediness modifier '+'" message each time it's hit.
Reported-by Greg KH <[email protected]>Signed-off-by Joe Perches <[email protected]>---
Resending, maybe Andrew's all-seeing eye blinked...
Quoted 1 line · Greg KH
Ok, with linux-next I get the same thing:
Thanks Greg.
scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/checkpatch.pl +1
-2@@ -2376,7 +2376,7 @@ sub process { "please, no space before tabs\n" . $herevet) && $fix) { while ($fixed[$fixlinenr] =~ - s/(^\+.*) {8,8}+\t/$1\t\t/) {} + s/(^\+.*) {8,8}\t/$1\t\t/) {} while ($fixed[$fixlinenr] =~ s/(^\+.*) +\t/$1\t/) {} } --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH - resend] checkpatch: Remove unnecessary + after {8,8}
Quoted 4 lines · Borislav Petkov
Hey Andrew,
can we get this one applied already - I'm seeing this warning at least since before my summer vacation started! :-P
Oh ok, so it did go in after 3.17 but when using checkpatch on a 3.17 tree, it fires of course. Maybe the first checkpatch fix to tag for stable?
:-)
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Greg KH
maintainerQuoted 126 lines · Joe Perches
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-nextTo 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.shdrivers/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 <[email protected]>--- scripts/reformat_with_checkpatch.sh | 141 ++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100755 scripts/reformat_with_checkpatch.shscripts/reformat_with_checkpatch.sh new file +88
-0@@ -0,0 +1,141 @@ +#!/bin/bash +# (c) 2014, Joe Perches <[email protected]> +# +# 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 + + ${CROSS_COMPILE}objdump -D $obj | \ + sed "s/^[[:space:]]\+[0-9a-f]\+//" > $obj.old + + patch -p1 < $checkpatch_fixes + + echo "Compiling modified version..." + + ${CROSS_COMPILE}make $obj + + ${CROSS_COMPILE}objdump -D $obj | \ + sed "s/^[[:space:]]\+[0-9a-f]\+//" > $obj.new + + echo "Comparing objects..." + diff -Nurd $obj.new $obj.old + if [ $? -ne 0 ] ; then + echo "Object differences exist! - Verify changes before commit!" + read -s -p "Press the 'enter' key to continue: " + else + echo "No object differences found" + fi + rm -f $obj.old + rm -f $obj.new + fi + + echo "running checkpatch on possible checkpatch fixes..." + + ./scripts/checkpatch.pl --no-summary --no-signoff $checkpatch_fixes + rm -f $checkpatch_fixes + + echo "Verify checkpatch output and make any necessary changes" + echo "Edit '$file' if appropriate" + read -s -p "Press the 'enter' key to continue: " +
scripts/reformat_with_checkpatch.sh line 98
Quoted 10 lines
scripts/reformat_with_checkpatch.sh new file +10
-0+ commit_log_file=$(mktemp git_commit.XXXXXX) + + if [ -e $commit_log_file ] ; then + rm -f $commit_log_file + fi + + if [[ $file =~ ^drivers/staging/ ]] ; then + echo -n "staging: " >> $commit_log_file + fi + echo "$(basename $(dirname $file)): checkpatch cleanup: $desc" >> $commit_log_file
If I pick drivers/staging/lustre/include/linux/lnet/types.h, then I get:
staging: lnet: checkpatch cleanup: whitespace neatening
and no 'types.h' here, is that intentional? If so, why?
And this is fun, I'm going to let this rip on the lustre code...
thanks,
greg k-h
Joe Perches
maintainerQuoted 3 lines · Greg KH
Quoted 2 lines · Joe Perches
A simple script to run checkpatch --fix for various types of of cleanups.
[]
Quoted 5 lines
If I pick
drivers/staging/lustre/include/linux/lnet/types.h, then I get:staging: lnet: checkpatch cleanup: whitespace neatening
and no '
types.h' here, is that intentional? If so, why?
Yes, it's how it's written.
It uses just the directory name, not any basename($file)
It can be changed if that's what's desired.
Quoted 1 line
And this is fun, I'm going to let this rip on the lustre code...
It doesn't autocommit, it does show the various changes it makes and asks you to accept them.
I suppose that could be automated with something better than "yes", but I didn't want it to be completely automatic.
Greg KH
maintainerQuoted 82 lines · Joe Perches
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-nextTo 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.shdrivers/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 <[email protected]>--- scripts/reformat_with_checkpatch.sh | 141 ++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100755 scripts/reformat_with_checkpatch.shscripts/reformat_with_checkpatch.sh new file +44
-0@@ -0,0 +1,141 @@ +#!/bin/bash +# (c) 2014, Joe Perches <[email protected]> +# +# 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
scripts/reformat_with_checkpatch.sh line 54
Quoted 10 lines
scripts/reformat_with_checkpatch.sh new file +10
-0+ + 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
Joe Perches
maintainerQuoted 3 lines · Greg KH
Quoted 2 lines · Joe Perches
A simple script to run checkpatch --fix for various types of of cleanups.
[]
Quoted 2 lines
Anyway, try running this script on
drivers/staging/lustre/lnet/lnet/acceptor.cto see how this build fails.
lustre doesn't use "normal" kernel makefiles.
I supposed that the entire staging/lustre/ path could be built for every change, but for most of staging, and nearly all of the rest of the kernel tree, using:
make <path>file.o
works.
I know there can be many enhancements to the reformat script, but I think a minimally acceptable version is a decent start.
So, thanks for trying it out.
And keep the complaints coming.
cheers, Joe
Greg KH
maintainerQuoted 9 lines · Joe Perches
Quoted 3 lines · Greg KH
Quoted 2 lines · Joe Perches
A simple script to run checkpatch --fix for various types of of cleanups.
[]
Quoted 2 lines
Anyway, try running this script on
drivers/staging/lustre/lnet/lnet/acceptor.cto see how this build fails.lustre doesn't use "normal" kernel makefiles.
Well, it does, it just has a:
subdir-ccflags-y := -I$(src)/include/
line in drivers/staging/lustre/Makefile that messes up making .o files in subdirectories.
I'll go fix that include file mess up now to be able to remove that line so the the .o file building will work.
thanks,
greg k-h
Greg KH
maintainerQuoted 9 lines · Joe Perches
Quoted 3 lines · Greg KH
Quoted 2 lines · Joe Perches
A simple script to run checkpatch --fix for various types of of cleanups.
[]
Quoted 2 lines
Anyway, try running this script on
drivers/staging/lustre/lnet/lnet/acceptor.cto see how this build fails.lustre doesn't use "normal" kernel makefiles.
Ok, I've fixed all of the lustre Makefile crud up and checked it into my staging-next branch. In doing so, it exposed just what a horrid mess the lustre include files are, which is good, hopefully people will notice and start fixing it up.
And with the fixes, this script now properly can build and test lustre files.
thanks,
greg k-h
Greg KH
maintainerQuoted 18 lines · Joe Perches
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-nextTo use this script try a sequence of commands like:
Quoted 7 lines
cd <
linux_repository>
git checkout -b <your_branch>
make allyesconfig
mkdir patches
./scripts/reformat_with_checkpatch.shdrivers/staging/<dir>/*.[ch] git format-patch --cover-letter -o patches/<your_branch> staging-next git send-email patches/<your_branch>
When running this on drivers/base/bus.c, it says that the .o files are different, when the diffstat for what makes them different is only whitespace.
I did the following:
$ scripts/reformat_with_checkpatch.sh drivers/base/bus.c
Ignore the first set of things it tries to commit by answering N to the "Would you like to commit these changes".
Then the second thing it tries to change in the file says that there is a .o file difference.
Yet the diff is below, I don't see how this happens. Is this due to there being some old temp file around because I did not accept the first set of changes?
thanks,
greg k-h
-------------
diff:
drivers/base/bus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/bus.c +2 -1
@@ -32,7 +32,6 @@ static struct kset *system_kset;#define to_drv_attr (_attr) container_of(_attr, struct driver_attribute, attr) -static int __must_check bus_rescan_devices_helper (struct device *dev,void *data);
@@ -128,6 +127,7 @@ static const struct sysfs_ops bus_sysfs_ops = {int bus_create_file (struct bus_type *bus,struct bus_attribute *attr) {int error; +if (bus_get (bus)) { error =sysfs_create_file (&bus->p->subsys.kobj, &attr->attr);bus_put (bus);
@@ -817,6 +817,7 @@ EXPORT_SYMBOL_GPL(device_reprobe);struct bus_type *find_bus (char *name) {struct kobject *k =kset_find_obj (bus_kset, name); +return k ?to_bus (k) :NULL ; }#endif /* 0 */
--------------
What the script complained about:
Comparing objects...
base/bus.o.old renamed from base/bus.o.new +3 -3
@@ -2449,13 +2449,13 @@ 0000000000000000 <descriptor.17493>: ... -: bf 03 00 00 00 mov $0x3,%edi +: be 03 00 00 00 mov $0x3,%esi : 00 00 add %al,(%rax) ... 0000000000000028 <descriptor.17483>: ... -: a2 03 00 00 00 00 00 movabs %al,0x3 +: a1 03 00 00 00 00 00 movabs 0x3,%eax : 00 00 0000000000000050 <descriptor.17406>:
@@ -2468,7 +2468,7 @@ 0000000000000078 <descriptor.17073>: ... -: 56 push %rsi +: 57 push %rdi : 00 00 add %al,(%rax) : 00 00 add %al,(%rax) : 00 00 add %al,(%rax)
Object differences exist! - Verify changes before commit!
Joe Perches
maintainerQuoted 3 lines · Greg KH
Quoted 2 lines · Joe Perches
A simple script to run checkpatch --fix for various types of of cleanups.
[]
Quoted 7 lines
I did the following:
$ scripts/reformat_with_checkpatch.sh drivers/base/bus.cIgnore the first set of things it tries to commit by answering N to the "Would you like to commit these changes".
Quoted 6 lines
Then the second thing it tries to change in the file says that there is a .o file difference.
Yet the diff is below, I don't see how this happens. Is this due to there being some old temp file around because I did not accept the first set of changes?
[]
Quoted 30 lines
What the script complained about:
Comparing objects...
base/bus.o.old renamed from base/bus.o.new +3
-3@@ -2449,13 +2449,13 @@ 0000000000000000 <descriptor.17493>: -: bf 03 00 00 00 mov $0x3,%edi +: be 03 00 00 00 mov $0x3,%esi : 00 00 add %al,(%rax) 0000000000000028 <descriptor.17483>: -: a2 03 00 00 00 00 00 movabs %al,0x3 +: a1 03 00 00 00 00 00 movabs 0x3,%eax : 00 00 0000000000000050 <descriptor.17406>:@@ -2468,7 +2468,7 @@ 0000000000000078 <descriptor.17073>: -: 56 push %rsi +: 57 push %rdi : 00 00 add %al,(%rax) : 00 00 add %al,(%rax) : 00 00 add %al,(%rax)
Quoted 3 lines
Object differences exist! - Verify changes before commit!
I've no real idea, but this looks more like
non-repeatable gcc compilation output to me.
Here's my script output from that sequence.
$ gcc --version gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ scripts/reformat_with_checkpatch.sh drivers/base/bus.c file: <drivers/base/bus.c> description: <whitespace neatening> types:<spacing,space_before_tab,pointer_location,trailing_whitespace,bracket_space> total: 0 errors, 0 warnings, 0 checks, 1272 lines checked
NOTE: Used message types: BRACKET_SPACE POINTER_LOCATION SPACE_BEFORE_TAB SPACING TRAILING_WHITESPACE
drivers/base/bus.c has no obvious style problems and is ready for submission.
file: <drivers/base/bus.c> description: <remove spaces before tabs> types:<space_before_tab>
total: 0 errors, 0 warnings, 0 checks, 1272 lines checked
NOTE: Used message types: SPACE_BEFORE_TAB
drivers/base/bus.c has no obvious style problems and is ready for submission.
file: <drivers/base/bus.c> description: <fix label positions> types:<indented_label>
total: 0 errors, 0 warnings, 0 checks, 1272 lines checked
NOTE: Used message types: INDENTED_LABEL
drivers/base/bus.c has no obvious style problems and is ready for submission.
file: <drivers/base/bus.c> description: <align arguments to parenthesis> types:<parenthesis_alignment>
CHECK: Alignment should match open parenthesis
#37: FILE: drivers/base/bus.c:37:
+static int __must_check bus_rescan_devices_helper(struct device *dev,
+ void *data);
CHECK: Alignment should match open parenthesis
#518: FILE: drivers/base/bus.c:518:
+ error = sysfs_create_link(&bus->p->devices_kset->kobj,
+ &dev->kobj, dev_name(dev));
CHECK: Alignment should match open parenthesis
#522: FILE: drivers/base/bus.c:522:
+ error = sysfs_create_link(&dev->kobj,
+ &dev->bus->p->subsys.kobj, "subsystem");
CHECK: Alignment should match open parenthesis
#701: FILE: drivers/base/bus.c:701:
+ printk(KERN_ERR "%s: uevent attr (%s) failed\n",
+ __func__, drv->name);
CHECK: Alignment should match open parenthesis
#707: FILE: drivers/base/bus.c:707:
+ printk(KERN_ERR "%s: driver_create_groups(%s) failed\n",
+ __func__, drv->name);
CHECK: Alignment should match open parenthesis
#715: FILE: drivers/base/bus.c:715:
+ printk(KERN_ERR "%s: add_bind_files(%s) failed\n",
+ __func__, drv->name);
CHECK: Alignment should match open parenthesis
#1003: FILE: drivers/base/bus.c:1003:
+ int (*compare)(const struct device *a,
+ const struct device *b))
total: 0 errors, 0 warnings, 7 checks, 1272 lines checked
NOTE: Used message types: PARENTHESIS_ALIGNMENT
Wrote EXPERIMENTAL --fix correction(s) to 'drivers/base/bus.c'
Do _NOT_ trust the results written to this file.
Do _NOT_ submit these changes without inspecting them for correctness.
This EXPERIMENTAL file is simply a convenience to help rewrite patches. No warranties, expressed or implied...
drivers/base/bus.c has style problems, please review.
If any of these errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. Compiling original version...
HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf scripts/kconfig/conf --silentoldconfig Kconfig CHK include/config/kernel.release make[1]: `all' is up to date. CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h CC arch/x86/kernel/asm-offsets.s GEN include/generated/asm-offsets.h CALL scripts/checksyscalls.sh CC drivers/base/bus.o
patching file drivers/base/bus.c
Compiling modified version...
CHK include/config/kernel.release
make[1]: `all' is up to date.
CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h CALL scripts/checksyscalls.sh CC drivers/base/bus.o
Comparing objects...
No object differences found
running checkpatch on possible checkpatch fixes...
WARNING: line over 80 characters
#27: FILE: drivers/base/bus.c:522:
+ &dev->bus->p->subsys.kobj, "subsystem");
drivers/base/bus.c.diff has style problems, please review.
If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
Verify checkpatch output and make any necessary changes
Edit 'drivers/base/bus.c' if appropriate
Press the 'enter' key to continue: diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 83e910a..a9d5825 100644
drivers/base/bus.c +7 -7
@@ -34,7 +34,7 @@ static struct kset *system_kset;static int __must_check bus_rescan_devices_helper (struct device *dev, -void *data); +void *data);static struct bus_type *bus_get (struct bus_type *bus) {
@@ -515,11 +515,11 @@ int bus_add_device(struct device *dev)if (error) goto out_groups; error =sysfs_create_link (&bus->p->devices_kset->kobj, - &dev->kobj,dev_name (dev)); + &dev->kobj,dev_name (dev));if (error) goto out_id; error =sysfs_create_link (&dev->kobj, - &dev->bus->p->subsys.kobj,"subsystem" ); + &dev->bus->p->subsys.kobj,"subsystem" );if (error) goto out_subsys;klist_add_tail (&dev->p->knode_bus, &bus->p->klist_devices);
@@ -698,13 +698,13 @@ int bus_add_driver(struct device_driver *drv) error =driver_create_file (drv, &driver_attr_uevent);if (error) {printk (KERN_ERR "%s: uevent attr (%s) failed\n" , - __func__, drv->name); + __func__, drv->name); } error =driver_add_groups (drv, bus->drv_groups);if (error) {/* How the hell do we get out of this pickle? Give up */ printk (KERN_ERR "%s: driver_create_groups(%s) failed\n" , - __func__, drv->name); + __func__, drv->name); }if (!drv->suppress_bind_attrs) {
@@ -712,7 +712,7 @@ int bus_add_driver(struct device_driver *drv)if (error) {/* Ditto */ printk (KERN_ERR "%s: add_bind_files(%s) failed\n" , - __func__, drv->name); + __func__, drv->name); } }
@@ -1000,7 +1000,7 @@ EXPORT_SYMBOL_GPL(bus_get_device_klist);*/ static void device_insertion_sort_klist (struct device *a,struct list_head *list,int (*compare)(const struct device *a, -const struct device *b)) +const struct device *b)) {struct list_head *pos;struct klist_node *n;
Ready to commit - First verify all diffs and make any necessary changes
Would you like to commit these changes <y>: n
file: <drivers/base/bus.c> description: <fix brace positions> types:<open_brace,braces,else_after_brace,while_after_brace>
CHECK: braces {} should be used on all arms of this statement
#131: FILE: drivers/base/bus.c:131:
+ if (bus_get(bus)) {
[...]
+ } else
[...]
total: 0 errors, 0 warnings, 1 checks, 1272 lines checked
NOTE: Used message types: BRACES ELSE_AFTER_BRACE OPEN_BRACE WHILE_AFTER_BRACE
drivers/base/bus.c has style problems, please review.
If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
file: <drivers/base/bus.c> description: <fix blank lines> types:<line_spacing>
CHECK: Please don't use multiple blank lines
#35: FILE: drivers/base/bus.c:35:
+
+
WARNING: Missing a blank line after declarations
#131: FILE: drivers/base/bus.c:131:
+ int error;
+ if (bus_get(bus)) {
WARNING: Missing a blank line after declarations
#820: FILE: drivers/base/bus.c:820:
+ struct kobject *k = kset_find_obj(bus_kset, name);
+ return k ? to_bus(k) : NULL;
total: 0 errors, 2 warnings, 1 checks, 1272 lines checked
NOTE: Used message types: LINE_SPACING
Wrote EXPERIMENTAL --fix correction(s) to 'drivers/base/bus.c'
Do _NOT_ trust the results written to this file.
Do _NOT_ submit these changes without inspecting them for correctness.
This EXPERIMENTAL file is simply a convenience to help rewrite patches. No warranties, expressed or implied...
drivers/base/bus.c has style problems, please review.
If any of these errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. Compiling original version...
CHK include/config/kernel.release
make[1]: `all' is up to date.
CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h CALL scripts/checksyscalls.sh CC drivers/base/bus.o
patching file drivers/base/bus.c
Compiling modified version...
CHK include/config/kernel.release
make[1]: `all' is up to date.
CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h CALL scripts/checksyscalls.sh CC drivers/base/bus.o
Comparing objects...
No object differences found
running checkpatch on possible checkpatch fixes... drivers/base/bus.c.diff has no obvious style problems and is ready for submission. Verify checkpatch output and make any necessary changes
Edit 'drivers/base/bus.c' if appropriate
Press the 'enter' key to continue: diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 83e910a..3546d02 100644
drivers/base/bus.c +2 -1
@@ -32,7 +32,6 @@ static struct kset *system_kset;#define to_drv_attr (_attr) container_of(_attr, struct driver_attribute, attr) -static int __must_check bus_rescan_devices_helper (struct device *dev,void *data);
@@ -128,6 +127,7 @@ static const struct sysfs_ops bus_sysfs_ops = {int bus_create_file (struct bus_type *bus,struct bus_attribute *attr) {int error; +if (bus_get (bus)) { error =sysfs_create_file (&bus->p->subsys.kobj, &attr->attr);bus_put (bus);
@@ -817,6 +817,7 @@ EXPORT_SYMBOL_GPL(device_reprobe);struct bus_type *find_bus (char *name) {struct kobject *k =kset_find_obj (bus_kset, name); +return k ?to_bus (k) :NULL ; }#endif /* 0 */
Ready to commit - First verify all diffs and make any necessary changes
Would you like to commit these changes <y>: