qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 RFC] scripts/checkpatch.pl: add check for `while` and `for`
@ 2018-02-26  2:53 Su Hang
  2018-02-27 17:32 ` Stefan Hajnoczi
  0 siblings, 1 reply; 5+ messages in thread
From: Su Hang @ 2018-02-26  2:53 UTC (permalink / raw)
  To: thuth, eblake, stefanha; +Cc: qemu-devel

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH RFC] scripts/checkpatch.pl:Add check for `while` and `for`
@ 2018-02-24 13:54 Su Hang
  2018-02-25  3:13 ` [Qemu-devel] [PATCH v2 " Su Hang
  0 siblings, 1 reply; 5+ 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] 5+ messages in thread

end of thread, other threads:[~2018-02-28  9:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-26  2:53 [Qemu-devel] [PATCH v2 RFC] scripts/checkpatch.pl: add check for `while` and `for` Su Hang
2018-02-27 17:32 ` Stefan Hajnoczi
2018-02-27 17:42   ` Peter Maydell
2018-02-28  9:50     ` Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2018-02-24 13:54 [Qemu-devel] [PATCH RFC] scripts/checkpatch.pl:Add " Su Hang
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).