From owner-freebsd-current Thu May 30 8: 1:40 2002 Delivered-To: freebsd-current@freebsd.org Received: from mail.speakeasy.net (mail14.speakeasy.net [216.254.0.214]) by hub.freebsd.org (Postfix) with ESMTP id DBFDC37B40B for ; Thu, 30 May 2002 08:00:13 -0700 (PDT) Received: (qmail 11313 invoked from network); 30 May 2002 15:00:12 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) by mail14.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 30 May 2002 15:00:12 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.11.6/8.11.6) with ESMTP id g4UF0RF32712; Thu, 30 May 2002 11:00:27 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <200205292053.g4TKrjqh063138@apollo.backplane.com> Date: Thu, 30 May 2002 10:59:52 -0400 (EDT) From: John Baldwin To: Matthew Dillon Subject: Re: Seeking OK to commit KSE MIII Cc: FreeBSD current users Cc: FreeBSD current users , "David O'Brien" , Julian Elischer Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 or is multi-line, or 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 <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message