diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-08 04:37:22 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-08 04:37:22 +0000 |
commit | 4be5f39e8c496b68ab3f2a76537a4dbbe0a5a190 (patch) | |
tree | fdee42e0b41ce53bfe818a83a2cf18ac504a5809 /zutils.cc | |
parent | Adding upstream version 1.2. (diff) | |
download | zutils-4be5f39e8c496b68ab3f2a76537a4dbbe0a5a190.tar.xz zutils-4be5f39e8c496b68ab3f2a76537a4dbbe0a5a190.zip |
Adding upstream version 1.3~pre1.upstream/1.3_pre1
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'zutils.cc')
-rw-r--r-- | zutils.cc | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -3,7 +3,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, @@ -89,17 +89,17 @@ int parse_format_type( const std::string & arg ) // 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; } @@ -108,16 +108,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; } |