summaryrefslogtreecommitdiffstats
path: root/decoder.c
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-06 12:50:42 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-06 12:50:42 +0000
commit238fd6c90779d1064851d65bbdc6935b86deb2bc (patch)
tree8019ce7fc444befd39a0c7f67db05b1238fc88ac /decoder.c
parentAdding upstream version 1.6~pre2. (diff)
downloadclzip-238fd6c90779d1064851d65bbdc6935b86deb2bc.tar.xz
clzip-238fd6c90779d1064851d65bbdc6935b86deb2bc.zip
Adding upstream version 1.6~rc1.upstream/1.6_rc1
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'decoder.c')
-rw-r--r--decoder.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/decoder.c b/decoder.c
index 3def722..31e226b 100644
--- a/decoder.c
+++ b/decoder.c
@@ -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,
@@ -55,17 +55,17 @@ void Pp_show_msg( struct Pretty_print * const pp, const char * const msg )
*/
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;
}
@@ -74,16 +74,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;
}