On 29-May-2002 Matthew Dillon wrote:
>:having said that, 
>:In this case the braces in question in ithread_schedule are:
>:-               } else
>:+               } else {
>:                        curthread->td_kse->ke_flags |= KEF_NEEDRESCHED;
>:+               }
>:I tend to always put braces on the else clause if the 'then' clause
>:has braces.. it just helps me find the end of the if statement.
>:The "if" statement in question was rewritten as part of KSE
>:so Adding the braces on the else clause doesn't seem 'out of scope'
>:to me.. It's not a tremendous obfuscation, because the clause
>:in question needs to be considered to understand the  change..
>     I do this too.  My rule for if() statements 'if (exp) stmt1 else stmt2'
>     in the FreeBSD codebase is:
>     * If <stmt1> or <stmt2> is multi-line, or <exp> is multi-line, then
>       braces are used around both statements, period.
>       Multi-line means:  multiple lines inclusive of any comments, not just
>       the pure C part of it.
>   This is wrong:

This is your opinion not gospel truth.  The reason I and others leave out
braces except when they are needed is to minimize the number of wasted
vertical space so that more code can fit on a screen at a time.  This is
the same reason for using

if (foo) {

Instead of:

if (foo)

However, the real pain here is that basically people go and modify code
they aren't even touching.  If you are modifying the condition of an if()
but not the body then the extra braces are just gratuitous.  You did this
when you went and pushed down Giant in a bunch of the syscalls adding {}'s
around code you weren't directly touching.  Basically then it is rather
tempting to just back them back out again in the next commit to that area
of the code and we keep cycling back and forth which is pretty stupid.

I would just prefer that we leave code as it is unless we actually require
the extra braces because there are multiple statements in the body.  If
you will commit to that I will commit to not removing extra braces that
offend my sensibilities in my commits. :)


John Baldwin <[EMAIL PROTECTED]>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to