qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 02/12] hw/intc/apic.c: Use uint32_t for mask wor


From: Stefan Weil
Subject: Re: [Qemu-devel] [PATCH 02/12] hw/intc/apic.c: Use uint32_t for mask word in foreach_apic
Date: Mon, 10 Mar 2014 20:39:45 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

Am 10.03.2014 20:10, schrieb Peter Maydell:
> Use unsigned arithmetic for operations on the mask word
> in the foreach_apic() macro, to avoid relying on undefined
> behaviour when shifting into the sign bit.
> 
> Signed-off-by: Peter Maydell <address@hidden>
> ---
>  hw/intc/apic.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/intc/apic.c b/hw/intc/apic.c
> index 361ae90..e137882 100644
> --- a/hw/intc/apic.c
> +++ b/hw/intc/apic.c
> @@ -201,12 +201,13 @@ static void apic_external_nmi(APICCommonState *s)
>  
>  #define foreach_apic(apic, deliver_bitmask, code) \
>  {\
> -    int __i, __j, __mask;\
> +    int __i, __j;\
> +    uint32_t __mask;\
>      for(__i = 0; __i < MAX_APIC_WORDS; __i++) {\
>          __mask = deliver_bitmask[__i];\
>          if (__mask) {\
>              for(__j = 0; __j < 32; __j++) {\
> -                if (__mask & (1 << __j)) {\
> +                if (__mask & (1U << __j)) {\
>                      apic = local_apics[__i * 32 + __j];\
>                      if (apic) {\
>                          code;\
> 


The declaration of __mask could be moved inside the for block and be
combined with the assignment, but that's not strictly necessary.

Reviewed-by: Stefan Weil <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]