From 1347ccca96db6e157af39fcc565466fa98b9220b Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 23 Mar 2020 16:47:27 +0100 Subject: [PATCH 03/23] dmidecode: Simplify the formatting of memory error status Make the logic more simple so that we always report the status on a single line. Signed-off-by: Jean Delvare --- dmidecode.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/dmidecode.c b/dmidecode.c index ef9bbd54b7f8..5a0631e926c7 100644 --- a/dmidecode.c +++ b/dmidecode.c @@ -1515,18 +1515,19 @@ static void dmi_memory_module_size(u8 code) printf(" (Single-bank Connection)"); } -static void dmi_memory_module_error(u8 code, const char *prefix) +static void dmi_memory_module_error(u8 code) { + static const char *status[] = { + "OK", /* 0x00 */ + "Uncorrectable Errors", + "Correctable Errors", + "Correctable and Uncorrectable Errors" /* 0x03 */ + }; + if (code & (1 << 2)) printf(" See Event Log\n"); else - { if ((code & 0x03) == 0) - printf(" OK\n"); - if (code & (1 << 0)) - printf("%sUncorrectable Errors\n", prefix); - if (code & (1 << 1)) - printf("%sCorrectable Errors\n", prefix); - } + printf(" %s\n", status[code & 0x03]); } /* @@ -4142,7 +4143,7 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) dmi_memory_module_size(data[0x0A]); printf("\n"); printf("\tError Status:"); - dmi_memory_module_error(data[0x0B], "\t\t"); + dmi_memory_module_error(data[0x0B]); break; case 7: /* 7.8 Cache Information */ -- 2.17.1