qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 RFC] scripts/checkpatch.pl: add check for `while`


From: Su Hang
Subject: [Qemu-devel] [PATCH v2 RFC] scripts/checkpatch.pl: add check for `while` and `for`
Date: Mon, 26 Feb 2018 10:53:18 +0800

Add 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.

Suggested-by: Eric Blake <address@hidden>
Suggested-by: Thomas Huth <address@hidden>
Signed-off-by: Su Hang <address@hidden>
---
 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1b4b812e28fa..10c138344fa9 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(for|while|if)\b/ &&
+                       $line !~ /\#\s*(for|while|if)/) {
                        my ($level, $endln, @chunks) =
                                ctx_statement_full($linenr, $realcnt, 1);
                         if ($dbg_adv_apw) {
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]