Re: [PATCH 08/11] dtc: Fix signedness comparisons warnings: Wrap (-1)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Mon, Oct 12, 2020 at 05:19:45PM +0100, Andre Przywara wrote:
> With -Wsign-compare, compilers warn about a mismatching signedness
> in a comparison in dtc's data_copy_file().
> 
> Even though maxlen is of an unsigned type, we compare against "-1",
> which is passed in from the parser to indicate an unknown size.
> 
> Cast the "-1" to an unsigned size to make the comparison match.
> 
> Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>

Applied, thanks.

> ---
>  data.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/data.c b/data.c
> index fdb0407..1473423 100644
> --- a/data.c
> +++ b/data.c
> @@ -84,7 +84,7 @@ struct data data_copy_file(FILE *f, size_t maxlen)
>  	while (!feof(f) && (d.len < maxlen)) {
>  		size_t chunksize, ret;
>  
> -		if (maxlen == -1)
> +		if (maxlen == (size_t)-1)
>  			chunksize = 4096;
>  		else
>  			chunksize = maxlen - d.len;

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux