summaryrefslogtreecommitdiffstats
path: root/zutils.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-08 04:26:11 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-08 04:26:11 +0000
commit560efe7382b3ec435391d3f2fcda03cb08787ab9 (patch)
tree082803f81c2cf83b8b859df041fb007d5e57a24b /zutils.cc
parentAdding upstream version 1.0~rc7. (diff)
downloadzutils-560efe7382b3ec435391d3f2fcda03cb08787ab9.tar.xz
zutils-560efe7382b3ec435391d3f2fcda03cb08787ab9.zip
Adding upstream version 1.0.upstream/1.0
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'zutils.cc')
-rw-r--r--zutils.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/zutils.cc b/zutils.cc
index 798da03..850504a 100644
--- a/zutils.cc
+++ b/zutils.cc
@@ -54,13 +54,13 @@ int readblock( const int fd, uint8_t * const buf, const int size )
errno = 0;
while( rest > 0 )
{
- errno = 0;
const int n = read( fd, buf + size - rest, rest );
if( n > 0 ) rest -= n;
else if( n == 0 ) break; // EOF
else if( errno != EINTR && errno != EAGAIN ) break;
+ errno = 0;
}
- return ( rest > 0 ) ? size - rest : size;
+ return size - rest;
}
@@ -73,12 +73,12 @@ int writeblock( const int fd, const uint8_t * const buf, const int size )
errno = 0;
while( rest > 0 )
{
- errno = 0;
const int n = write( fd, buf + size - rest, rest );
if( n > 0 ) rest -= n;
else if( n < 0 && errno != EINTR && errno != EAGAIN ) break;
+ errno = 0;
}
- return ( rest > 0 ) ? size - rest : size;
+ return size - rest;
}