* [Qemu-devel] [PATCH RFC] scripts/checkpatch.pl:Add check for `while` and `for`
@ 2018-02-24 13:54 Su Hang
2018-02-24 19:20 ` no-reply
2018-02-25 3:13 ` [Qemu-devel] [PATCH v2 " Su Hang
0 siblings, 2 replies; 3+ messages in thread
From: Su Hang @ 2018-02-24 13:54 UTC (permalink / raw)
To: thuth, stefanha, eblake; +Cc: qemu-devel
Add check for `while` and `for` statement, which condition has more than
one line.
The former checkpatch.pl can check `if` statement, which condition has more
than one line, whether block misses brace round, like this:
'''
if (cond1 ||
cond2)
statement;
'''
But it doesn't do the same check for `for` and `while`.
Suggested-by: Eric Blake <eblake@redhat.com>
Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Su Hang <suhang16@mails.ucas.ac.cn>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1b4b812e28fa..cfe7e77d156f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2353,7 +2353,7 @@ sub process {
}
# check for missing bracing round if etc
- if ($line =~ /(^.*)\bif\b/ && $line !~ /\#\s*if/) {
+ if ($line =~ /(^.*)\b(if|for|while)\b/ && $line !~ /\#\s*(if|for|while)/) {
my ($level, $endln, @chunks) =
ctx_statement_full($linenr, $realcnt, 1);
if ($dbg_adv_apw) {
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH RFC] scripts/checkpatch.pl:Add check for `while` and `for`
2018-02-24 13:54 [Qemu-devel] [PATCH RFC] scripts/checkpatch.pl:Add check for `while` and `for` Su Hang
@ 2018-02-24 19:20 ` no-reply
2018-02-25 3:13 ` [Qemu-devel] [PATCH v2 " Su Hang
1 sibling, 0 replies; 3+ messages in thread
From: no-reply @ 2018-02-24 19:20 UTC (permalink / raw)
To: suhang16; +Cc: famz, thuth, stefanha, eblake, qemu-devel
Hi,
This series seems to have some coding style problems. See output below for
more information:
Type: series
Message-id: 1519480458-9573-1-git-send-email-suhang16@mails.ucas.ac.cn
Subject: [Qemu-devel] [PATCH RFC] scripts/checkpatch.pl:Add check for `while` and `for`
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
d557d98ca9 scripts/checkpatch.pl:Add check for `while` and `for`
=== OUTPUT BEGIN ===
Checking PATCH 1/1: scripts/checkpatch.pl:Add check for `while` and `for`...
ERROR: line over 90 characters
#32: FILE: scripts/checkpatch.pl:2356:
+ if ($line =~ /(^.*)\b(if|for|while)\b/ && $line !~ /\#\s*(if|for|while)/) {
total: 1 errors, 0 warnings, 8 lines checked
Your patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH v2 RFC] scripts/checkpatch.pl:Add check for `while` and `for`
2018-02-24 13:54 [Qemu-devel] [PATCH RFC] scripts/checkpatch.pl:Add check for `while` and `for` Su Hang
2018-02-24 19:20 ` no-reply
@ 2018-02-25 3:13 ` Su Hang
1 sibling, 0 replies; 3+ messages in thread
From: Su Hang @ 2018-02-25 3:13 UTC (permalink / raw)
To: thuth, eblake, stefanha; +Cc: qemu-devel
Add check for `while` and `for` statement, which condition has more than
one line.
The former checkpatch.pl can check `if` statement, which condition has more
than one line, whether block misses brace round, like this:
'''
if (cond1 ||
cond2)
statement;
'''
But it doesn't do the same check for `for` and `while` statement.
Suggested-by: Eric Blake <eblake@redhat.com>
Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Su Hang <suhang16@mails.ucas.ac.cn>
---
scripts/checkpatch.pl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1b4b812e28fa..7e332135e177 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2353,7 +2353,8 @@ sub process {
}
# check for missing bracing round if etc
- if ($line =~ /(^.*)\bif\b/ && $line !~ /\#\s*if/) {
+ if ($line =~ /(^.*)\b(if|for|while)\b/ &&
+ $line !~ /\#\s*(if|for|while)/) {
my ($level, $endln, @chunks) =
ctx_statement_full($linenr, $realcnt, 1);
if ($dbg_adv_apw) {
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-25 7:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-24 13:54 [Qemu-devel] [PATCH RFC] scripts/checkpatch.pl:Add check for `while` and `for` Su Hang
2018-02-24 19:20 ` no-reply
2018-02-25 3:13 ` [Qemu-devel] [PATCH v2 " Su Hang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).