dmidecode-devel
[Top][All Lists]
Advanced

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

[dmidecode] [PATCH] dmidecode: Skip details of uninstalled memory module


From: Jean Delvare
Subject: [dmidecode] [PATCH] dmidecode: Skip details of uninstalled memory modules
Date: Mon, 19 Oct 2020 14:27:41 +0200

If a memory slot is empty then by definition the fields containing
the memory module details are irrelevant. Best case they are filled
with "Unused" and "None", but in some cases they are even invalid
because the manufacturer did not bother setting the fields to
valid neutral values. So it is better to not print these fields
at all, so as to not confuse the user.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
While the exact point at which we should stop decoding is debatable, I
chose to print the Type field unconditionally because some
manufacturers set this field even for empty slots, probably to tell the
user what kind of memory modules should be used. Memory speed, on the
other hand, can often be decided by the user, so this is the first
field I decided to not print when the slot is empty. I'm open to
discussions on that topic though.

 dmidecode.c |    3 +++
 1 file changed, 3 insertions(+)

--- dmidecode.orig/dmidecode.c  2020-10-19 12:02:56.253983789 +0200
+++ dmidecode/dmidecode.c       2020-10-19 14:20:32.512881464 +0200
@@ -4475,6 +4475,9 @@ static void dmi_decode(const struct dmi_
                                dmi_memory_device_type(data[0x12]));
                        dmi_memory_device_type_detail(WORD(data + 0x13));
                        if (h->length < 0x17) break;
+                       /* If no module is present, the remaining fields are 
irrelevant */
+                       if (WORD(data + 0x0C) == 0)
+                               break;
                        dmi_memory_device_speed("Speed", WORD(data + 0x15),
                                                h->length >= 0x5C ?
                                                DWORD(data + 0x54) : 0);


-- 
Jean Delvare
SUSE L3 Support



reply via email to

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