public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch]clarification of coding style regarding conditional statements with two branches
@ 2007-05-04  7:26 Oliver Neukum
  2007-05-04 14:48 ` Jiri Slaby
  0 siblings, 1 reply; 6+ messages in thread
From: Oliver Neukum @ 2007-05-04  7:26 UTC (permalink / raw)
  To: linux-kernel

Hi,

I suggest that the coding style should state that if either branch of
an 'if' statement needs braces, both branches should use them.

	Regards
		Oliver
Signed-off-by: Oliver Neukum <oneukum@suse.de>
----

--- a/Documentation/CodingStyle	2007-04-20 13:08:17.000000000 +0200
+++ b/Documentation/CodingStyle	2007-04-20 13:16:14.000000000 +0200
@@ -160,6 +160,21 @@
 25-line terminal screens here), you have more empty lines to put
 comments on.
 
+Do not unnecessarily use braces where a single statement will do.
+
+if (condition)
+	action();
+
+This does not apply if one branch of a conditional statement is a single
+statement. Use braces in both branches.
+
+if (condition) {
+	do_this();
+	do_that();
+} else {
+	otherwise();
+}
+
 		3.1:  Spaces
 
 Linux kernel style for use of spaces depends (mostly) on

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

end of thread, other threads:[~2007-05-04 21:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-04  7:26 [patch]clarification of coding style regarding conditional statements with two branches Oliver Neukum
2007-05-04 14:48 ` Jiri Slaby
2007-05-04 15:29   ` Oliver Neukum
2007-05-04 16:24     ` Jiri Slaby
2007-05-04 16:16   ` Krzysztof Halasa
2007-05-04 21:16   ` Jan Engelhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox