From ff9a87509d68a92b8ec062c9eb5d80977de2196f Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Mon, 24 Jul 2017 10:42:23 +0000 Subject: [PATCH] unix.c (buf_write): Return early if there is nothing to write. 2017-07-24 Thomas Koenig * io/unix.c (buf_write): Return early if there is nothing to write. From-SVN: r250473 --- libgfortran/ChangeLog | 5 +++++ libgfortran/io/unix.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index f34b4df785a..d29f4f46100 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2017-07-24 Thomas Koenig + + * io/unix.c (buf_write): Return early if there is + nothing to write. + 2017-06-09 Thomas Koenig * intrinsics/eoshift2.c (eoshift2): Use memcpy diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index c76b427387a..61e9f7997b2 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -582,6 +582,9 @@ buf_read (unix_stream *s, void *buf, ssize_t nbyte) static ssize_t buf_write (unix_stream *s, const void *buf, ssize_t nbyte) { + if (nbyte == 0) + return 0; + if (s->ndirty == 0) s->buffer_offset = s->logical_offset;