From cff11afa886a0147d734b650755d232b5e7f2099 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 3 May 2016 15:32:21 +0200 Subject: [PATCH 11/11] dmidecode: Hide irrelevant fixup message Only display the message about type 34 length fixup if the entry in question is going to be displayed. Otherwise it's only confusing. This fixes bug #109024: http://savannah.nongnu.org/support/?109024 Fixes: 3f70b3515d91 ("dmidecode: Fix up invalid DMI type 34 structure length") --- dmidecode.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dmidecode.c b/dmidecode.c index 0c26685..84c18e1 100644 --- a/dmidecode.c +++ b/dmidecode.c @@ -2949,7 +2949,7 @@ static void dmi_64bit_memory_error_address(u64 code) * first 5 characters of the device name to be trimmed. It's easy to * check and fix, so do it, but warn. */ -static void dmi_fixup_type_34(struct dmi_header *h) +static void dmi_fixup_type_34(struct dmi_header *h, int display) { u8 *p = h->data; @@ -2957,7 +2957,9 @@ static void dmi_fixup_type_34(struct dmi_header *h) if (h->length == 0x10 && is_printable(p + 0x0B, 0x10 - 0x0B)) { - printf("Invalid entry length (%u). Fixed up to %u.\n", 0x10, 0x0B); + if (!(opt.flags & FLAG_QUIET) && display) + printf("Invalid entry length (%u). Fixed up to %u.\n", + 0x10, 0x0B); h->length = 0x0B; } } @@ -4446,7 +4448,7 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags) /* Fixup a common mistake */ if (h.type == 34) - dmi_fixup_type_34(&h); + dmi_fixup_type_34(&h, display); /* look for the next handle */ next = data + h.length; -- 2.7.4