diff mbox series

WIP: [PATCH] Fix types mistmatch

Message ID CAJcrxCgYBMAf7-J5PXyWZyhXAOOPCpOTK0yqi-ZLQppJfvBmaw@mail.gmail.com
State Changes Requested
Headers show
Series WIP: [PATCH] Fix types mistmatch | expand

Commit Message

Roman Kalashnikov Oct. 20, 2017, 11:31 p.m. UTC
Signed-off-by: Roman Kalashnikov <lunix0x@gmail.com>
---
 archival/gun.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

                     (me->total ? me->total : 1));
     if (percent != (unsigned int)me->percent) {
@@ -354,7 +357,7 @@ static int lunpipe(unsigned have, unsigned char *next,
struct ind *indp,
    prematurely or a write error occurs, or Z_ERRNO if junk (not a another
gzip
    stream) follows a valid gzip stream.
  */
-static int gunpipe(z_stream *strm, int infile, unsigned long *offs, int
nbytes, int outfile, uint32_t *checksum, void *dgst)
+static int gunpipe(z_stream *strm, int infile, unsigned long *offs,
unsigned int nbytes, int outfile, uint32_t *checksum, void *dgst)
 {
     int ret, first, last;
     unsigned have, flags, len;
@@ -492,7 +495,7 @@ static int gunpipe(z_stream *strm, int infile, unsigned
long *offs, int nbytes,

 /* Process the gun command line arguments. See the command syntax near the
    beginning of this source file. */
-int decompress_image(int infile, unsigned long *offs, int nbytes,
+int decompress_image(int infile, unsigned long *offs, unsigned int nbytes,
         int outfile, uint32_t *checksum, void *dgst)
 {
     int ret;
diff mbox series

Patch

diff --git a/archival/gun.c b/archival/gun.c
index ade0379..3c09ad5 100644
--- a/archival/gun.c
+++ b/archival/gun.c
@@ -45,8 +45,8 @@  struct ind {
     unsigned char *inbuf;
     unsigned long *offs;
     unsigned long *checksum;
- int nbytes;
- int total;
+ unsigned int nbytes;
+ unsigned int total;
     int percent;
     void *dgst;
 };
@@ -56,6 +56,7 @@  struct ind {
    returns end-of-file or error. Return 0 on error. */
 static unsigned in(void *in_desc, unsigned char **buf)
 {
+ unsigned int piece;
     int ret;
     unsigned len;
     unsigned char *next;
@@ -66,20 +67,22 @@  static unsigned in(void *in_desc, unsigned char **buf)
     *buf = next;
     len = 0;
     do {
- ret = PIECE;
- if ((unsigned)ret > SIZE - len)
- ret = (int)(SIZE - len);
- if (ret > me->nbytes)
- ret = me->nbytes;
- ret = fill_buffer(me->infile, next, ret, me->offs, (uint32_t
*)me->checksum, me->dgst);
+ piece = PIECE;
+ if (piece > SIZE - len)
+ piece = (int)(SIZE - len);
+ if (piece > me->nbytes)
+ piece = me->nbytes;
+ ret = fill_buffer(me->infile, next, ret, me->offs, (uint32_t
*)me->checksum, me->dgst);
         if (ret < 0) {
             len = 0;
             break;
         }
- next += ret;
- len += ret;
- me->nbytes -= ret;
- } while (ret != 0 && len < SIZE);
+ else
+ piece = ret;
+ next += piece;
+ len += piece;
+ me->nbytes -= piece;
+ } while (piece != 0 && len < SIZE);
     percent = (unsigned int)(((double)(me->total - me->nbytes)) * 100 /