[PATCH] CodingStyle: proscribe do-while without braces.

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: Andrew Morton <akpm@...>, Linus Torvalds <torvalds@...>, <linux-sparse@...>
Date: Thursday, July 26, 2007 - 5:37 pm

Sparse warns about do-while loops without braces; Linus's rationale from the
Sparse Git changelog:

Signed-off-by: Josh Triplett <josh@kernel.org>
---
 Documentation/CodingStyle |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
index 7f1730f..f12e4b8 100644
--- a/Documentation/CodingStyle
+++ b/Documentation/CodingStyle
@@ -175,6 +175,13 @@ if (condition) {
 	otherwise();
 }
 
+This also does not apply to a do-while loop; always use braces with a do-while,
+even if it contains a single statement:
+
+do {
+	this();
+} while(condition);
+
 		3.1:  Spaces
 
 Linux kernel style for use of spaces depends (mostly) on
-- 
1.5.2.1


-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] CodingStyle: proscribe do-while without braces., Josh Triplett, (Thu Jul 26, 5:37 pm)
Re: [PATCH] CodingStyle: proscribe do-while without braces., Krzysztof Halasa, (Thu Jul 26, 8:18 pm)
Re: [PATCH] CodingStyle: proscribe do-while without braces., Krzysztof Halasa, (Fri Jul 27, 12:00 pm)
Re: [PATCH] CodingStyle: proscribe do-while without braces., Krzysztof Halasa, (Fri Jul 27, 1:44 pm)