From: Doug Evans <dje@google.com>
To: Simon Marchi <simon.marchi@ericsson.com>
Cc: Pedro Alves <palves@redhat.com>, Yao Qi <qiyaoltc@gmail.com>,
<gdb-patches@sourceware.org>
Subject: Re: [PATCH] Replace some xmalloc-family functions with XNEW-family ones
Date: Thu, 27 Aug 2015 17:48:00 -0000 [thread overview]
Message-ID: <047d7b15fa29aaec9c051e4e941b@google.com> (raw)
Simon Marchi writes:
> On 15-08-26 03:44 PM, Pedro Alves wrote:
> > On 08/26/2015 08:24 PM, Simon Marchi wrote:
> >
> >> I was able to test with just a few targets, those for which I was
able to
> >> build a toolchain with crosstool-ng (arm and mips). I did mingw32 as
well.
> >
> > Thanks.
> >
> >> I applied for an access to the gcc compile farm, but I'm still
waiting.
> >>
> >> I don't think I can do better at the moment. Is there still something
> >> holding back the patch?
> >
> > I think you should go ahead. If anything breaks, it should be a
trivial fix.
> >
> > Thanks,
> > Pedro Alves
>
> Alright, pushed a slightly modified (rebased) version:
>
>
> >From 8d7493201cf01c9836403695f67f7e157341bfd5 Mon Sep 17 00:00:00 2001
> From: Simon Marchi <simon.marchi@ericsson.com>
> Date: Wed, 26 Aug 2015 17:16:07 -0400
> Subject: [PATCH] Replace some xmalloc-family functions with XNEW-family
ones
>
> This patch is part of the make-gdb-buildable-in-C++ effort. The idea is
> to change some calls to the xmalloc family of functions to calls to the
> equivalents in the XNEW family. This avoids adding an explicit cast, so
> it keeps the code a bit more readable. Some of them also map relatively
> well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be
> possible to do scripted replacements if needed.
>
> I only changed calls that were obviously allocating memory for one or
> multiple "objects". Allocation of variable sizes (such as strings or
> buffer handling) will be for later (and won't use XNEW).
>
> - xmalloc (sizeof (struct foo)) -> XNEW (struct foo)
> - xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num)
> - xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo)
> - xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num)
> - xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p,
num)
> - obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo)
> - obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob,
struct foo, num)
> - alloca (sizeof (struct foo)) -> XALLOCA (struct foo)
> - alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num)
>
> Some instances of xmalloc followed by memset to zero the buffer were
> replaced by XCNEW or XCNEWVEC.
>
> I regtested on x86-64, Ubuntu 14.04, but the patch touches many
> architecture-specific files. For those I'll have to rely on the
> buildbot or people complaining that I broke their gdb.
>
> gdb/ChangeLog:
>
> * aarch64-linux-nat.c (aarch64_add_process): Likewise.
> * aarch64-tdep.c (aarch64_gdbarch_init): Likewise.
> * ada-exp.y (write_ambiguous_var): Likewise.
> * ada-lang.c (resolve_subexp): Likewise.
> (user_select_syms): Likewise.
> (assign_aggregate): Likewise.
> (ada_evaluate_subexp): Likewise.
> (cache_symbol): Likewise.
Hi.
First off, thanks for doing this!
I don't want to discourage such cleanups by nitpicking.
A couple of comments.
1) Apologies you felt you needed to write such a long changelog
entry. IMO it's not necessary. There's no doubt a rule that
says such verbosity is indeed necessary, but I'd like to think we
can bend the rules now and then for cases such as this.
I'm not sure what I'd have done differently, I'd have to
go through the patch. If all functions in a file were updated
I'd be ok with:
* ada-lang.c (*): Likewise.
There is precedent for doing that.
And even if not all functions were updated
(and therefore "(*)" is inaccurate),
I think a properly worded introductory sentence
would make it ok.
2) The changelog entry needs to be made more readable.
I'd be ok with just adding a line at the top.
E.g.,
Change some calls to the xmalloc family of functions
to calls to the equivalents in the XNEW family.
* aarch64-linux-nat.c (aarch64_add_process): Likewise.
...
As it currently is all I see is "Likewise." throughout
and the reader has no idea what it refers to.
[Yeah, the reader can go into the git logs,
but they shouldn't have to.]
next reply other threads:[~2015-08-27 17:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 17:48 Doug Evans [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-08-17 21:53 Simon Marchi
2015-08-18 8:49 ` Yao Qi
2015-08-18 11:13 ` Pedro Alves
2015-08-18 12:56 ` Yao Qi
2015-08-18 13:09 ` Antoine Tremblay
2015-08-19 15:31 ` Simon Marchi
2015-08-26 19:24 ` Simon Marchi
2015-08-26 19:44 ` Pedro Alves
2015-08-26 21:20 ` Simon Marchi
2015-08-26 21:33 ` Simon Marchi
2015-08-27 9:54 ` Yao Qi
2015-08-27 16:56 ` DJ Delorie
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=047d7b15fa29aaec9c051e4e941b@google.com \
--to=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=qiyaoltc@gmail.com \
--cc=simon.marchi@ericsson.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