public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Tom Tromey <tom@tromey.com>
Cc: Andrew Burgess <aburgess@redhat.com>,
	gdb-patches@sourceware.org, Matt Turner <mattst88@gmail.com>
Subject: Re: [PATCH] Linux: Avoid pread64/pwrite64 for high memory addresses (PR gdb/30525)
Date: Thu, 6 Jul 2023 17:47:01 +0100	[thread overview]
Message-ID: <c798e514-0670-9630-3516-5e304521eece@palves.net> (raw)
In-Reply-To: <87ilaxukmw.fsf@tromey.com>

On 2023-07-06 16:25, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:
> 
> Pedro> I just realized that the lseek path, which I just reindented, has an if branch
> Pedro> with more than one line which isn't using braces...  The patch should at least be
> Pedro> consistent in all the lines it touches...  :-)  If we follow the documented convention,
> Pedro> then here's what we get.
> 
> Pedro> WDYT?  Should we tweak the convention instead?
> 
> I tend to interpret this rule as "two statements and/or comments", so
> braces are required if there's a comment but not for a single statement
> that happens to be broken up across multiple lines.
> 

I don't see how the current wording leaves any room for interpretation, but
I could definitely see that the wording may have overreached the original intention.

I remembered this rule being discussed on the list, (but not the discussion itself),
so I did some digging, and found it.

It all started here:

  https://inbox.sourceware.org/gdb-patches/20111218115931.GA22952@host2.jankratochvil.net/

and then a few weeks later another similar discussion happened, which led Jan proposing
adding formalizing the convention:

  https://inbox.sourceware.org/gdb-patches/CADPb22Q9qi3TsYw3ZFkAyuO6a0VEJ_wtM_4pe_tXzDW5myi29Q@mail.gmail.com/

Curiously, Eli had pointed out the "comments or more ?" issue here:

  https://inbox.sourceware.org/gdb-patches/831ur4kot7.fsf@gnu.org/

but sadly there was no answer.

From what I can tell in those two threads, this was really only about the comments case.  I'll
drop the braces from my patch and merge it.

As for the text in the wiki, how about something like below.  (Note this tweaks the existing
example to use "cond" instead of "i", since we don't do implicit bool conversions, and "i"
looks like an int.)

```
Per the GNU coding standards, single statements are not wrapped in braces, while multiple statements are.

Thus, if you need to wrap a statement, write:

if (cond)
  func (foo (),
        bar ());

and not:

if (cond)
  {
    func (foo (),
          bar ());
  }

As a GDB-specific rule, statements preceded by comments should also be wrapped in braces, as they look like separate statements:

if (cond)
  {
    /* Return success.  */
    return 0;
  }

and not:

if (cond)
  /* Return success.  */
  return 0;
```


Oh the irony:

 https://inbox.sourceware.org/gdb-patches/4F1011EA.1030509@redhat.com/

:-)

  reply	other threads:[~2023-07-06 16:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 13:41 Pedro Alves
2023-07-05 14:45 ` Matt Turner
2023-07-05 17:59 ` Andrew Burgess
2023-07-06 13:43   ` Pedro Alves
2023-07-06 13:54     ` Pedro Alves
2023-07-06 15:25       ` Tom Tromey
2023-07-06 16:47         ` Pedro Alves [this message]
2023-07-06 17:00           ` Pedro Alves
2023-07-07 15:18           ` Tom Tromey

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=c798e514-0670-9630-3516-5e304521eece@palves.net \
    --to=pedro@palves.net \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mattst88@gmail.com \
    --cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).