Re: [PATCH 11/14] libfdt: overlay: Fix comparison warning

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



On Mon, Sep 21, 2020 at 05:53:00PM +0100, Andre Przywara wrote:
> With -Wsign-compare, compilers warn about a mismatching signedness in
> a comparison in overlay_update_local_node_references().
> 
> This happens because the division of a signed int by an unsigned int
> promotes the dividend to unsigned first (ANSI C standard 6.1.3.8).
> 
> As in this case we basically just divide by 4, we can do the division
> separately earlier, which preserves the original type.
> 
> Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>

Applied, thanks.

> ---
>  libfdt/fdt_overlay.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
> index b310e49..d217e79 100644
> --- a/libfdt/fdt_overlay.c
> +++ b/libfdt/fdt_overlay.c
> @@ -241,6 +241,7 @@ static int overlay_update_local_node_references(void *fdto,
>  
>  		if (fixup_len % sizeof(uint32_t))
>  			return -FDT_ERR_BADOVERLAY;
> +		fixup_len /= sizeof(uint32_t);
>  
>  		tree_val = fdt_getprop(fdto, tree_node, name, &tree_len);
>  		if (!tree_val) {
> @@ -250,7 +251,7 @@ static int overlay_update_local_node_references(void *fdto,
>  			return tree_len;
>  		}
>  
> -		for (i = 0; i < (fixup_len / sizeof(uint32_t)); i++) {
> +		for (i = 0; i < fixup_len; i++) {
>  			fdt32_t adj_val;
>  			uint32_t poffset;
>  

-- 
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