diff mbox series

Re: WIP: [PATCH] Fix types mistmatch

Message ID 54c9adf4-abf7-4886-977e-b6cb93b62a14@googlegroups.com
State Changes Requested
Headers show
Series Re: WIP: [PATCH] Fix types mistmatch | expand

Commit Message

Roman Kalashnikov Oct. 20, 2017, 11:42 p.m. UTC
Wow, i just forget to add include/util.h into commit.

From: Roman Kalashnikov <lunix0x@gmail.com>
Date: Sat, 21 Oct 2017 02:38:05 +0300
Subject: [PATCH] Fix types mistmatch

Signed-off-by: Roman Kalashnikov <lunix0x@gmail.com>
---
 archival/gun.c | 31 +++++++++++++++++--------------
 include/util.h |  6 +++---
 2 files changed, 20 insertions(+), 17 deletions(-)

    uint32_t __attribute__ ((__unused__)) *checksum,
    void __attribute__ ((__unused__)) *dgst) {
--
2.14.2

Comments

Stefano Babic Oct. 30, 2017, 12:32 p.m. UTC | #1
Hi Romain,

On 21/10/2017 01:42, Roman Kalashnikov wrote:
> Wow, i just forget to add include/util.h into commit.
> 

..but this is the commit message that it is stored when I apply the
patch with "git am". Can you drop it ?

> From: Roman Kalashnikov <lunix0x@gmail.com>
> Date: Sat, 21 Oct 2017 02:38:05 +0300
> Subject: [PATCH] Fix types mistmatch
> 
> Signed-off-by: Roman Kalashnikov <lunix0x@gmail.com>
> ---
>  archival/gun.c | 31 +++++++++++++++++--------------
>  include/util.h |  6 +++---
>  2 files changed, 20 insertions(+), 17 deletions(-)
> 
> 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

The "else" seems to me superfluous, there is a "break" in the if
statement. It makes no difference, really, but I think that is more
readable if the else clause is dropped.

> +            piece = ret;
> +        next += piece;
> +        len += piece;
> +        me->nbytes -= piece;
> +    } while (piece != 0 && len < SIZE);
>      percent = (unsigned int)(((double)(me->total - me->nbytes)) * 100 /
>     (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 --git a/include/util.h b/include/util.h
> index 3abc84b..b64d1f9 100644
> --- a/include/util.h
> +++ b/include/util.h
> @@ -32,7 +32,7 @@ extern int loglevel;
> 
>  /*
>   * loglevel is used into TRACE / ERROR
> - * for values > LASTLOGLEVEL, it is an encoded field
> + * for values > LASTLOGLEVEL, it is an encoded field
>   * to inform the installer about a change in a subprocess
>   */
>  typedef enum {
> @@ -179,12 +179,12 @@ int get_install_info(sourcetype *source, char
> *buf, size_t len);
>  unsigned long long ustrtoull(const char *cp, char **endp, unsigned int
> base);
> 
>  #ifdef CONFIG_GUNZIP
> -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);
>  #else
>  static inline int decompress_image(int __attribute__ ((__unused__))infile,
>    unsigned long __attribute__ ((__unused__)) *offs,
> -  int __attribute__ ((__unused__)) nbytes,
> +  unsigned int __attribute__ ((__unused__)) nbytes,
>    int __attribute__ ((__unused__)) outfile,
>    uint32_t __attribute__ ((__unused__)) *checksum,
>    void __attribute__ ((__unused__)) *dgst) {
> --

Best regards,
Stefano
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 /
     (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 --git a/include/util.h b/include/util.h
index 3abc84b..b64d1f9 100644
--- a/include/util.h
+++ b/include/util.h
@@ -32,7 +32,7 @@  extern int loglevel;

 /*
  * loglevel is used into TRACE / ERROR
- * for values > LASTLOGLEVEL, it is an encoded field
+ * for values > LASTLOGLEVEL, it is an encoded field
  * to inform the installer about a change in a subprocess
  */
 typedef enum {
@@ -179,12 +179,12 @@  int get_install_info(sourcetype *source, char *buf, 
size_t len);
 unsigned long long ustrtoull(const char *cp, char **endp, unsigned int 
base);

 #ifdef CONFIG_GUNZIP
-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);
 #else
 static inline int decompress_image(int __attribute__ ((__unused__))infile,
    unsigned long __attribute__ ((__unused__)) *offs,
-   int __attribute__ ((__unused__)) nbytes,
+   unsigned int __attribute__ ((__unused__)) nbytes,
    int __attribute__ ((__unused__)) outfile,