From 4bc471a6e5516f2bdb9fc43bfae04bba2bb83270 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@1198 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_open.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c index c6a2d7d9..b9885aa5 100644 --- a/program/src/rrd_open.c +++ b/program/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