From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 7076B3858439 for ; Thu, 4 Nov 2021 20:23:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7076B3858439 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-wr1-x42b.google.com with SMTP id t30so10446404wra.10 for ; Thu, 04 Nov 2021 13:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jguk.org; s=google; h=from:subject:to:message-id:date:user-agent:mime-version :content-language; bh=MOt8/bg9eXtjAqooEBhbBTnlVvNtURQnGs7pFwXY2kQ=; b=gTas8bFBcp+Pxj2ZV3DjDKPko7bkm04YVkWHj6XuQYY43hWuXHsY6eRYDw8IYL8q2n hj7jvD4GZA5Yd/pruL5msSudFl9j65GPe2RTNDTVy/vMrQsKAFUh16SYQwX8exeiIcII kZqT8enc5tfTacHaXEezos+GVG+6NcdOFLKNG5U/RBgKelQwdLg8ZEdgkBI7p9YZ26Um /G7PsNYnuSD9robzzY6lJb1/+kugF5E1ZPlid5e7Tgj6u8qot0xDTJiZVKs6TyW3ErMd D5qBDrbVtEucqJSCZFKBy4ho1PlB+Xj7H+LSJkpy6EHkbHA66/dxU+2oaxu7vt4QVQ3N 26cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-language; bh=MOt8/bg9eXtjAqooEBhbBTnlVvNtURQnGs7pFwXY2kQ=; b=yvvzyscYBvB2O1HC/A5T6fWds2RtWIq3X1pksKySQl2vnq8Xg+E6UCovj75HUCUTDE 1C8BCFXdbe03IP/6snU2J1/dOh8ociHnxGcBp/2Ie78M+Thd6WPdQgyecUjHQFxwvyvD lvyO2M+WP/kPb53C+narlJ7eKnL0D1OZxrW6lenUZxgWBdJGU3iGPlo3oYyP5XlE971R 6AjbCmS5xrNzGlR65oIFjDTY5FvefyfECBQ5SqJgsisbyJk3U1liqmM0sz5a3MZg1Rbg rF1DrrhoRjftuU2sowB7/3KDgEXZCBRhe1ECAdIyLxsiUBVXsgmYBcq+erx824lFZy6O XQiw== X-Gm-Message-State: AOAM532v3yP7VhQin8CicgNt46VpHajiP6nM3Co1J1b5tbRoJCXfSJel BZyLixWhGjyDxnGAzY/u2g4h0pyprQKWfw== X-Google-Smtp-Source: ABdhPJyCpsWvYeIvZxYmQ6Cn/DYx6o/+1Or25vZG0LyCspfMbOgmzxoUEEKhj39NCKKKZszJTO3FVg== X-Received: by 2002:adf:d091:: with SMTP id y17mr55597160wrh.418.1636057408473; Thu, 04 Nov 2021 13:23:28 -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 e7sm3981789wrg.31.2021.11.04.13.23.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Nov 2021 13:23:28 -0700 (PDT) From: Jonny Grant Subject: glibc strerrorname_np To: GNU C Library Message-ID: Date: Thu, 4 Nov 2021 20:23:27 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 Content-Language: en-GB X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HTML_MESSAGE, 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Thu, 04 Nov 2021 20:23:31 -0000 Hi Carlos I was pleased to see you added strerrorname_np() May I ask, I couldn't find the file your implementation is in - could you point it out to me in the glibc repository please? I noticed on the man page it may return NULL, which is a shame, as then it means we always need to check that before using in every printf etc :- printf("err %s\n", strerrorname_np(myerr)?strerrorname_np(myerr), "Unknown err");   I'd done my own version a while ago as strerrno_s(), and assumed I could never get it accepted anywhere like glibc. Probably I should have tried to submit it to glibc! https://github.com/jonnygrant/safec/blob/master/strerrno.c Would something like my implementation ever be accepted? errno_t strerrno_s(char * const buf, const rsize_t buflen, const errno_t errnum) Last quick question, do you know why strerror_r() is considered safer than strerror()? I guess someone could trash the memory returned by it? char * errstr = strerror(EINVAL); errstr[0] = '\0';  // trashed the process copy of the string. (or even SEGV it, if it was in some static section of the ELF?) Kind regards Jonny