-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[libc] fwrite_unlocked: only return errno if an actual error occurred. #167350
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
Changes from 1 commit
2ccd126
ccb1b25
9b0318a
64fad09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,8 +51,14 @@ LIBC_INLINE void funlockfile(::FILE *f) { ::funlockfile(f); } | |
| LIBC_INLINE FileIOResult fwrite_unlocked(const void *ptr, size_t size, | ||
| size_t nmemb, ::FILE *f) { | ||
| // Need to use system errno in this case, as system write will set this errno | ||
| // which we need to propagate back into our code. | ||
| return {::fwrite_unlocked(ptr, size, nmemb, f), errno}; | ||
| // which we need to propagate back into our code. fwrite only modifies errno | ||
| // if there was an error, and errno may have previously been nonzero. Only | ||
| // return errno if there was an error. | ||
| auto bytes = ::fwrite_unlocked(ptr, size, nmemb, f); | ||
| if (bytes == nmemb * size) | ||
| return bytes; | ||
| else | ||
| return errno; | ||
|
||
| } | ||
| #endif // LIBC_COPT_STDIO_USE_SYSTEM_FILE | ||
| } // namespace internal | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.