qemu-trivial
[Top][All Lists]
Advanced

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

[Qemu-trivial] [PATCH 4/3] checkpatch: Enforce proper do/while (0) style


From: Eric Blake
Subject: [Qemu-trivial] [PATCH 4/3] checkpatch: Enforce proper do/while (0) style
Date: Thu, 30 Nov 2017 08:01:54 -0600

while (0) is only idiomatic in a macro definition, where the caller
will be supplying the trailing ';'.  Warn if the macro has a duplicate.

Signed-off-by: Eric Blake <address@hidden>
---
 scripts/checkpatch.pl | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 34df753571..acb66bff34 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1622,6 +1622,11 @@ sub process {
                        }
                }

+# 'while (0);' is odd; only macros should use while (0), without trailing ;
+               if ($line =~ /while\s*\(0\);/) {
+                       ERROR("suspicious ; after while (0)\n" . $herecurr);
+               }
+
 # Check relative indent for conditionals and blocks.
                if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ 
/^.\s*#/ && $line !~ /\}\s*while\s*/) {
                        my ($s, $c) = ($stat, $cond);
-- 
2.14.3




reply via email to

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