aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2012-05-15 14:01:19 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2012-05-15 14:01:19 -0700
commite63d2ad42dc930e453b39cd5c27b30554d5ba6ec (patch)
treee4324c85644b3223dc94ab4e581cc2a80c20ace0
parent00814c0aa91073f388ef53474e5042b4382911d7 (diff)
downloadklibc-e63d2ad42dc930e453b39cd5c27b30554d5ba6ec.tar.gz
[klibc] fflush: only flush output streams for fflush(NULL)
If we call fflush(NULL), only flush output streams; in particular, don't flush input streams... Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--usr/klibc/stdio/fflush.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr/klibc/stdio/fflush.c b/usr/klibc/stdio/fflush.c
index 03fb29618bb87..56f477155de4f 100644
--- a/usr/klibc/stdio/fflush.c
+++ b/usr/klibc/stdio/fflush.c
@@ -47,9 +47,12 @@ int fflush(FILE *file)
} else {
int err = 0;
- for (f = __stdio_headnode.next; f != &__stdio_headnode;
- f = f->next)
- err |= __fflush(f);
+ for (f = __stdio_headnode.next;
+ f != &__stdio_headnode;
+ f = f->next) {
+ if (f->obytes)
+ err |= __fflush(f);
+ }
return err;
}
}