From cdc1c436cd3ce5899d4c91d7a155f3f82453117c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 7 Nov 2015 16:38:05 +0100 Subject: Adding upstream version 1.2~rc2. Signed-off-by: Daniel Baumann --- compress.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'compress.cc') diff --git a/compress.cc b/compress.cc index f560be3..b579f3c 100644 --- a/compress.cc +++ b/compress.cc @@ -4,7 +4,7 @@ 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 - the Free Software Foundation, either version 3 of the License, or + the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -45,17 +45,17 @@ // int readblock( const int fd, uint8_t * const buf, const int size ) { - int rest = size; + int sz = 0; errno = 0; - while( rest > 0 ) + while( sz < size ) { - const int n = read( fd, buf + size - rest, rest ); - if( n > 0 ) rest -= n; + const int n = read( fd, buf + sz, size - sz ); + if( n > 0 ) sz += n; else if( n == 0 ) break; // EOF else if( errno != EINTR ) break; errno = 0; } - return size - rest; + return sz; } @@ -64,16 +64,16 @@ int readblock( const int fd, uint8_t * const buf, const int size ) // int writeblock( const int fd, const uint8_t * const buf, const int size ) { - int rest = size; + int sz = 0; errno = 0; - while( rest > 0 ) + while( sz < size ) { - const int n = write( fd, buf + size - rest, rest ); - if( n > 0 ) rest -= n; + const int n = write( fd, buf + sz, size - sz ); + if( n > 0 ) sz += n; else if( n < 0 && errno != EINTR ) break; errno = 0; } - return size - rest; + return sz; } -- cgit v1.2.3