File dmidecode-skip-details-of-uninstalled-memory-modules.patch of Package dmidecode.17206

From: Jean Delvare <jdelvare@suse.de>
Date: Fri, 30 Oct 2020 15:36:19 +0100
Subject: dmidecode: Skip details of uninstalled memory modules
Git-commit: d64af9778d795c7318653f5bc3016295bf67d700
Patch-mainline: yes
References: bsc#1174257

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>
---
 dmidecode.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4378,6 +4378,9 @@ static void dmi_decode(const struct dmi_
 			dmi_memory_device_type_detail(WORD(data + 0x13));
 			printf("\n");
 			if (h->length < 0x17) break;
+			/* If no module is present, the remaining fields are irrelevant */
+			if (WORD(data + 0x0C) == 0)
+				break;
 			printf("\tSpeed:");
 			dmi_memory_device_speed(WORD(data + 0x15));
 			printf("\n");
openSUSE Build Service is sponsored by