linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] CodingStyle: proscribe do-while without braces.
@ 2007-07-26 21:37 Josh Triplett
  2007-07-26 21:44 ` Andrew Morton
  2007-07-27  0:18 ` Krzysztof Halasa
  0 siblings, 2 replies; 16+ messages in thread
From: Josh Triplett @ 2007-07-26 21:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton, Linus Torvalds, linux-sparse

Sparse warns about do-while loops without braces; Linus's rationale from the
Sparse Git changelog:
> Add warning message for naked do-while
>
> Does it necessarily make sense? Dunno, but it does tend to be bad
> practice, or at least result in code that can be hard to mentally parse.
>
> Maybe that mental parsing is just me.	 Or maybe it should be warned
> about. You decide.

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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2007-07-27 18:51 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-26 21:37 [PATCH] CodingStyle: proscribe do-while without braces Josh Triplett
2007-07-26 21:44 ` Andrew Morton
2007-07-26 21:54   ` Josh Triplett
2007-07-27  0:18 ` Krzysztof Halasa
2007-07-27  0:35   ` Andrew Morton
2007-07-27 16:00     ` Krzysztof Halasa
2007-07-27 17:05       ` Josh Triplett
2007-07-27 17:44         ` Krzysztof Halasa
2007-07-27 18:27         ` Andrew Morton
2007-07-27 18:52           ` Josh Triplett
2007-07-27  0:42   ` Stefan Richter
2007-07-27  0:59     ` Andrew Morton
2007-07-27  7:41       ` Stefan Richter
2007-07-27  7:53         ` Andrew Morton
2007-07-27 17:13           ` Stefan Richter
2007-07-27  1:17     ` Randy Dunlap

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