From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N1E3r-0004Ux-R1 for qemu-devel@nongnu.org; Fri, 23 Oct 2009 02:55:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N1E3r-0004Ud-8Z for qemu-devel@nongnu.org; Fri, 23 Oct 2009 02:55:43 -0400 Received: from [199.232.76.173] (port=48134 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1E3r-0004Ua-3Y for qemu-devel@nongnu.org; Fri, 23 Oct 2009 02:55:43 -0400 Received: from hall.aurel32.net ([88.191.82.174]:33510) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N1E3q-00040K-KF for qemu-devel@nongnu.org; Fri, 23 Oct 2009 02:55:42 -0400 Date: Fri, 23 Oct 2009 08:55:39 +0200 From: Aurelien Jarno Subject: Re: [Qemu-devel] CODING_STYLE and if blocks Message-ID: <20091023065539.GA827@hall.aurel32.net> References: <20091022220153.GB10700@volta.aurel32.net> <4AE0DFB8.2070804@codemonkey.ws> <2D5CAF48-D135-41CD-BB7E-8149B8B2863E@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <2D5CAF48-D135-41CD-BB7E-8149B8B2863E@suse.de> Sender: Aurelien Jarno List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: qemu-devel@nongnu.org On Fri, Oct 23, 2009 at 01:47:04AM +0200, Alexander Graf wrote: > > On 23.10.2009, at 00:42, Anthony Liguori wrote: > >> Aurelien Jarno wrote: >>> Hi all, >>> >>> I am currently reviewing the S390 patches which extensively use of >>> code like: >>> >>> if (a == 5) printf("a was 5.\n"); >>> else if (a == 6) printf("a was 6.\n"); >>> else printf("a was something else entirely.\n"); >>> >>> It is something currently allowed by the CODING_STYLE document >>> (there is >>> no "indented statement"), but I am not fully comfortable with it. >>> Should >>> we accept such code? Should we fix CODING_STYLE? >>> >> >> I'd vote for fixing CODING_STYLE as that syntax makes my eyes hurt. >> >> While CODING_STYLE is there as a guideline, good taste should still >> always prevail :-) > > I think Uli only wrote the code as is because CODING_STYLE told him to > always use braces around one-liner statements. I don't see how > > if (a == 5) > printf("a was 5.\n"); > else if (a == 6) > printf("a was 6.\n"); > else > printf("a was something else entirely.\n"); > > would be not readable. In fact I tend to use that code style myself a > lot in places where it makes sense like: > > if (r < 0) > return r; > > It would really hurt my eyes to have braces on these simple ifs every > single time. > It has been debated already a few times already, the argument against this it that it make patches more difficulty readable. -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net