All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel]  [PATCH RFC v2] scripts/checkpatch.pl: Bug fix
@ 2018-03-19 16:22 Su Hang
  2018-03-19 17:19 ` no-reply
  0 siblings, 1 reply; 2+ messages in thread
From: Su Hang @ 2018-03-19 16:22 UTC (permalink / raw)
  To: eblake, vsementsov; +Cc: qemu-devel

Commit 2b9aef6fcd96ba7ed8c1ee723e391901852d344c introduced a regression:
checkpatch.pl started complaining about the following valid pattern:
do {
     /* something */
} while (condition);

Fix the script to once again permit this pattern.

---
v1: fix bug.
v2: correct inappropriate patch description.

Signed-off-by: Su Hang <suhang16@mails.ucas.ac.cn>
---
 scripts/checkpatch.pl | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 57daae05ea18..d52207a3cc9d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2356,6 +2356,18 @@ sub process {
 # check for missing bracing around if etc
 		if ($line =~ /(^.*)\b(?:if|while|for)\b/ &&
 			$line !~ /\#\s*if/) {
+			my $allowed = 0;
+
+			# Check the pre-context.
+			if ($line =~ /(\}.*?)$/) {
+				my $pre = $1;
+
+				if ($line !~ /else/) {
+					print "APW: ALLOWED: pre<$pre> line<$line>\n"
+						if $dbg_adv_apw;
+					$allowed = 1;
+				}
+			}
 			my ($level, $endln, @chunks) =
 				ctx_statement_full($linenr, $realcnt, 1);
                         if ($dbg_adv_apw) {
@@ -2364,7 +2376,6 @@ sub process {
                                 if $#chunks >= 1;
                         }
 			if ($#chunks >= 0 && $level == 0) {
-				my $allowed = 0;
 				my $seen = 0;
 				my $herectx = $here . "\n";
 				my $ln = $linenr - 1;
@@ -2408,7 +2419,7 @@ sub process {
                                             $allowed = 1;
 					}
 				}
-				if ($seen != ($#chunks + 1)) {
+				if ($seen != ($#chunks + 1) && !$allowed) {
 					ERROR("braces {} are necessary for all arms of this statement\n" . $herectx);
 				}
 			}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH RFC v2] scripts/checkpatch.pl: Bug fix
  2018-03-19 16:22 [Qemu-devel] [PATCH RFC v2] scripts/checkpatch.pl: Bug fix Su Hang
@ 2018-03-19 17:19 ` no-reply
  0 siblings, 0 replies; 2+ messages in thread
From: no-reply @ 2018-03-19 17:19 UTC (permalink / raw)
  To: suhang16; +Cc: famz, eblake, vsementsov, qemu-devel

Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 1521476567-21818-1-git-send-email-suhang16@mails.ucas.ac.cn
Subject: [Qemu-devel]  [PATCH RFC v2] scripts/checkpatch.pl: Bug fix

=== 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
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/1521476567-21818-1-git-send-email-suhang16@mails.ucas.ac.cn -> patchew/1521476567-21818-1-git-send-email-suhang16@mails.ucas.ac.cn
 t [tag update]            patchew/20180319131743.3885-1-peter.maydell@linaro.org -> patchew/20180319131743.3885-1-peter.maydell@linaro.org
 * [new tag]               patchew/20180319161556.16446-1-peter.maydell@linaro.org -> patchew/20180319161556.16446-1-peter.maydell@linaro.org
Switched to a new branch 'test'
b098aef89b scripts/checkpatch.pl: Bug fix

=== OUTPUT BEGIN ===
Checking PATCH 1/1: scripts/checkpatch.pl: Bug fix...
WARNING: line over 80 characters
#31: FILE: scripts/checkpatch.pl:2366:
+					print "APW: ALLOWED: pre<$pre> line<$line>\n"

ERROR: Missing Signed-off-by: line(s)

total: 1 errors, 1 warnings, 33 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] 2+ messages in thread

end of thread, other threads:[~2018-03-20  1:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19 16:22 [Qemu-devel] [PATCH RFC v2] scripts/checkpatch.pl: Bug fix Su Hang
2018-03-19 17:19 ` no-reply

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.