From 3a0284b94e3710f0c99b0e1bff2059c524d8ce27 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 7 Nov 2015 16:38:52 +0100 Subject: Adding upstream version 1.2. Signed-off-by: Daniel Baumann --- decompress.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'decompress.cc') 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; } -- cgit v1.2.3