-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dont set errno = 0 #129
Labels
Comments
That need not be a problem if each function has the outline:
int saved = errno;
errno = 0;
…
if (errno == 0)
errno = saved;
return …;
That is, the function saves the value in errno on entry and restores it
before returning if the function (or the functions it calls) have not set
errno to a non-zero value.
On Mon, Feb 20, 2023 at 07:02 Reini Urban ***@***.***> wrote:
According to the C Standard (e.g., C99:7.5p3),
"The value of errno is zero at program startup, but is never set to zero
by any library function."
git grep 'errno = 0' src
src/io/fopen_s.c:100: errno = 0;
src/io/fprintf_s.c:95: errno = 0;
src/io/freopen_s.c:104: errno = 0;
src/io/fscanf_s.c:136: errno = 0;
src/io/gets_s.c:148: errno = 0;
src/io/scanf_s.c:136: errno = 0;
src/io/sscanf_s.c:130: errno = 0;
src/io/tmpfile_s.c:98: errno = 0;
src/io/vfprintf_s.c:101: errno = 0;
src/io/vfscanf_s.c:131: errno = 0;
src/io/vprintf_s.c:87: errno = 0;
src/io/vscanf_s.c:123: errno = 0;
src/io/vsscanf_s.c:130: errno = 0;
src/misc/bsearch_s.c:156: errno = 0;
src/os/getenv_s.c:142: errno = 0;
src/os/gmtime_s.c:124: errno = 0;
src/os/localtime_s.c:126: errno = 0;
src/str/strtok_s.c:259: errno = 0;
src/str/vsnprintf_s.c:1186: errno = 0;
src/str/vsprintf_s.c:115: errno = 0;
src/wchar/fwprintf_s.c:112: errno = 0;
src/wchar/fwscanf_s.c:108: errno = 0;
src/wchar/fwscanf_s.c:137: errno = 0;
src/wchar/mbsrtowcs_s.c:201: errno = 0;
src/wchar/mbstowcs_s.c:183: errno = 0;
src/wchar/mbstowcs_s.c:199: errno = 0;
src/wchar/snwprintf_s.c:191: errno = 0;
src/wchar/swprintf_s.c:192: errno = 0;
src/wchar/swprintf_s.c:202: errno = 0;
src/wchar/swprintf_s.c:217: errno = 0; /* EOVERFLOW */
src/wchar/swscanf_s.c:137: errno = 0;
src/wchar/vfwprintf_s.c:118: errno = 0;
src/wchar/vfwscanf_s.c:112: errno = 0;
src/wchar/vfwscanf_s.c:141: errno = 0;
src/wchar/vsnwprintf_s.c:190: errno = 0;
src/wchar/vswprintf_s.c:174: errno = 0;
src/wchar/vswprintf_s.c:198: errno = 0;
src/wchar/vswscanf_s.c:135: errno = 0;
src/wchar/vwprintf_s.c:107: errno = 0;
src/wchar/vwscanf_s.c:128: errno = 0;
src/wchar/wcstok_s.c:267: errno = 0;
src/wchar/wscanf_s.c:124: errno = 0;
—
Reply to this email directly, view it on GitHub
<#129>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCAHBWF6U5Z5HHFWU7I66TWYN2QTANCNFSM6AAAAAAVB5J6NE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Jonathan Leffler ***@***.***> #include <disclaimer.h>
Guardian of DBD::Informix - v2018.1031 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."
|
According to the C Standard (e.g., C99:7.5p3),
But this a libc, not just a common library. And the libc mandates to set errno on all cases a syscall fails. And to clear it before each syscall. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to the C Standard (e.g., C99:7.5p3),
$ git grep -n 'errno = 0' src
From https://www.bugseng.com/blog/c-standard-library-cannot-be-trusted-blindly
The text was updated successfully, but these errors were encountered: