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

Re: [Xen-devel] [PATCH 13/34] xen/arm: gic: Introduce GIC_SGI_MAX



On Tue, 25 Mar 2014, Julien Grall wrote:
> All the functions that send an SGI takes an enum. Therefore checking everytime
> if the value is in the range is not correct.
> 
> Introduce GIC_SGI_MAX to check the enum will never reach more than 16 values.
> 
> This is fix the compilation with Clang 3.5:
> 
> gic.c:515:15: error: comparison of constant 16 with expression of type 'enum 
> gic_sgi' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
>    ASSERT(sgi < 16); /* There are only 16 SGIs */
>           ~~~ ^ ~~
> xen/xen/include/xen/lib.h:43:26: note: expanded from macro 'ASSERT'
>     do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0)
>                          ^
> xen/xen/include/xen/compiler.h:11:41: note: expanded from macro 'unlikely'
>  #define unlikely(x)   __builtin_expect((x),0)
> 
> Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx>
> Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
> Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>
> Cc: Tim Deegan <tim@xxxxxxx>
> ---
>  xen/arch/arm/gic.c        |    7 ++++---
>  xen/include/asm-arm/gic.h |    2 ++
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> index 0095b97..41142a5 100644
> --- a/xen/arch/arm/gic.c
> +++ b/xen/arch/arm/gic.c
> @@ -481,7 +481,8 @@ void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi 
> sgi)
>      unsigned int mask = 0;
>      cpumask_t online_mask;
>  
> -    ASSERT(sgi < 16); /* There are only 16 SGIs */
> +    BUILD_BUG_ON(GIC_SGI_MAX >= 16);
> +    ASSERT(sgi != GIC_SGI_MAX);

These new checks wouldn't be able to cover the following case, while the
previous check could:

enum gic_sgi sgi = (enum gic_sgi) integer_greater_than_16;
send_SGI_mask(something, sgi);

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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