diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 15:38:58 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 15:38:58 +0000 |
commit | 745a5c64486e2c306b98dc5a1dec127bd3ce6d37 (patch) | |
tree | 55a9c0c1a8aca7363fef2f018a4cae574dc672b3 /decompress.cc | |
parent | Adding debian version 1.2~rc2-1. (diff) | |
download | plzip-745a5c64486e2c306b98dc5a1dec127bd3ce6d37.tar.xz plzip-745a5c64486e2c306b98dc5a1dec127bd3ce6d37.zip |
Merging upstream version 1.2.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'decompress.cc')
-rw-r--r-- | decompress.cc | 22 |
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; } |