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

Re: [PATCH] xen/arm: silence ambiguous integer casting warning error



On Wed, 20 Apr 2022, Paran Lee wrote:

> GCC with "-g -Wall -Wextra" option throws warning message as below:
> 
> error: comparison of integer expressions of different signedness:
>  ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
> 
> Silence the warning by correcting the integer type.
> 
> Signed-off-by: Paran Lee <p4ranlee@xxxxxxxxx>

Thanks for the cleanup!


> ---
>  xen/arch/arm/gic-v3.c | 5 +++--
>  xen/arch/arm/setup.c  | 2 +-
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index 3c472ed768..81ac25f528 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -916,7 +916,8 @@ static void gicv3_hyp_disable(void)
>      isb();
>  }
>  
> -static u16 gicv3_compute_target_list(int *base_cpu, const struct cpumask 
> *mask,
> +static u16 gicv3_compute_target_list(unsigned int *base_cpu,
> +                                     const struct cpumask *mask,
>                                       uint64_t cluster_id)
>  {
>      int cpu = *base_cpu;

I think we need to change cpu to unsigned int too to make it consistent


> @@ -953,7 +954,7 @@ out:
>  
>  static void gicv3_send_sgi_list(enum gic_sgi sgi, const cpumask_t *cpumask)
>  {
> -    int cpu = 0;
> +    unsigned int cpu = 0;
>      uint64_t val;
>  
>      for_each_cpu(cpu, cpumask)
>
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index d5d0792ed4..5ab2aaecaf 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -862,7 +862,7 @@ void __init start_xen(unsigned long boot_phys_offset,
>                        unsigned long fdt_paddr)
>  {
>      size_t fdt_size;
> -    int cpus, i;
> +    unsigned int cpus, i;
>      const char *cmdline;
>      struct bootmodule *xen_bootmodule;
>      struct domain *d;

I can see that we should change i to unsigned int.

cpus could cause a comparison between signed and unsigned int here:

  if ( (num_online_cpus() < cpus) && !cpu_online(i) )

num_online_cpus returns an int

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.