[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [PATCH 02/12] hw/intc/apic.c: Use uint32_t for mask w
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-trivial] [PATCH 02/12] hw/intc/apic.c: Use uint32_t for mask word in foreach_apic |
Date: |
Mon, 10 Mar 2014 23:56:54 +0200 |
On Mon, Mar 10, 2014 at 07:10:38PM +0000, Peter Maydell wrote:
> 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>
Reviewed-by: Michael S. Tsirkin <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;\
> --
> 1.9.0
>
- [Qemu-trivial] [PATCH 04/12] hw/i386/acpi_build.c: Avoid shifting left into sign bit, (continued)
- [Qemu-trivial] [PATCH 04/12] hw/i386/acpi_build.c: Avoid shifting left into sign bit, Peter Maydell, 2014/03/10
- [Qemu-trivial] [PATCH 11/12] hw/intc/xilinx_intc: Avoid shifting left into sign bit, Peter Maydell, 2014/03/10
- [Qemu-trivial] [PATCH 07/12] hw/intc/openpic: Avoid shifting left into sign bit, Peter Maydell, 2014/03/10
- [Qemu-trivial] [PATCH 09/12] tests/libqos/pci-pc: Avoid shifting left into sign bit, Peter Maydell, 2014/03/10
- [Qemu-trivial] [PATCH 01/12] target-i386: Avoid shifting left into sign bit, Peter Maydell, 2014/03/10
- [Qemu-trivial] [PATCH 10/12] hw/intc/slavio_intctl: Avoid shifting left into sign bit, Peter Maydell, 2014/03/10
- [Qemu-trivial] [PATCH 02/12] hw/intc/apic.c: Use uint32_t for mask word in foreach_apic, Peter Maydell, 2014/03/10
- Re: [Qemu-trivial] [PATCH 00/12] Avoid shifting left into sign bit, Michael S. Tsirkin, 2014/03/10