aboutsummaryrefslogtreecommitdiff
path: root/src/lib/libc/stdio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdio.c')
-rw-r--r--src/lib/libc/stdio.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/libc/stdio.c b/src/lib/libc/stdio.c
index dcbcf83..864fb34 100644
--- a/src/lib/libc/stdio.c
+++ b/src/lib/libc/stdio.c
@@ -322,15 +322,18 @@ int fflush(FILE* stream) {
dbg_printf("FFLUSH %p\n", stream);
if (!(stream->file_mode & FM_WRITE)) return 0;
- if (stream == NULL || stream->fd == 0) return EOF;
+ if (stream == NULL || stream->fd == 0) {
+ return EOF;
+ }
if (stream->buf_mode != 0 && stream->out_buf_used > 0) {
size_t ret = sc_write(stream->fd, stream->pos, stream->out_buf_used, stream->out_buf);
- stream->out_buf_used = 0;
if (ret != stream->out_buf_used) {
return EOF;
}
+
+ stream->out_buf_used = 0;
if (!(stream->st.type & (FT_CHARDEV | FT_CHANNEL | FT_DIR))) {
stream->pos += ret;
}