-
Notifications
You must be signed in to change notification settings - Fork 16
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
stdio/file: fix numerous issues in the fread/fwrite functions #376
Conversation
bf2a36e
to
7058c9c
Compare
Also fixed error handling in blocking safe write to return -1 in case of undefined behavior. JIRA: RTOS-892, RTOS-874
7058c9c
to
42040bb
Compare
0f3e3de
to
5df66ae
Compare
5df66ae
to
408aeb3
Compare
return 0; | ||
} | ||
if (stream->bufpos != stream->bufeof) { | ||
/* abort if the read buffer cannot be flushed (non-seekable stream) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't errno
be set then? (And maybe the error flag?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's implementation-specific behavior. In this case, I'm emulating glibc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, case similar to errno
in malloc(0)
, so we probably can't solve this reasonably. Ack.
408aeb3
to
fc10e0c
Compare
return 0; | ||
} | ||
if (stream->bufpos != stream->bufeof) { | ||
/* abort if the read buffer cannot be flushed (non-seekable stream) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, case similar to errno
in malloc(0)
, so we probably can't solve this reasonably. Ack.
Fixed the following issues: - fclose returned -EINVAL instead of EOF - fclose did not return EOF on stream buffer flushing errors - removed unnecessary stream buffer flushing in fopen & fdopen - freopen did not return NULL on stream buffer flushing errors - fseek/fseeko/fsetpos cleared F_EOF flag on error - ftell/ftello/fgetpos cleared F_EOF flag - ftell/ftello/fgetpos flushed the stream buffer - non-blocking fflush was unsupported - flushing failed for non-seekable streams (lseek returning ESPIPE) - interleaved fread/fwrite failed for non-seekable streams (lseek returning ESPIPE) - non-blocking fread was unsupported - unbuffered fread did not set F_ERROR flag on read errors - unbuffered fread did not set F_EOF flag at end-of-file - buffered fread did not set F_ERROR flag on write buffer flushing errors - buffered fread did not return 0 on write buffer flushing errors - buffered fread did not set F_ERROR flag on buffer refilling errors - buffered fread incorrectly set F_EOF flag on EAGAIN errors - buffered fread did not always read full blocks from files - non-blocking fwrite was unsupported - unbuffered fwrite did not set F_ERROR flag on write errors - buffered fwrite did not set F_ERROR flag on read buffer flushing errors - buffered fwrite did not return 0 on read buffer flushing errors - buffered fwrite did not always write full blocks to files JIRA: RTOS-892
fc10e0c
to
029ada8
Compare
Description
Motivation and Context
Types of changes
How Has This Been Tested?
Checklist:
Special treatment