aboutsummaryrefslogtreecommitdiff
path: root/src/lib/libc/stdio.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2017-04-19 11:37:40 +0200
committerAlex Auvolat <alex@adnab.me>2017-04-19 11:37:40 +0200
commit8e88e765ee17296a85c5ae372471ed248ce321db (patch)
tree94c375f5ec15d215dac16c6f9e386f24283c07df /src/lib/libc/stdio.c
parent96da27494f89d75f8aec0c8894440c3f7482f54b (diff)
downloadkogata-8e88e765ee17296a85c5ae372471ed248ce321db.tar.gz
kogata-8e88e765ee17296a85c5ae372471ed248ce321db.zip
Mini reorganization
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;
}