From: Eduardo Habkost Date: Fri, 31 Aug 2012 18:11:16 +0000 (-0300) Subject: apic_id_is_present: fix undefined behavior X-Git-Tag: rel-1.7.2~86 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7f036855d99e5d0a73f96883b38a932958483070;p=seabios.git apic_id_is_present: fix undefined behavior This patch addresses some feedback sent by Laszlo[1] on the non-contiguous APIC ID patches I have sent recently. - (1 << 31) is undefined for 32-bit signed ints - Use !! on the returned value, so the function return value can be an int without a unsigned -> signed conversion [] http://article.gmane.org/gmane.comp.emulators.qemu/162163 Cc: Laszlo Ersek Signed-off-by: Eduardo Habkost --- diff --git a/src/smp.c b/src/smp.c index 3c36f8c..4975412 100644 --- a/src/smp.c +++ b/src/smp.c @@ -77,7 +77,7 @@ ASM16( int apic_id_is_present(u8 apic_id) { - return FoundAPICIDs[apic_id/32] & (1 << (apic_id % 32)); + return !!(FoundAPICIDs[apic_id/32] & (1ul << (apic_id % 32))); } // find and initialize the CPUs by launching a SIPI to them