From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121855 invoked by alias); 11 Nov 2019 14:57:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 121845 invoked by uid 89); 11 Nov 2019 14:57:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-13.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=Ensure, UID, USER, strncpy X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Nov 2019 14:57:22 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id D2EF62047F; Mon, 11 Nov 2019 09:57:20 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id CF03A201E8; Mon, 11 Nov 2019 09:57:19 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id B36C920AF6; Mon, 11 Nov 2019 09:57:19 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Mon, 11 Nov 2019 14:57:00 -0000 From: "Tom Tromey (Code Review)" To: Christian Biesinger , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: comment Subject: [review v2] Use getpwuid_r instead of getpwuid when available X-Gerrit-Change-Id: I587359267f8963ef1da6ba0223a1525807a721de X-Gerrit-Change-Number: 485 X-Gerrit-ChangeURL: X-Gerrit-Commit: 05523d63be1169bb28b78f93e267e4a44894c8c6 In-Reply-To: References: X-Gerrit-Comment-Date: Mon, 11 Nov 2019 09:57:19 -0500 Reply-To: gnutoolchain-gerrit@osci.io MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-76-gf8b6da0ab5 Content-Type: text/plain; charset=UTF-8 Message-Id: <20191111145719.B36C920AF6@gnutoolchain-gerrit.osci.io> X-SW-Source: 2019-11/txt/msg00284.txt.bz2 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 Gerrit-CC: Tom Tromey Gerrit-Comment-Date: Mon, 11 Nov 2019 14:57:19 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment