Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>, Eli Zaretskii <eliz@gnu.org>
Cc: Doug Evans <dje@google.com>,
	Paul Pluzhnikov <ppluzhnikov@google.com>,
	       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).]
Date: Fri, 13 Jan 2012 11:09:00 -0000	[thread overview]
Message-ID: <20120113110600.GA3501@host2.jankratochvil.net> (raw)
In-Reply-To: <831ur4kot7.fsf@gnu.org> <20120113034602.GS31383@adacore.com>

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  <jan.kratochvil@redhat.com>

	* 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


  reply	other threads:[~2012-01-13 11:06 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-12  3:12 [patch] Fix for PR gdb/9538 (loading of separate debuginfo and symlinks) Paul Pluzhnikov
2012-01-12 17:28 ` Doug Evans
2012-01-12 20:59   ` Paul Pluzhnikov
2012-01-12 21:31     ` Jan Kratochvil
2012-01-12 22:20       ` Paul Pluzhnikov
2012-01-12 22:27         ` Jan Kratochvil
2012-01-12 22:31           ` Paul Pluzhnikov
2012-01-12 22:29       ` Paul Pluzhnikov
2012-01-12 22:50         ` Jan Kratochvil
2012-01-12 23:12           ` Paul Pluzhnikov
2012-01-12 23:18             ` Jan Kratochvil
2012-01-12 23:25         ` Doug Evans
2012-01-12 23:27           ` Jan Kratochvil
2012-01-12 23:40             ` Doug Evans
2012-01-13  0:21               ` [doc patch] gdbint: braces for two lines in code [Re: [patch] Fix for PR gdb/9538 (loading of separate debuginfo and symlinks).] Jan Kratochvil
2012-01-13  0:27                 ` Doug Evans
2012-01-13  4:02                   ` Joel Brobecker
2012-01-13 11:09                     ` Jan Kratochvil [this message]
2012-01-13 11:23                       ` Pedro Alves
2012-01-13 11:55                         ` Eli Zaretskii
2012-01-13 12:15                           ` Joel Brobecker
2012-01-13 12:40                             ` Eli Zaretskii
2012-01-13 14:37                               ` [commit] " Jan Kratochvil
2012-01-13  9:05                 ` Eli Zaretskii
2012-01-12 23:28           ` [patch] Fix for PR gdb/9538 (loading of separate debuginfo and symlinks) Paul Pluzhnikov
2012-01-12 23:55             ` Jan Kratochvil
2012-01-13  0:21               ` Paul Pluzhnikov
2012-01-13  0:48                 ` Jan Kratochvil
2012-01-13  3:39                   ` Paul Pluzhnikov
2012-01-18 19:15                     ` Paul Pluzhnikov
2012-01-12 22:26     ` Doug Evans
2012-01-12 22:40       ` Paul Pluzhnikov
2012-01-12 22:52         ` Doug Evans

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=20120113110600.GA3501@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=dje@google.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=ppluzhnikov@google.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