[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
- [dmidecode] [PATCH 0/8] dmidecode: Minors fixes and clean-ups, Jean Delvare, 2020/03/16
- [dmidecode] [PATCH 1/8] dmidecode: Print type 33 name unconditionally, Jean Delvare, 2020/03/16
- [dmidecode] [PATCH 2/8] dmidecode: Don't choke on invalid processor voltage, Jean Delvare, 2020/03/16
- [dmidecode] [PATCH 3/8] dmidecode: Simplify the formatting of memory error status,
Jean Delvare <=
- [dmidecode] [PATCH 4/8] dmidecode: Fix the alignment of type 25 name, Jean Delvare, 2020/03/16
- [dmidecode] [PATCH 5/8] dmidecode: Code indentation fixes, Jean Delvare, 2020/03/16
- [dmidecode] [PATCH 6/8] dmidecode: Reduce the indentation of type 42 structures, Jean Delvare, 2020/03/16
- [dmidecode] [PATCH 7/8] dmidecode: Move type 42 warning messages to stderr, Jean Delvare, 2020/03/16
- [dmidecode] [PATCH 8/8] dmidecode: Refactor ASCII filtering of DMI strings, Jean Delvare, 2020/03/16