[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 23/34] checkpatch: add check for `while` and `for`
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 23/34] checkpatch: add check for `while` and `for` |
Date: |
Tue, 6 Mar 2018 14:19:19 +0100 |
From: Su Hang <address@hidden>
Adding check for `while` and `for` statements, 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` statements.
Using `(?:...)` instead of `(...)` in regex pattern catch.
Because `(?:...)` is faster and avoids unwanted side-effect.
Suggested-by: Stefan Hajnoczi <address@hidden>
Suggested-by: Eric Blake <address@hidden>
Suggested-by: Thomas Huth <address@hidden>
Signed-off-by: Su Hang <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
scripts/checkpatch.pl | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a88af61..d1fe79b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2352,8 +2352,9 @@ sub process {
}
}
-# check for missing bracing round if etc
- if ($line =~ /(^.*)\bif\b/ && $line !~ /\#\s*if/) {
+# check for missing bracing around if etc
+ if ($line =~ /(^.*)\b(?:if|while|for)\b/ &&
+ $line !~ /\#\s*if/) {
my ($level, $endln, @chunks) =
ctx_statement_full($linenr, $realcnt, 1);
if ($dbg_adv_apw) {
--
1.8.3.1
- [Qemu-devel] [PULL 15/34] openpic_kvm: drop address_space_to_flatview call, (continued)
- [Qemu-devel] [PULL 15/34] openpic_kvm: drop address_space_to_flatview call, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 19/34] address_space_access_valid: address_space_to_flatview needs RCU lock, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 17/34] address_space_write: address_space_to_flatview needs RCU lock, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 22/34] checkpatch: add a warning for basename/dirname, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 18/34] address_space_read: address_space_to_flatview needs RCU lock, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 16/34] memory: inline some performance-sensitive accessors, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 20/34] address_space_map: address_space_to_flatview needs RCU lock, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 21/34] address_space_rw: address_space_to_flatview needs RCU lock, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 23/34] checkpatch: add check for `while` and `for`,
Paolo Bonzini <=
- [Qemu-devel] [PULL 24/34] Revert "build-sys: compile with -Og or -O1 when --enable-debug", Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 25/34] Fixing WHPX casing to match SDK, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 27/34] Remove unnecessary WHPX __debugbreak();, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 26/34] Resolves WHPX breaking changes in SDK 17095, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 29/34] Fix WHPX typo in 'mmio', Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 30/34] Fix WHPX issue leaking tpr values, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 34/34] use g_path_get_basename instead of basename, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 31/34] WHXP Removes the use of WHvGetExitContextSize, Paolo Bonzini, 2018/03/06
- [Qemu-devel] [PULL 32/34] WHPX improve interrupt notification registration, Paolo Bonzini, 2018/03/06