From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30963 invoked by alias); 13 Jan 2012 11:06:50 -0000 Received: (qmail 30953 invoked by uid 22791); 13 Jan 2012 11:06:49 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL,BAYES_00,FAKE_REPLY_C,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 13 Jan 2012 11:06:33 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0DB67iZ022955 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 13 Jan 2012 06:06:07 -0500 Received: from host2.jankratochvil.net (ovpn-116-21.ams2.redhat.com [10.36.116.21]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0DB61o7010633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 13 Jan 2012 06:06:04 -0500 Date: Fri, 13 Jan 2012 11:09:00 -0000 From: Jan Kratochvil To: Joel Brobecker , Eli Zaretskii Cc: Doug Evans , Paul Pluzhnikov , gdb-patches@sourceware.org Subject: Re: [doc patch] gdbint: braces for two lines in code [Re: [patch] Fix for PR gdb/9538 (loading of separate debuginfo and symlinks).] Message-ID: <20120113110600.GA3501@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <831ur4kot7.fsf@gnu.org> <20120113034602.GS31383@adacore.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00466.txt.bz2 On Fri, 13 Jan 2012 04:46:02 +0100, Joel Brobecker wrote: > My 2 cents: I think it's too trivial to object... I do not think > there are any solid argument in favor of one or the other. A decision > has been made, let's go with it. I was posting the patch more for its language + understandability part. On Fri, 13 Jan 2012 09:08:04 +0100, Eli Zaretskii wrote: > > +@smallexample > > +if (i) > > + @{ > > + /* Return success. */ > > + return 0; > > + @} > > +@end smallexample > > If you really want to make a point that this rule is valid even if the > second line is a comment, then I suggest to say so explicitly in the > text. Two non-comment statements really require a block. It would not work otherwise. The poi > Otherwise, I'd suggest to replace the comment with a non-comment line. The point was the braces should be there even if it is a comment line. This has no compiler justification, it is just the coding style. OK this way? It also addresses: ok: if (i) { /* Here is no operation needed and even if the comment is a single statement braces would be better. */ } not ok: if (i) /* Here is no operation needed and even if the comment is a single statement braces would be better. */; This mail became a real nitpick/bikeshed. Thanks, Jan gdb/doc/ 2012-01-13 Jan Kratochvil * gdbint.texinfo (Coding Standards): Require braces for two lines of code. --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -5849,6 +5849,27 @@ the following guidelines: @tab (pointer dereference) @end multitable +Any two or more lines in code should be wrapped in braces even if one of +them is a comment line. The readability is improved as such two lines look +as separate code lines which would require the braces for compiler. Use: + +@smallexample +if (i) + @{ + /* Return success. */ + return 0; + @} +@end smallexample + +@noindent +and not: + +@smallexample +if (i) + /* Return success. */ + return 0; +@end smallexample + @subsection Comments @cindex comment formatting