[PATCH 2/6] dmicheck: re-orgainise the smbios entry point check
Ivan Hu
ivan.hu at canonical.com
Wed Sep 2 07:36:51 UTC 2015
Move the checking SMBIOS/DMI table entry point to the smbios_entry_check
function. Also add the flag to check if the SMBIOS table exist or not,
if not skip the SMBIOS/DMI table check instead of searching table again.
Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
---
src/dmi/dmicheck/dmicheck.c | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/src/dmi/dmicheck/dmicheck.c b/src/dmi/dmicheck/dmicheck.c
index 5fabca0..02bca98 100644
--- a/src/dmi/dmicheck/dmicheck.c
+++ b/src/dmi/dmicheck/dmicheck.c
@@ -84,6 +84,8 @@ typedef struct {
uint8_t offset;
} fwts_dmi_used_by_kernel;
+static bool smbios_found = false;
+
/*
* Table derived by scanning thousands of DMI table dumps from bug reports
*/
@@ -406,9 +408,10 @@ static int dmi_sane(fwts_framework *fw, fwts_smbios_entry *entry)
return ret;
}
-static int dmicheck_test1(fwts_framework *fw)
+static int smbios_entry_check(fwts_framework *fw)
{
void *addr = 0;
+
fwts_smbios_entry entry;
fwts_smbios_type type;
uint16_t version;
@@ -422,12 +425,8 @@ static int dmicheck_test1(fwts_framework *fw)
"This test tries to find and sanity check the SMBIOS "
"data structures.");
- if ((addr = fwts_smbios_find_entry(fw, &entry, &type, &version)) == NULL) {
- fwts_failed(fw, LOG_LEVEL_MEDIUM,
- "SMBIOSNoEntryPoint",
- "Could not find SMBIOS Table Entry Point.");
- return FWTS_OK;
- }
+ if ((addr = fwts_smbios_find_entry(fw, &entry, &type, &version)) == NULL)
+ return FWTS_ERROR;
fwts_passed(fw, "Found SMBIOS Table Entry Point at %p", addr);
dmi_dump_entry(fw, &entry, type);
@@ -490,6 +489,24 @@ static int dmicheck_test1(fwts_framework *fw)
}
return FWTS_OK;
+
+}
+
+static int dmicheck_test1(fwts_framework *fw)
+{
+
+ if (smbios_entry_check(fw) != FWTS_ERROR) {
+ smbios_found = true;
+ }
+
+ if (!smbios_found) {
+ fwts_failed(fw, LOG_LEVEL_HIGH,
+ "SMBIOSNoEntryPoint",
+ "Could not find SMBIOS Table Entry Point.");
+ return FWTS_ERROR;
+ }
+
+ return FWTS_OK;
}
static bool dmi_used_by_kernel(uint8_t type, uint8_t offset)
@@ -1548,6 +1565,11 @@ static int dmicheck_test2(fwts_framework *fw)
uint16_t version = 0;
uint8_t *table;
+ if (!smbios_found) {
+ fwts_skipped(fw, "Cannot find SMBIOS or DMI table entry, skip the test.");
+ return FWTS_SKIP;
+ }
+
addr = fwts_smbios_find_entry(fw, &entry, &type, &version);
if (addr == NULL) {
fwts_failed(fw, LOG_LEVEL_HIGH, DMI_NO_TABLE_HEADER,
--
1.9.1
More information about the fwts-devel
mailing list