From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85510 invoked by alias); 31 Oct 2019 19:53:30 -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 85502 invoked by uid 89); 31 Oct 2019 19:53:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.1 spammy= 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; Thu, 31 Oct 2019 19:53:28 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id C4A0A20465; Thu, 31 Oct 2019 15:53:26 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id BF46C20266; Thu, 31 Oct 2019 15:53:25 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id A643B20AF6; Thu, 31 Oct 2019 15:53:25 -0400 (EDT) X-Gerrit-PatchSet: 1 Date: Thu, 31 Oct 2019 19:53:00 -0000 From: "Simon Marchi (Code Review)" To: Christian Biesinger , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: comment Subject: [review] Use strerror_r in safe_strerror if available X-Gerrit-Change-Id: I81048fbaf148035c221c528727f7efe58ba528eb X-Gerrit-Change-Number: 474 X-Gerrit-ChangeURL: X-Gerrit-Commit: 158f4b24a83ad0a50aea6d7e1ba64f725c0a3bea In-Reply-To: References: X-Gerrit-Comment-Date: Thu, 31 Oct 2019 15:53:25 -0400 Reply-To: gnutoolchain-gerrit@osci.io MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-75-g9005159e5d Content-Type: text/plain; charset=UTF-8 Message-Id: <20191031195325.A643B20AF6@gnutoolchain-gerrit.osci.io> X-SW-Source: 2019-10/txt/msg01194.txt.bz2 Simon Marchi has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/474 ...................................................................... Patch Set 1: (2 comments) https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/474/1/gdb/gdbsupport/posix-strerror.c File gdb/gdbsupport/posix-strerror.c: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/474/1/gdb/gdbsupport/posix-strerror.c@24 PS1, Line 24: 19 | 20 | #include "common-defs.h" 21 | 22 | /* Implementation of safe_strerror as defined in common-utils.h. */ 23 | 24 > char * 25 | safe_strerror (int errnum) 26 | { 27 | static thread_local char buf[1024]; 28 | 29 | char *msg = nullptr; Just wondering, maybe we could make safe_strerror return a `const char *`? I suppose we never want the caller to modify what we return, since it could point to some immutable string. https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/474/1/gdb/gdbsupport/posix-strerror.c@31 PS1, Line 31: 26 | { 27 | static thread_local char buf[1024]; 28 | 29 | char *msg = nullptr; 30 | #ifdef HAVE_STRERROR_R 31 > #if !__GLIBC__ || ((_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE) 32 | /* Glibc has two different, incompatible versions of strerror_r. */ 33 | if (strerror_r (errnum, buf, sizeof (buf)) == 0) 34 | msg = buf; 35 | #else 36 | msg = strerror_r (errnum, buf, sizeof (buf)); Just a nit, can you "indent" the preprocessor declarations, like #ifdef HAVE_STRERROR_R # if ... ? I think it makes it easier to read. -- Gerrit-Project: binutils-gdb Gerrit-Branch: master Gerrit-Change-Id: I81048fbaf148035c221c528727f7efe58ba528eb Gerrit-Change-Number: 474 Gerrit-PatchSet: 1 Gerrit-Owner: Christian Biesinger Gerrit-CC: Simon Marchi Gerrit-Comment-Date: Thu, 31 Oct 2019 19:53:25 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment