From: Alejandro Colomar <alx.manpages@gmail.com>
To: Ian Abbott <abbotti@mev.co.uk>, Alejandro Colomar <alx@kernel.org>
Cc: linux-man@vger.kernel.org, GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] scanf.3: Do not mention the ERANGE error
Date: Fri, 9 Dec 2022 19:59:25 +0100 [thread overview]
Message-ID: <5f490d45-b31e-279e-edcb-de4806b8ba54@gmail.com> (raw)
In-Reply-To: <20221208123454.13132-1-abbotti@mev.co.uk>
[-- Attachment #1.1: Type: text/plain, Size: 2007 bytes --]
Hi Ian,
On 12/8/22 13:34, Ian Abbott wrote:
> The `scanf()` function does not intentionally set `errno` to `ERANGE`.
> That is just a side effect of the code that it uses to perform
> conversions. It also does not work as reliably as indicated in the
> 'man' page when the target integer type is narrower than `long`.
> Typically (at least in glibc) for target integer types narrower than
> `long`, the number has to exceed the range of `long` (for signed
> conversions) or `unsigned long` (for unsigned conversions) for `errno`
> to be set to `ERANGE`.
>
> Documenting `ERANGE` in the ERRORS section kind of implies that
> `scanf()` should return `EOF` when an integer overflow is encountered,
> which it doesn't (and doing so would violate the C standard).
>
> Just remove any mention of the `ERANGE` error to avoid confusion.
>
> Fixes: 646af540e467 ("Add an ERRORS section documenting at least some of the errors that may occur for scanf().")
> Cc: Michael Kerrisk <mtk.manpages@gmail.com>
> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
I see. How about saying something like "it may also fail for any of any errors
that functions used to perform the conversions may fail"?
Cheers,
Alex
> ---
> man3/scanf.3 | 7 -------
> 1 file changed, 7 deletions(-)
>
> diff --git a/man3/scanf.3 b/man3/scanf.3
> index ba470a5c1..c5ff59f45 100644
> --- a/man3/scanf.3
> +++ b/man3/scanf.3
> @@ -576,10 +576,6 @@ is NULL.
> .TP
> .B ENOMEM
> Out of memory.
> -.TP
> -.B ERANGE
> -The result of an integer conversion would exceed the size
> -that can be stored in the corresponding integer type.
> .SH ATTRIBUTES
> For an explanation of the terms used in this section, see
> .BR attributes (7).
> @@ -609,9 +605,6 @@ The functions
> and
> .BR sscanf ()
> conform to C89 and C99 and POSIX.1-2001.
> -These standards do not specify the
> -.B ERANGE
> -error.
> .PP
> The
> .B q
--
<http://www.alejandro-colomar.es/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2022-12-09 18:59 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-08 12:34 [PATCH] scanf.3: Do not mention the ERANGE error Ian Abbott
2022-12-09 18:59 ` Alejandro Colomar [this message]
2022-12-09 19:28 ` Ian Abbott
2022-12-09 19:33 ` Alejandro Colomar
2022-12-09 21:41 ` Zack Weinberg
2022-12-11 15:58 ` Alejandro Colomar
2022-12-11 16:03 ` Alejandro Colomar
2022-12-12 2:11 ` Zack Weinberg
2022-12-12 10:21 ` Alejandro Colomar
2022-12-14 2:13 ` Zack Weinberg
2022-12-14 10:47 ` Alejandro Colomar
2022-12-14 11:03 ` Ian Abbott
2022-12-29 6:42 ` Zack Weinberg
2022-12-29 6:39 ` Zack Weinberg
2022-12-29 10:47 ` Alejandro Colomar
2022-12-29 16:35 ` Zack Weinberg
2022-12-29 16:39 ` Alejandro Colomar
2022-12-12 15:22 ` Ian Abbott
2022-12-14 2:18 ` Zack Weinberg
2022-12-14 10:22 ` Ian Abbott
2022-12-14 10:39 ` Alejandro Colomar
2022-12-14 10:52 ` Ian Abbott
2022-12-14 11:23 ` Alejandro Colomar
2022-12-14 14:10 ` Ian Abbott
2022-12-14 16:38 ` Joseph Myers
2022-12-12 10:07 ` Ian Abbott
2022-12-12 11:33 ` Alejandro Colomar
2023-01-20 4:09 ` Eric Biggers
2023-01-20 13:12 ` Alejandro Colomar
2023-01-20 17:55 ` G. Branden Robinson
2023-01-20 22:02 ` Alejandro Colomar
2023-01-20 19:41 ` Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5f490d45-b31e-279e-edcb-de4806b8ba54@gmail.com \
--to=alx.manpages@gmail.com \
--cc=abbotti@mev.co.uk \
--cc=alx@kernel.org \
--cc=libc-alpha@sourceware.org \
--cc=linux-man@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox