mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: Oliver Neukum <oliver@neukum.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [patch]clarification of coding style regarding conditional statements with two branches
Date: Fri, 04 May 2007 16:48:15 +0200	[thread overview]
Message-ID: <463B47AF.4010503@gmail.com> (raw)
In-Reply-To: <200705040926.55257.oliver@neukum.org>

Oliver Neukum napsal(a):
> 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.

Why, what's wrong with
if (condition) {
	do_this();
	do_that();
} else
	otherwise();

? It's more readable/nicer in my eyes than

> +if (condition) {
> +	do_this();
> +	do_that();
> +} else {
> +	otherwise();
> +}
> +

and not only in mine according to fast grep.

regards,
-- 
http://www.fi.muni.cz/~xslaby/            Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E

  reply	other threads:[~2007-05-04 14:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-04  7:26 Oliver Neukum
2007-05-04 14:48 ` Jiri Slaby [this message]
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=463B47AF.4010503@gmail.com \
    --to=jirislaby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver@neukum.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®