mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oliver Neukum <oliver@neukum.org>
To: linux-kernel@vger.kernel.org
Subject: [patch]clarification of coding style regarding conditional statements with two branches
Date: Fri, 4 May 2007 09:26:55 +0200	[thread overview]
Message-ID: <200705040926.55257.oliver@neukum.org> (raw)

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

             reply	other threads:[~2007-05-04  7:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-04  7:26 Oliver Neukum [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200705040926.55257.oliver@neukum.org \
    --to=oliver@neukum.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®