dmidecode-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dmidecode] [PATCH 3/8] dmidecode: Simplify the formatting of memory err


From: Jean Delvare
Subject: [dmidecode] [PATCH 3/8] dmidecode: Simplify the formatting of memory error status
Date: Mon, 16 Mar 2020 10:39:05 +0100

Make the logic more simple so that we always report the status on a
single line.

Signed-off-by: Jean Delvare <address@hidden>
---
 dmidecode.c |   19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

--- dmidecode.orig/dmidecode.c  2020-02-19 14:13:26.036024273 +0100
+++ dmidecode/dmidecode.c       2020-02-19 14:18:32.399072109 +0100
@@ -1515,18 +1515,19 @@ static void dmi_memory_module_size(u8 co
                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_
                        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 */

-- 
Jean Delvare
SUSE L3 Support



reply via email to

[Prev in Thread] Current Thread [Next in Thread]