Minor - breakup mptable allocation into two calls.
authorKevin O'Connor <kevin@koconnor.net>
Wed, 29 Jul 2009 23:44:42 +0000 (19:44 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 29 Jul 2009 23:44:42 +0000 (19:44 -0400)
src/mptable.c

index dd3b10afe2eff281ca07c2b55c91b376ced1ec5a..8f622fffbb2d43fd8d35f1000d143f7da9bab683 100644 (file)
@@ -29,22 +29,20 @@ mptable_init(void)
         // Building an mptable on uniprocessor machines confuses some OSes.
         return;
 
-    int length = (sizeof(struct mptable_floating_s)
-                  + sizeof(struct mptable_config_s)
+    int length = (sizeof(struct mptable_config_s)
                   + sizeof(struct mpt_cpu) * smp_cpus
                   + sizeof(struct mpt_bus)
                   + sizeof(struct mpt_ioapic)
                   + sizeof(struct mpt_intsrc) * 16);
-    void *start = malloc_fseg(length);
-    if (!start) {
+    struct mptable_config_s *config = malloc_fseg(length);
+    struct mptable_floating_s *floating = malloc_fseg(sizeof(*floating));
+    if (!config || !floating) {
         dprintf(1, "No room for MPTABLE!\n");
         return;
     }
 
     /* floating pointer structure */
-    struct mptable_floating_s *floating = start;
     memset(floating, 0, sizeof(*floating));
-    struct mptable_config_s *config = (void*)&floating[1];
     floating->signature = MPTABLE_SIGNATURE;
     floating->physaddr = (u32)config;
     floating->length = 1;