From: Svante Signell <svante.signell@gmail.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Sergio Durigan Junior <sergiodj@redhat.com>,
Pedro Alves <palves@redhat.com>,
gdb-patches@sourceware.org
Subject: Re: New patch: Re: Small patch to enable build of gdb-7.6 for GNU/Hurd
Date: Wed, 29 May 2013 12:49:00 -0000 [thread overview]
Message-ID: <1369831755.30815.10.camel@G3620.my.own.domain> (raw)
In-Reply-To: <20130529094242.GE5751@adacore.com>
On Wed, 2013-05-29 at 13:42 +0400, Joel Brobecker wrote:
> > Attaching a patch and Chengelog entry for the function
> > nto_find_and_open_solib preceding nto_init_solib_absolute_prefix. There
> > I did not see any use of the make_cleanup/do_cleanups functions
> > (assuming open and openp always return). Therefore xfree is used
> > directly.
>
> In this case, I would KISS, and go with cleanups. Otherwise,
> you have to remember when you can free. With cleanups, you just
> mark it right after allocation and do_cleanups before returning.
> And we are putting more and more tools in place to make sure we
> do not forget to do the cleanups...
OK, I will use the *_cleanup(s) functions instead.
> > 2013-05-27 Svante Signell <svante.signell@gmail.com>
> >
> > * nto-dep.c (nto_find_and_open_solib): Use xstrprintf followed by
> > a cleanup instead of alloca to be consistent with function
> > (nto_init_solib_absolute_prefix).
>
> My comments below...
>
> > --- a/gdb/nto-tdep.c 2013-05-27 15:58:07.000000000 +0200
> > +++ b/gdb/nto-tdep.c 2013-05-27 16:23:50.000000000 +0200
> > @@ -89,9 +89,7 @@ nto_find_and_open_solib (char *solib, un
> > char *buf, *arch_path, *nto_root, *endian;
> > const char *base;
> > const char *arch;
> > - int arch_len, len, ret;
> > -#define PATH_FMT \
> > - "%s/lib:%s/usr/lib:%s/usr/photon/lib:%s/usr/photon/dll:%s/lib/dll"
> > + int ret;
> >
> > nto_root = nto_target ();
> > if (strcmp (gdbarch_bfd_arch_info (target_gdbarch ())->arch_name, "i386") == 0)
> > @@ -117,22 +115,20 @@ nto_find_and_open_solib (char *solib, un
> > /* In case nto_root is short, add strlen(solib)
> > so we can reuse arch_path below. */
> >
> > - arch_len = (strlen (nto_root) + strlen (arch) + strlen (endian) + 2
> > - + strlen (solib));
> > - arch_path = alloca (arch_len);
> > - xsnprintf (arch_path, arch_len, "%s/%s%s", nto_root, arch, endian);
> > + arch_path = xstrprintf (arch_path, arch_len, "%s/%s%s", nto_root, arch, endian);
>
> You forgot to remove "arch_path, arch_len" from the arguments of
> the call above. As a result, i suspect that this patch does not
> compile, and that's the minimum we need to do...
I have updated my patch and it built. I copied the patch to a directory,
attached it to the mail, and checked by opening the attachment with
gedit. Then updated the patch to that directory and rechecked with gedit
again and the updated patch was there (not deleting the old attachment)
Still the old version was attached :( Maybe an evolution issue.
> >
> > - len = strlen (PATH_FMT) + strlen (arch_path) * 5 + 1;
> > - buf = alloca (len);
> > - xsnprintf (buf, len, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
> > + buf = xstrprintf ("\"%s\"/lib:\"%s\"/usr/lib:\"%s\"/usr/photon/lib:\"%s\"/usr/photon/dll:\"%s\"/lib/dll", arch_path, arch_path, arch_path, arch_path,
> > arch_path);
>
> Same as in the other patch in the same file: Your patch is adding
> double-quoting of the arg_path, which we may want if you have
> a compelling argument, but should be discussed independently of
> this patch.
OK, an updated patch will remove these quotes.
> I do not know of any absolute guideline whether to split the format
> string or not, but I probably would, like so:
>
> buf = xstrprintf ("\"%s\"/lib:\"%s\"/usr/lib:\"%s\"/usr/photon/lib"
> ":\"%s\"/usr/photon/dll:\"%s\"/lib/dll",
> arch_path, arch_path, arch_path, arch_path,
> arch_path);
>
> Be sure, also, to try to restrict your line length to 70 characters if
> you can. That's our soft limit, with 80 being the absolute limit (under
> normal circumstances).
OK, will do.
> > + xfree (arch_path);
> >
> > base = lbasename (solib);
> > ret = openp (buf, 1, base, o_flags, temp_pathname);
> > + xfree (buf);
> > if (ret < 0 && base != solib)
> > {
> > - xsnprintf (arch_path, arch_len, "/%s", solib);
> > + arch_path = xstrprintf ("/%s", solib);
> > ret = open (arch_path, o_flags, 0);
> > + xfree (arch_path);
> > if (temp_pathname)
> > {
> > if (ret >= 0)
>
>
next prev parent reply other threads:[~2013-05-29 12:49 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-23 16:36 Svante Signell
2013-05-23 17:08 ` Tom Tromey
2013-05-23 17:21 ` Svante Signell
2013-05-23 17:27 ` Tom Tromey
2013-05-23 17:54 ` Svante Signell
2013-05-24 3:01 ` Sergio Durigan Junior
2013-05-24 2:59 ` Sergio Durigan Junior
2013-05-24 4:27 ` Joel Brobecker
2013-05-24 8:53 ` Pedro Alves
2013-05-24 9:07 ` Svante Signell
2013-05-24 9:13 ` Sergio Durigan Junior
2013-05-27 11:41 ` Svante Signell
2013-05-27 12:10 ` Joel Brobecker
2013-05-27 12:21 ` Svante Signell
2013-05-27 13:48 ` Svante Signell
2013-05-27 13:57 ` Svante Signell
2013-05-27 14:31 ` Joel Brobecker
2013-05-27 15:59 ` Svante Signell
2013-05-29 9:26 ` Joel Brobecker
2013-05-29 12:18 ` Svante Signell
2013-05-27 16:03 ` New patch: " Svante Signell
2013-05-29 9:42 ` Joel Brobecker
2013-05-29 12:49 ` Svante Signell [this message]
2013-05-27 14:55 ` Thomas Schwinge
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=1369831755.30815.10.camel@G3620.my.own.domain \
--to=svante.signell@gmail.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=sergiodj@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