summaryrefslogtreecommitdiffstats
path: root/decompress.cc
diff options
context:
space:
mode:
Diffstat (limited to 'decompress.cc')
-rw-r--r--decompress.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/decompress.cc b/decompress.cc
index cf0318c..cdcc7af 100644
--- a/decompress.cc
+++ b/decompress.cc
@@ -1,6 +1,6 @@
/* Plzip - Parallel compressor compatible with lzip
Copyright (C) 2009 Laszlo Ersek.
- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Antonio Diaz Diaz.
+ Copyright (C) 2009-2014 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -43,17 +43,17 @@
int preadblock( const int fd, uint8_t * const buf, const int size,
const long long pos )
{
- int rest = size;
+ int sz = 0;
errno = 0;
- while( rest > 0 )
+ while( sz < size )
{
- const int n = pread( fd, buf + size - rest, rest, pos + size - rest );
- if( n > 0 ) rest -= n;
+ const int n = pread( fd, buf + sz, size - sz, pos + sz );
+ if( n > 0 ) sz += n;
else if( n == 0 ) break; // EOF
else if( errno != EINTR ) break;
errno = 0;
}
- return size - rest;
+ return sz;
}
@@ -63,16 +63,16 @@ int preadblock( const int fd, uint8_t * const buf, const int size,
int pwriteblock( const int fd, const uint8_t * const buf, const int size,
const long long pos )
{
- int rest = size;
+ int sz = 0;
errno = 0;
- while( rest > 0 )
+ while( sz < size )
{
- const int n = pwrite( fd, buf + size - rest, rest, pos + size - rest );
- if( n > 0 ) rest -= n;
+ const int n = pwrite( fd, buf + sz, size - sz, pos + sz );
+ if( n > 0 ) sz += n;
else if( n < 0 && errno != EINTR ) break;
errno = 0;
}
- return size - rest;
+ return sz;
}