On Wed, Sep 06, 2017 at 04:25:55PM +0200, Otto Moerbeek wrote:
> clang complains about a quite some signed compares in pax. This fixes
> a few of them, all of the form
> 
>       if (var < sizeof(...))
> 
> where var is an int.
> 
> Here a conversion of the int value to unsigned takes place, due to
> the conversion rules. This causes negative values of var not to be caught.
> By casting the sizeof value to int that wil happen. No more warning
> and better invalid value checking....
> 
> OK?

OK bluhm@

> Index: cpio.c
> ===================================================================
> RCS file: /cvs/src/bin/pax/cpio.c,v
> retrieving revision 1.30
> diff -u -p -r1.30 cpio.c
> --- cpio.c    26 Aug 2016 04:11:16 -0000      1.30
> +++ cpio.c    6 Sep 2017 14:18:58 -0000
> @@ -251,7 +251,7 @@ rd_ln_nm(ARCHD *arcn)
>  int
>  cpio_id(char *blk, int size)
>  {
> -     if ((size < sizeof(HD_CPIO)) ||
> +     if ((size < (int)sizeof(HD_CPIO)) ||
>           (strncmp(blk, AMAGIC, sizeof(AMAGIC) - 1) != 0))
>               return(-1);
>       return(0);
> @@ -488,7 +488,7 @@ cpio_wr(ARCHD *arcn)
>  int
>  vcpio_id(char *blk, int size)
>  {
> -     if ((size < sizeof(HD_VCPIO)) ||
> +     if ((size < (int)sizeof(HD_VCPIO)) ||
>           (strncmp(blk, AVMAGIC, sizeof(AVMAGIC) - 1) != 0))
>               return(-1);
>       return(0);
> @@ -505,7 +505,7 @@ vcpio_id(char *blk, int size)
>  int
>  crc_id(char *blk, int size)
>  {
> -     if ((size < sizeof(HD_VCPIO)) ||
> +     if ((size < (int)sizeof(HD_VCPIO)) ||
>           (strncmp(blk, AVCMAGIC, sizeof(AVCMAGIC) - 1) != 0))
>               return(-1);
>       return(0);
> @@ -799,7 +799,7 @@ vcpio_wr(ARCHD *arcn)
>  int
>  bcpio_id(char *blk, int size)
>  {
> -     if (size < sizeof(HD_BCPIO))
> +     if (size < (int)sizeof(HD_BCPIO))
>               return(-1);
>  
>       /*
> 

Reply via email to