From: oetiker Date: Thu, 6 Sep 2007 08:42:22 +0000 (+0000) Subject: * mimic write() and read() even better -- Bernhard Fischer X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=aece9a43678dd1ab14316a385ee1599cd31e3011;p=rrdtool.git * mimic write() and read() even better -- Bernhard Fischer git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1198 a5681a0c-68f1-0310-ab6d-d61299d08faa --- 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 */