From: Tobias Stoeckmann Subject: Re: wprintf(3): Fix errno value and document it To: tech@openbsd.org Date: Fri, 16 May 2025 22:48:01 +0200 On Fri, May 16, 2025 at 10:42:59PM +0200, Tobias Stoeckmann wrote: > https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/vfprintf.c#rev1.73 Of course the correct patch has to take both code places into account: Index: vfwprintf.c =================================================================== RCS file: /cvs/src/lib/libc/stdio/vfwprintf.c,v diff -u -p -u -p -r1.23 vfwprintf.c --- vfwprintf.c 6 Oct 2023 16:41:02 -0000 1.23 +++ vfwprintf.c 16 May 2025 20:46:16 -0000 @@ -1059,7 +1059,7 @@ error: goto finish; overflow: - errno = ENOMEM; + errno = EOVERFLOW; ret = -1; finish: @@ -1450,7 +1450,7 @@ done: goto finish; overflow: - errno = ENOMEM; + errno = EOVERFLOW; ret = -1; finish: Index: wprintf.3 =================================================================== RCS file: /cvs/src/lib/libc/stdio/wprintf.3,v diff -u -p -u -p -r1.10 wprintf.3 --- wprintf.3 31 Mar 2022 17:27:16 -0000 1.10 +++ wprintf.3 16 May 2025 20:46:16 -0000 @@ -584,6 +584,21 @@ In no case does a non-existent or small a numeric field; if the result of a conversion is wider than the field width, the field is expanded to contain the conversion result. +.Sh ERRORS +In addition to the errors documented for the +.Xr write 2 +system call, the +.Fn wprintf +family of functions may fail if: +.Bl -tag -width Er +.It Bq Er EILSEQ +An invalid wide character code was encountered. +.It Bq Er ENOMEM +Insufficient storage space is available. +.It Bq Er EOVERFLOW +The return value would be too large to be represented by an +.Vt int . +.El .Sh SEE ALSO .Xr btowc 3 , .Xr fputws 3 ,