From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id 00A4B3858401 for ; Mon, 8 Nov 2021 14:01:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 00A4B3858401 Received: by mail-oi1-x22d.google.com with SMTP id bf8so9721258oib.6 for ; Mon, 08 Nov 2021 06:01:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=+vqfpnNV2UQ4ITfXKWGPJjHbGBBjjhRUyfIlvmzkc78=; b=74GeAVE5mT7zp954F2hlwBAT88W8/xYx6GzGj7rTt5bjamYA7R7qxmYrwZhMr9dGjY 9zUojX76vQOsnIlPXpgNrD0JycpttLtIOQhc4BjLcGqFPsU5ynHEBrRCn6PThgV5Ndk3 IZvKrwwetE2JAmttM9YGKU5ROwpkJThiitV7OOw4UV/xhgyM5PwLgFkMJW1R1WBeQ/xT LDAyRw+xU5SXvg622mxnN9DpxmuhEm5oplTRN9kUkF5wgDGkyzUk8zrthgh5iZMQAHXg 08LnLq5+4r0VSjawz5R1otq78EZIetB5WVnEWbDQPD5fyRXyMcRoB+q5hwBdNAA4oaDU b83w== X-Gm-Message-State: AOAM532cDGPADSHJn3m5zlOwY6WHfeVDgpsr8XTRERI3Mn5nxVkDXnap s5wv5CDpYPloOcjwD+xsB3GDuQ== X-Google-Smtp-Source: ABdhPJzlOjFciEABPxb1/gJrNM6BhPVkpTOjESJgwxwLQfdeBFfPYD0eHKov5xQH5eGdXuZ7QaAlbw== X-Received: by 2002:a05:6808:1897:: with SMTP id bi23mr15347111oib.111.1636380091448; Mon, 08 Nov 2021 06:01:31 -0800 (PST) Received: from ?IPV6:2804:431:c7cb:55a:c067:29b:4c08:be99? ([2804:431:c7cb:55a:c067:29b:4c08:be99]) by smtp.gmail.com with ESMTPSA id f6sm3474387otu.29.2021.11.08.06.01.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Nov 2021 06:01:31 -0800 (PST) Message-ID: <1464e69a-110a-9551-4a62-79bc63cc8064@linaro.org> Date: Mon, 8 Nov 2021 11:01:28 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: glibc strerrorname_np Content-Language: en-US To: Florian Weimer , Jonny Grant Cc: GNU C Library References: <874k8nniw4.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella In-Reply-To: <874k8nniw4.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: Mon, 08 Nov 2021 14:01:33 -0000 On 08/11/2021 05:36, Florian Weimer via Libc-alpha wrote: > * Jonny Grant: > >> 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"); > > We can add %#m to printf for this use case. It would print the errno > constant if known, or a number otherwise. To use it, errno needs to be > assigned before calling printf. Printing multiple error codes would not > be possible directly, but such usage is quite rare. > > On older glibc, it prints the (translated) string, which is better than > nothing. > This is not a fully replacement, but I think is a reasonable extension.