public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scanf.3: Do not mention the ERANGE error
@ 2022-12-08 12:34 Ian Abbott
  2022-12-09 18:59 ` Alejandro Colomar
  2022-12-12 11:33 ` Alejandro Colomar
  0 siblings, 2 replies; 32+ messages in thread
From: Ian Abbott @ 2022-12-08 12:34 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: linux-man, Ian Abbott, Michael Kerrisk

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>
---
 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
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2023-01-20 22:02 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-08 12:34 [PATCH] scanf.3: Do not mention the ERANGE error Ian Abbott
2022-12-09 18:59 ` Alejandro Colomar
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox