From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 73592 invoked by alias); 9 Dec 2019 19:11:44 -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 73582 invoked by uid 89); 9 Dec 2019 19:11:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.0 required=5.0 tests=AWL,BAYES_00,ENV_AND_HDR_SPF_MATCH,GIT_PATCH_2,RCVD_IN_DNSWL_NONE,SPF_PASS,USER_IN_DEF_SPF_WL autolearn=ham version=3.3.1 spammy=H*RU:209.85.210.66, HX-Spam-Relays-External:209.85.210.66 X-HELO: mail-ot1-f66.google.com Received: from mail-ot1-f66.google.com (HELO mail-ot1-f66.google.com) (209.85.210.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Dec 2019 19:11:42 +0000 Received: by mail-ot1-f66.google.com with SMTP id o9so13216163ote.2 for ; Mon, 09 Dec 2019 11:11:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xn83PkEi+QMw837vMI1TbOO0PeeAaOWqsuEZ0HOy42g=; b=dodWml9kf9fcREe+25ZX9lcbQMtQbkKTLqZomsZCUi0I2gpdjaG4Cxn7ZLE510iUno jc/sZtP9mojfRHy+wfkhJd6vdagZRVsrxLsU9PeYAzpXZcEn5ubfjCWEcSYSfSsVCEM2 6Nlqp/zIdg/TqS3Bog4YdJe1trK39yPfdj3rAneBiZWZtj16bF10Fl2KLihp3jyjUoDF D7ZKTCE1fCx5dp9R/gnWNz1CNn7HzhhGdoBtlo8aXK/l/8mNwTYHGMFt6ptRcvAD6oZn FHEH200SeT5jB02d+1xEqSaGlUwit6Y6F1eHFHRe6jQOjVSwxhEaAmF1pWOvScY1soLy GmQg== MIME-Version: 1.0 References: <20191126195901.50696-1-cbiesinger@google.com> In-Reply-To: From: "Christian Biesinger via gdb-patches" Reply-To: Christian Biesinger Date: Mon, 09 Dec 2019 19:11:00 -0000 Message-ID: Subject: Re: [PATCH] Replace the remaining uses of strerror with safe_strerror To: Pedro Alves Cc: gdb-patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-12/txt/msg00355.txt.bz2 On Fri, Dec 6, 2019 at 4:46 PM Pedro Alves wrote: > > On 12/6/19 8:36 PM, Christian Biesinger wrote: > > On Fri, Dec 6, 2019 at 2:06 PM Pedro Alves wrote: > > >> GDBserver and (I assume) the IPA can be built with other C runtimes on Linux, > >> like musl and others. Do you know how musl behaves? > > > > Oof, looks like they return int :( > > http://git.musl-libc.org/cgit/musl/tree/src/string/strerror_r.c > > > > I guess I'll change to #if defined(IN_PROCESS_AGENT) && defined(__GLIBC__)? > > > > Crazy thought --- use C++ overload resolution to pick the right thing > automatically: > > /* Called if we have a XSI-compliant strerror_r. */ > static char *select_strerror_r (int, char *buf) { return buf; } > > /* Called if we have a GNU strerror_r. */ > static char *select_strerror_r (char *res, char *) { return res; } > > #ifdef IN_PROCESS_AGENT > return select_strerror_r (strerror_r (errnum, buf, buflen), buf); > #else ... Ah, great idea. That way I don't even need the #ifdef. Done, will send a new version now. Christian