From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id DA4E73858428 for ; Fri, 5 Nov 2021 22:23:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DA4E73858428 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=jguk.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jguk.org Received: by mail-wm1-x331.google.com with SMTP id a20-20020a1c7f14000000b003231d13ee3cso10556640wmd.3 for ; Fri, 05 Nov 2021 15:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jguk.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=W+f2qZyELnW0lXjayiMOfnEDAEoXqzHEe12+IvgZmEM=; b=MWzcG7toKUfAXVGpDPdRZ7pt7c0EKeF47ywy5AdN5WtqgQzfFMaueIyrWwQ7KEpYQL eoQn5ZZaptqNoc3fzcy8FT9drzJLnxlmBqKsvzFcBP5O/HY0PfCFKijhN7+xhZlsRoTi j7w3SNIV63sSXRjSDYejswO2hyUdu9DD5A+yGkI36lT2SFKvFp11i0knUnHLTVWr8+pB HfcAOgGJo2bQlDXfWQV8wnUjD1JQXDn3MARnRq76QXuWBisOmt00v7BUVbBZuZm+8Sdk lKQp2JlGjFKl1AuIw8aJAxFL4J9UAEqQwQ/jHVuH1jXg4gGbH6R9m6GU49sYvSDyn7Yy 94+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=W+f2qZyELnW0lXjayiMOfnEDAEoXqzHEe12+IvgZmEM=; b=7O7zQ1lq3hpK+cqpnkO1hzdQHWKJ34iNVuzIJTVATKhL1x20AZ9qjnbQT6MXyFravf 0qJmElgpwET0U8mgetAONI1uavNHhSo2GbCxAa9/WvGTSODGNGyZC+UJDodFrazU9Nsj garN8tyCzeIVcIDjGu5qcEiCnTRVtxvW+fhG4YPLa3oG/kqHJaP1iO9FgmEc6aqlz49e bCaGWjRvWyVnsMA9puUi56AOJpvo9elJWA7/hRer2FfepvwOWoouOXg5TjpMGmH0U5/W Vn+H+j6/0Xt/U1w0g2iTSba9IhSi2Q/hft0V1zt4rm3iJCJYBKya0J0pj5cmFxBSj1Zz Ippw== X-Gm-Message-State: AOAM531CngIEffkBrRzKNCZNEhJzvBcN8bsuHcRoeuGy1lK0DFpyLrvB ZFoh6dnpO89/dEAt5oulzSbXDA== X-Google-Smtp-Source: ABdhPJxp9c5OPEDt8iSiOgJ9EHPwNHkk3teHF6Y91g4EHMIuraSfii5MDiNTXaml+cxDUY+DMAU8Lw== X-Received: by 2002:a05:600c:1c87:: with SMTP id k7mr34118474wms.103.1636151030991; Fri, 05 Nov 2021 15:23:50 -0700 (PDT) Received: from [192.168.0.12] (cpc87345-slou4-2-0-cust172.17-4.cable.virginm.net. [81.101.252.173]) by smtp.gmail.com with ESMTPSA id h18sm9719885wre.46.2021.11.05.15.23.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Nov 2021 15:23:50 -0700 (PDT) Subject: Re: glibc strerrorname_np To: Adhemerval Zanella , libc-alpha@sourceware.org References: <98556e3e-2869-64f0-574e-7a64503185c2@linaro.org> <9613b21a-3ab0-3303-9321-7bf4e36ce7ed@jguk.org> <77e058e8-2f54-46a5-2180-9784f23040e7@linaro.org> <4f5422c1-d6ea-1ea5-eeea-db61f8b95bc8@jguk.org> <66a2e472-d4e2-96bb-d1a5-8bafa795083f@linaro.org> From: Jonny Grant Message-ID: Date: Fri, 5 Nov 2021 22:23:48 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <66a2e472-d4e2-96bb-d1a5-8bafa795083f@linaro.org> Content-Type: multipart/mixed; boundary="------------DB1F1C1FF1D6A770472CA81F" Content-Language: en-GB X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2021 22:23:53 -0000 This is a multi-part message in MIME format. --------------DB1F1C1FF1D6A770472CA81F Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 05/11/2021 13:01, Adhemerval Zanella wrote: > > > On 05/11/2021 08:51, Jonny Grant wrote: >>> >> >> Hi Adhemerval >> >> Thank you for your reply. Personally I understood an ABI break would be the return type, the name, or the parameters. But the proposed change is not so. Changing to return a string, should be fine. > > It is still an ABI break, code that checks NULL for invalid input will > stop to work. > >> >> ie, in relation to strerror() C99 and POSIX.1-2008 require the return value to be non-NULL. (my view is it is always better not to return a NULL from such string functions that could then cause a SEGV. >> >> strerror(1000) returns a string "Unknown error 1000" >> >> Better to simply align with glibc strerror() approach? >> >> Feels like there is still time to change it, as it is _np. Aligning with strerror(), or just "" as you had mentioned seems reasonable. > > I give you that it is indeed a better return code, and it is not a matter > of timing, but rather I don't think it really worth the ABI break and > the required code complexity to do so. > > It would require: > > 1. Change the strerrorname_np to return "" on invalid code. Please find attached the patch. > 2. Keep the compat symbol that returns NULL and add a compat symbol. > 3. Exports a new symbol with version on 2.35 with the new semantic > and update the ailist. May I check, why would a new symbol be needed? I'd expect it is only a change to strerrorname_np and any test code you have that presently checks for NULL return. > 4. Update the documentation and sync with man-pages. The man-page update is minor, I could handle that. >> https://man7.org/linux/man-pages/man3/strerror.3.html >> >> It's common for some returns to change, eg glibc 2.13 changed strerror_r() behaviour to return the actual error code, as opposed to returning -1 and setting errno. > > And such change did got without burden and extra complexity. Just check > the multiple preprocessor checks it requires to get the right definition > depending of the system support on the misc/error.c (imported from gnulib). > Ok, I think the change I propose does not affect the definition, as the function signature is the same. Maybe I misunderstand something. Cheers, Jonny --------------DB1F1C1FF1D6A770472CA81F Content-Type: text/x-patch; charset=UTF-8; name="errlist.c.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="errlist.c.patch" --- errlist.c.orig 2021-11-05 22:18:24.021988414 +0000 +++ errlist.c 2021-11-05 22:20:12.744347665 +0000 @@ -69,7 +69,7 @@ { if (errnum < 0 || errnum >= array_length (_sys_errnameidx) || (errnum > 0 && _sys_errnameidx[errnum] == 0)) - return NULL; + return ""; return _sys_errname.str + _sys_errnameidx[errnum]; } --------------DB1F1C1FF1D6A770472CA81F--