From: "Tom Tromey (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
To: Christian Biesinger <cbiesinger@google.com>, gdb-patches@sourceware.org
Subject: [review v2] Use getpwuid_r instead of getpwuid when available
Date: Mon, 11 Nov 2019 14:57:00 -0000 [thread overview]
Message-ID: <20191111145719.B36C920AF6@gnutoolchain-gerrit.osci.io> (raw)
In-Reply-To: <gerrit.1572720018000.I587359267f8963ef1da6ba0223a1525807a721de@gnutoolchain-gerrit.osci.io>
Tom Tromey has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/485
......................................................................
Patch Set 2:
(1 comment)
Thank you for this and the other "_r" patches.
I think this one can be hugely simplified, see below.
| --- gdb/nat/linux-osdata.c
| +++ gdb/nat/linux-osdata.c
| @@ -204,11 +204,18 @@ /* Finds the user name for the user UID and copies it into USER. At
|
| static void
| user_from_uid (char *user, int maxlen, uid_t uid)
| {
| - struct passwd *pwentry = getpwuid (uid);
| + struct passwd *pwentry;
| +#ifdef HAVE_GETPWUID_R
| + char buf[1024];
| + struct passwd pwd;
| + getpwuid_r (uid, &pwd, buf, sizeof (buf), &pwentry);
PS2, Line 212:
I think that, because the only use is in a "nat" file,
and because we know this is always available on Linux,
then there's no need for the configury. We can just call
this unconditionally.
| +#else
| + pwentry = getpwuid (uid);
| +#endif
|
| if (pwentry)
| {
| strncpy (user, pwentry->pw_name, maxlen);
| /* Ensure that the user name is null-terminated. */
| user[maxlen - 1] = '\0';
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I587359267f8963ef1da6ba0223a1525807a721de
Gerrit-Change-Number: 485
Gerrit-PatchSet: 2
Gerrit-Owner: Christian Biesinger <cbiesinger@google.com>
Gerrit-CC: Tom Tromey <tromey@sourceware.org>
Gerrit-Comment-Date: Mon, 11 Nov 2019 14:57:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
next prev parent reply other threads:[~2019-11-11 14:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-02 18:40 [review] " Christian Biesinger (Code Review)
2019-11-11 14:57 ` Tom Tromey (Code Review) [this message]
2019-11-11 19:35 ` [review v3] Use getpwuid_r instead of getpwuid Christian Biesinger (Code Review)
2019-11-11 19:36 ` Christian Biesinger (Code Review)
2019-11-11 23:25 ` Tom Tromey (Code Review)
2019-11-11 23:29 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-11 23:29 ` Sourceware to Gerrit sync (Code Review)
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=20191111145719.B36C920AF6@gnutoolchain-gerrit.osci.io \
--to=gerrit@gnutoolchain-gerrit.osci.io \
--cc=cbiesinger@google.com \
--cc=gdb-patches@sourceware.org \
--cc=gnutoolchain-gerrit@osci.io \
/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