From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPZy6-0005MP-L1 for qemu-devel@nongnu.org; Mon, 17 Mar 2014 12:00:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WPZy5-0007kd-1Z for qemu-devel@nongnu.org; Mon, 17 Mar 2014 12:00:50 -0400 From: Peter Maydell Date: Mon, 17 Mar 2014 16:00:31 +0000 Message-Id: <1395072041-18911-3-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1395072041-18911-1-git-send-email-peter.maydell@linaro.org> References: <1395072041-18911-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH v2 02/12] hw/intc/apic.c: Use uint32_t for mask word in foreach_apic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, qemu-ppc@nongnu.org, patches@linaro.org 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 Reviewed-by: Stefan Weil Reviewed-by: Michael S. Tsirkin --- I took Stefan Weil's suggestion and merged the __mask declaration into the assignment inside the loop. --- hw/intc/apic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 361ae90..b8c061b 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -201,12 +201,12 @@ static void apic_external_nmi(APICCommonState *s) #define foreach_apic(apic, deliver_bitmask, code) \ {\ - int __i, __j, __mask;\ + int __i, __j;\ for(__i = 0; __i < MAX_APIC_WORDS; __i++) {\ - __mask = deliver_bitmask[__i];\ + uint32_t __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