From 1af727318af21e5a3b188fed290f3cebb5a8ba86 Mon Sep 17 00:00:00 2001 From: Burt P Date: Sat, 17 Mar 2018 13:29:08 -0500 Subject: dmi: ignore placeholder strings ("To Be Filled...", etc) Signed-off-by: Burt P --- hardinfo/dmi_util.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'hardinfo') diff --git a/hardinfo/dmi_util.c b/hardinfo/dmi_util.c index 28b2c197..25ec8288 100644 --- a/hardinfo/dmi_util.c +++ b/hardinfo/dmi_util.c @@ -21,6 +21,21 @@ #include "hardinfo.h" #include "dmi_util.h" +/* frees the string and sets it NULL if it is to be ignored + * returns -1 if error, 0 if ok, 1 if ignored */ +static int ignore_placeholder_strings(char **pstr) { + if (pstr == NULL || *pstr == NULL) + return -1; +#define DMI_IGNORE(m) if (strcasecmp(m, *pstr) == 0) { free(*pstr); *pstr = NULL; return 1; } + DMI_IGNORE("To be filled by O.E.M."); + DMI_IGNORE("System Product Name"); + DMI_IGNORE("System Manufacturer"); + DMI_IGNORE("System Version"); + DMI_IGNORE("Default String"); + /*... more, I'm sure. */ + return 0; +} + static const char *dmi_sysfs_root(void) { char *candidates[] = { "/sys/devices/virtual/dmi", @@ -105,6 +120,7 @@ dmi_str_done: g_free(ret); ret = NULL; } + ignore_placeholder_strings(&ret); } return ret; } -- cgit v1.2.3