public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: linux-kernel@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Teemu Likonen <tlikonen@iki.fi>, Jiri Kosina <jkosina@suse.cz>,
	Dan Carpenter <error27@gmail.com>,
	Martin Olsson <martin@minimum.se>,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH RFC] Codingstyle: allow omitting braces for all single statement branches
Date: Thu, 26 Nov 2009 17:11:28 +0100	[thread overview]
Message-ID: <4B0EA8B0.10703@s5r6.in-berlin.de> (raw)
In-Reply-To: <1259227618-1466-1-git-send-email-u.kleine-koenig@pengutronix.de>

Uwe Kleine-König wrote:
> Grepping for "} else$" in v2.6.32-rc8 yields 6440 hits.  So this seems
> to be common practice and should be allowed.

Flawed reasoning.  Is this in new and otherwise stylistically
well-written code?  Or did you perhaps grep in old code or even in staging?

> checkpatch doesn't warn about both variants.

What checkpatch does/ can do, or doesn't, is only indirectly related to
good style or canonical style.

> --- a/Documentation/CodingStyle
> +++ b/Documentation/CodingStyle
> @@ -168,15 +168,23 @@ 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();
> -}
> +If not all branches of a conditional statement are single statements you might
> +use braces for both branches.
> +
> +	if (condition) {
> +		do_this();
> +		do_that();
> +	} else
> +		otherwise();
> +
> +or
> +
> +	if (condition) {
> +		do_this();
> +		do_that();
> +	} else {
> +		otherwise();
> +	}
>  
>  		3.1:  Spaces
>  

Either don't remove the existing paragraph, or remove it --- but do not
add your new either-or paragraph.  If you consider both variants to be
OK, you don't need to bloat the style guide by documenting them both.
There is no third or fourth alternative.
-- 
Stefan Richter
-=====-==--= =-== ==-=-
http://arcgraph.de/sr/

      parent reply	other threads:[~2009-11-26 16:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-26  9:26 [PATCH RFC] Codingstyle: allow omitting braces for all single statement branches Uwe Kleine-König
2009-11-26 14:52 ` Peter Zijlstra
2009-11-26 16:11 ` Stefan Richter [this message]

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=4B0EA8B0.10703@s5r6.in-berlin.de \
    --to=stefanr@s5r6.in-berlin.de \
    --cc=error27@gmail.com \
    --cc=gitster@pobox.com \
    --cc=jkosina@suse.cz \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin@minimum.se \
    --cc=rdunlap@xenotime.net \
    --cc=tlikonen@iki.fi \
    --cc=u.kleine-koenig@pengutronix.de \
    /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