From 97d23fb9a642574ef4415e71e4a01387d06744d6 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 30 Nov 2017 16:27:56 +0100 Subject: [PATCH 10/10] dmidecode: Share common EFI code Avoid duplicating code between OS-specific paths. --- dmidecode.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dmidecode.c b/dmidecode.c index aadef75..87faaa9 100644 --- a/dmidecode.c +++ b/dmidecode.c @@ -4946,6 +4946,7 @@ static int address_from_efi(off_t *address) #elif defined(__FreeBSD__) char addrstr[KENV_MVALLEN + 1]; #endif + const char *eptype; int ret; *address = 0; /* Prevent compiler warning */ @@ -4970,9 +4971,7 @@ static int address_from_efi(off_t *address) || strcmp(linebuf, "SMBIOS") == 0) { *address = strtoull(addrp, NULL, 0); - if (!(opt.flags & FLAG_QUIET)) - printf("# %s entry point at 0x%08llx\n", - linebuf, (unsigned long long)*address); + eptype = linebuf; ret = 0; break; } @@ -4997,14 +4996,16 @@ static int address_from_efi(off_t *address) } *address = strtoull(addrstr, NULL, 0); - if (!(opt.flags & FLAG_QUIET)) - printf("# SMBIOS entry point at 0x%08llx\n", - (unsigned long long)*address); - + eptype = "SMBIOS"; ret = 0; #else ret = EFI_NOT_FOUND; #endif + + if (ret == 0 && !(opt.flags & FLAG_QUIET)) + printf("# %s entry point at 0x%08llx\n", + eptype, (unsigned long long)*address); + return ret; } -- 2.9.5