From 568c53913663b8330c72faa5156b38951b29528c Mon Sep 17 00:00:00 2001 From: Burt P Date: Tue, 25 Jun 2019 23:31:00 -0500 Subject: devices/dmi_memory.c: point out bad info Signed-off-by: Burt P --- modules/devices/dmi_memory.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'modules/devices') diff --git a/modules/devices/dmi_memory.c b/modules/devices/dmi_memory.c index 279caaec..565982f4 100644 --- a/modules/devices/dmi_memory.c +++ b/modules/devices/dmi_memory.c @@ -23,6 +23,7 @@ #include gboolean no_handles = FALSE; +gboolean sketchy_info = FALSE; /* strings from dmidecode */ static const char empty_mem_str[] = "No Module Installed"; @@ -35,6 +36,15 @@ static const unsigned long dtm = 17; /* socket */ #define UNKIFNULL2(f) ((f) ? f : _("(Unknown)")) #define SEQ(s,m) (g_strcmp0(s, m) == 0) +const char *problem_marker() { + static const char as_markup[] = "\u26A0"; + static const char as_text[] = "(!)"; + if (params.markup_ok) + return as_markup; + else + return as_text; +} + typedef struct { unsigned long array_handle; gchar *locator; @@ -269,6 +279,7 @@ void dmi_mem_free(dmi_mem* s) { gchar *dmi_mem_socket_info_view0() { gchar *ret = g_strdup("[$ShellParam$]\nViewType=0\n"); GSList *l = NULL; + sketchy_info = FALSE; dmi_mem *mem = dmi_mem_new(); @@ -282,6 +293,12 @@ gchar *dmi_mem_socket_info_view0() { size_str = g_strdup_printf("%"PRId64" / %"PRId64" %s", a->size_MiB_present / 1024, a->size_MiB_max / 1024, _("GiB")); else size_str = g_strdup_printf("%"PRId64" / %"PRId64" %s", a->size_MiB_present, a->size_MiB_max, _("MiB")); + + if (a->size_MiB_max < a->size_MiB_present) { + sketchy_info = TRUE; + size_str = h_strdup_cprintf(" %s", size_str, problem_marker()); + } + ret = h_strdup_cprintf("[%s %s]\n" "%s=0x%x\n" "%s=%s\n" @@ -395,6 +412,7 @@ gchar *dmi_mem_socket_info_view1() { _("Memory DMI") ); GSList *l = NULL; + sketchy_info = FALSE; gchar key_prefix[] = "DEV"; dmi_mem *mem = dmi_mem_new(); @@ -410,6 +428,12 @@ gchar *dmi_mem_socket_info_view1() { size_str = g_strdup_printf("%"PRId64" / %"PRId64" %s", a->size_MiB_present / 1024, a->size_MiB_max / 1024, _("GiB")); else size_str = g_strdup_printf("%"PRId64" / %"PRId64" %s", a->size_MiB_present, a->size_MiB_max, _("MiB")); + + if (a->size_MiB_max < a->size_MiB_present) { + sketchy_info = TRUE; + size_str = h_strdup_cprintf(" %s", size_str, problem_marker()); + } + gchar *details = g_strdup_printf("[%s]\n" "%s=0x%lx\n" "%s=%s\n" @@ -547,5 +571,11 @@ gboolean dmi_mem_show_hinote(const char **msg) { } return TRUE; } + if (sketchy_info) { + *msg = g_strdup( + _("\"More often than not, information contained in the DMI tables is inaccurate,\n" + "incomplete or simply wrong.\" -dmidecode manual page")); + return TRUE; + } return FALSE; } -- cgit v1.2.3