public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Clark <Stephen.Clark@seclark.us>
To: Lennart Sorensen <lsorense@csclub.uwaterloo.ca>
Cc: Jeff Garzik <jeff@garzik.org>,
	Randy Dunlap <randy.dunlap@oracle.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: CodingStyle: start flamewar about use of braces
Date: Tue, 08 May 2007 18:50:08 -0400	[thread overview]
Message-ID: <4640FEA0.3020407@seclark.us> (raw)
In-Reply-To: <20070508222540.GG8753@csclub.uwaterloo.ca>

Lennart Sorensen wrote:

>On Tue, May 08, 2007 at 05:19:45PM -0400, Jeff Garzik wrote:
>  
>
>>>>+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 anyone tries to add braces to my code's 'else' statements where they 
>>are not required, that patch will get NAK'd in a heartbeat.
>>    
>>
>
>Oh isn't coding style fun.  I personally hate code that doesn't ALWAYS
>have the braces everywhere since it makes adding a print statement
>or other debuging to the condition such a pain since you then have to
>add braces to the condition to avoid breaking the code just to insert
>a print statement.  It is one of the few things I disagree with in the
>linux kernel coding style.
>
>--
>Len Sorensen
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/
>
>  
>
I agree - it is merely defensive programming to always have the braces, 
it prevents someone
from sticking in a diag and forgetting to add braces so things go haywire.

My $.02
Steve

-- 

"They that give up essential liberty to obtain temporary safety, 
deserve neither liberty nor safety."  (Ben Franklin)

"The course of history shows that as a government grows, liberty 
decreases."  (Thomas Jefferson)




  reply	other threads:[~2007-05-08 22:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200705081903.l48J3AOw010373@hera.kernel.org>
2007-05-08 19:43 ` CodingStyle: start flamewar about use of braces Randy Dunlap
2007-05-08 21:19   ` Jeff Garzik
2007-05-08 22:25     ` Lennart Sorensen
2007-05-08 22:50       ` Stephen Clark [this message]
2007-05-08 23:01         ` Jeff Garzik
2007-05-08 23:37     ` Satyam Sharma
2007-05-09  8:16       ` Stefan Richter
2007-05-09  8:59         ` Pekka Enberg

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=4640FEA0.3020407@seclark.us \
    --to=stephen.clark@seclark.us \
    --cc=jeff@garzik.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lsorense@csclub.uwaterloo.ca \
    --cc=randy.dunlap@oracle.com \
    /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