[SeaBIOS] [PATCH] apic_id_is_present: fix undefined behavior

Eduardo Habkost ehabkost at redhat.com
Fri Aug 31 20:11:16 CEST 2012


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 <lersek at redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 src/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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
-- 
1.7.11.4




More information about the SeaBIOS mailing list