Skip to contentSkip to conversation

Add/Fix command-line checks for smbios options v2

PATCH Superseded Beth Kon 2 participants 2 messages May 29, 2009 – Jun 16, 2009

lore
Share & tools
lore

Beth Kon

author
#0 lore raw

PATCH 1/1 Add/Fix command-line checks for smbios options v2

(Resending with "v2" in subject line)
- One type 4 table is required per cpu. Add a check for this.
- Fix check for smbios file.

Changes from v1:
- static designation of smbios_validate_table, and remove whitespace

--

hw/smbios.c +15 -2
index ced90ce..57d2c2d 100644
@@ -40,9 +40,19 @@ struct smbios_table {
 
 static uint8_t *smbios_entries;
 static size_t smbios_entries_len;
+static int smbios_type4_count = 0;
+
+static void smbios_validate_table(void) {
+    if (smbios_type4_count && smbios_type4_count != smp_cpus) {
+         fprintf(stderr,
+                 "Number of SMBIOS Type 4 tables must match cpu count.\n");
+        exit(1);
+    }
+}
 
 uint8_t *smbios_get_table(size_t *length)
 {
+    smbios_validate_table();
     *length = smbios_entries_len;
     return smbios_entries;
 }
@@ -173,8 +183,8 @@ int smbios_entry_add(const char *t)
         struct smbios_table *table;
         int size = get_image_size(buf);
 
-        if (size < sizeof(struct smbios_structure_header)) {
-            fprintf(stderr, "Cannot read smbios file %s", buf);
+        if (size == -1 || size < sizeof(struct smbios_structure_header)) {
+            fprintf(stderr, "Cannot read smbios file %s\n", buf);
             exit(1);
         }
 
@@ -196,6 +206,9 @@ int smbios_entry_add(const char *t)
 
         header = (struct smbios_structure_header *)(table->data);
         smbios_check_collision(header->type, SMBIOS_TABLE_ENTRY);
+        if (header->type == 4) {
+            smbios_type4_count++;
+        }
 
         smbios_entries_len += sizeof(*table) + size;
         (*(uint16_t *)smbios_entries) =
#1 lore raw
Quoted 19 lines · Beth Kon

(Resending with "v2" in subject line)
- One type 4 table is required per cpu. Add a check for this.
- Fix check for smbios file.

Changes from v1:
- static designation of smbios_validate_table, and remove whitespace

--

hw/smbios.c +1 -0
index ced90ce..57d2c2d 100644
@@ -40,9 +40,19 @@ struct smbios_table {
 
 static uint8_t *smbios_entries;
 static size_t smbios_entries_len;
+static int smbios_type4_count = 0;

hw/smbios.c struct smbios_table { · line 53

Quoted 10 lines
hw/smbios.c +8 -0
+
+static void smbios_validate_table(void) {
+    if (smbios_type4_count && smbios_type4_count != smp_cpus) {
+         fprintf(stderr,
+                 "Number of SMBIOS Type 4 tables must match cpu count.\n");
+        exit(1);
+    }
+}
 
 

Please format according to CodingStyle.

Signature · 3 lines
Regards,

Anthony Liguori