Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Doug Evans <dje@google.com>, Pedro Alves <palves@redhat.com>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Remove CHECK_TYPEDEF, use check_typedef instead
Date: Mon, 13 Jul 2015 17:18:00 -0000	[thread overview]
Message-ID: <55A3F2DD.8010902@ericsson.com> (raw)
In-Reply-To: <CADPb22SjePg2g8kn+u7tGNN2u8xxTStd-cvtQxd6BaPJ6MjWYw@mail.gmail.com>

On 15-07-11 09:18 AM, Doug Evans wrote:
> On Tue, Jul 7, 2015 at 11:15 AM, Pedro Alves <palves@redhat.com> wrote:
>> ...
>> Or even rename it while at it:
>>
>>  void
>>  peel_typedefs (struct type **type)
>>  {
>>    *type = check_typedef (*type);
>>  }
>>
>> And so you'd write:
>>
>>  > -      CHECK_TYPEDEF (result);
>>  > +      peel_typedefs (&result);
>>
>> Then the code ends up self documenting, and there's no way to
>> forget to assign the return of the function back to the
>> argument.
> 
> Hi.
> 
> If we get into renaming, it would be really nice to fix another
> problem with check_typedefs.
> Many don't know (or forget) that it actually serves (at least) two
> main purposes.
> The first is the obvious removal of typedefs.
> The second is the resolution of opaque types.
> Forgetting the second purpose has caused bugs in the past,
> and just makes the code harder to read than it should be.

That's what I noticed when I was trying to get rid of check_typedef instances
where the return value is ignored.  I am not comfortable with having a function
being used solely for its side-effects.  That makes the calling code very unclear
about its intentions.  Why not have a separate function that only serves the
second purpose?  Perhaps that check_typedef could be refactored to make use of it,
I don't know.


      parent reply	other threads:[~2015-07-13 17:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 20:06 Simon Marchi
2015-07-07 13:20 ` Joel Brobecker
2015-07-07 16:15 ` Pedro Alves
2015-07-07 20:15   ` Simon Marchi
2015-07-07 22:01     ` Pedro Alves
2015-07-11 13:19   ` Doug Evans
2015-07-11 18:32     ` Pedro Alves
2015-07-11 22:52       ` Doug Evans
2015-07-14  9:34         ` Pedro Alves
2015-07-14 20:42           ` Simon Marchi
2015-07-13 17:18     ` Simon Marchi [this message]

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=55A3F2DD.8010902@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.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