Blame SOURCES/0003-dmidecode-Simplify-the-formatting-of-memory-error-st.patch

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