From aece9a43678dd1ab14316a385ee1599cd31e3011 Mon Sep 17 00:00:00 2001 From: oetiker Date: Thu, 6 Sep 2007 08:42:22 +0000 Subject: [PATCH] * mimic write() and read() even better -- Bernhard Fischer git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1198 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_open.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rrd_open.c b/src/rrd_open.c index c6a2d7d..b9885aa 100644 --- a/src/rrd_open.c +++ b/src/rrd_open.c @@ -469,7 +469,7 @@ inline ssize_t rrd_read( /* write count bytes from buffer buf to the current position * rrd_file->pos of rrd_file->fd. - * Returns the number of bytes written. */ + * Returns the number of bytes written or <0 on error. */ inline ssize_t rrd_write( rrd_file_t *rrd_file, @@ -477,6 +477,10 @@ inline ssize_t rrd_write( size_t count) { #ifdef HAVE_MMAP + if (count == 0) + return 0; + if (buf == NULL) + return -1 /* EINVAL */ memcpy(rrd_file->file_start + rrd_file->pos, buf, count); rrd_file->pos += count; return count; /* mimmic write() semantics */ -- 2.30.2