Blame SOURCES/0010-dmidecode-Add-helper-function-pr_info.patch

f877e3
From dd593d2f0c7272658070208d0a6957d77fc7e6f2 Mon Sep 17 00:00:00 2001
f877e3
From: Jean Delvare <jdelvare@suse.de>
f877e3
Date: Wed, 1 Apr 2020 09:51:51 +0200
f877e3
Subject: [PATCH 10/23] dmidecode: Add helper function pr_info
f877e3
f877e3
Print all info messages through a helper function pr_info.
f877e3
f877e3
Signed-off-by: Jean Delvare <jdelvare@suse.de>
f877e3
---
f877e3
 dmidecode.c | 30 +++++++++++++++---------------
f877e3
 dmioutput.c | 10 ++++++++++
f877e3
 dmioutput.h |  1 +
f877e3
 3 files changed, 26 insertions(+), 15 deletions(-)
f877e3
f877e3
diff --git a/dmidecode.c b/dmidecode.c
f877e3
index 2939b2d307fc..e3f6e300efc2 100644
f877e3
--- a/dmidecode.c
f877e3
+++ b/dmidecode.c
f877e3
@@ -5296,11 +5296,11 @@ static void dmi_table(off_t base, u32 len, u16 num, u32 ver, const char *devmem,
f877e3
 		if (opt.type == NULL)
f877e3
 		{
f877e3
 			if (num)
f877e3
-				printf("%u structures occupying %u bytes.\n",
f877e3
-				       num, len);
f877e3
+				pr_info("%u structures occupying %u bytes.",
f877e3
+					num, len);
f877e3
 			if (!(opt.flags & FLAG_FROM_DUMP))
f877e3
-				printf("Table at 0x%08llX.\n",
f877e3
-				       (unsigned long long)base);
f877e3
+				pr_info("Table at 0x%08llX.",
f877e3
+					(unsigned long long)base);
f877e3
 		}
f877e3
 		printf("\n");
f877e3
 	}
f877e3
@@ -5397,8 +5397,8 @@ static int smbios3_decode(u8 *buf, const char *devmem, u32 flags)
f877e3
 
f877e3
 	ver = (buf[0x07] << 16) + (buf[0x08] << 8) + buf[0x09];
f877e3
 	if (!(opt.flags & FLAG_QUIET))
f877e3
-		printf("SMBIOS %u.%u.%u present.\n",
f877e3
-		       buf[0x07], buf[0x08], buf[0x09]);
f877e3
+		pr_info("SMBIOS %u.%u.%u present.",
f877e3
+			buf[0x07], buf[0x08], buf[0x09]);
f877e3
 
f877e3
 	offset = QWORD(buf + 0x10);
f877e3
 	if (!(flags & FLAG_NO_FILE_OFFSET) && offset.h && sizeof(off_t) < 8)
f877e3
@@ -5465,7 +5465,7 @@ static int smbios_decode(u8 *buf, const char *devmem, u32 flags)
f877e3
 			break;
f877e3
 	}
f877e3
 	if (!(opt.flags & FLAG_QUIET))
f877e3
-		printf("SMBIOS %u.%u present.\n",
f877e3
+		pr_info("SMBIOS %u.%u present.",
f877e3
 			ver >> 8, ver & 0xFF);
f877e3
 
f877e3
 	dmi_table(DWORD(buf + 0x18), WORD(buf + 0x16), WORD(buf + 0x1C),
f877e3
@@ -5493,7 +5493,7 @@ static int legacy_decode(u8 *buf, const char *devmem, u32 flags)
f877e3
 		return 0;
f877e3
 
f877e3
 	if (!(opt.flags & FLAG_QUIET))
f877e3
-		printf("Legacy DMI %u.%u present.\n",
f877e3
+		pr_info("Legacy DMI %u.%u present.",
f877e3
 			buf[0x0E] >> 4, buf[0x0E] & 0x0F);
f877e3
 
f877e3
 	dmi_table(DWORD(buf + 0x08), WORD(buf + 0x06), WORD(buf + 0x0C),
f877e3
@@ -5645,8 +5645,8 @@ int main(int argc, char * const argv[])
f877e3
 	if (opt.flags & FLAG_FROM_DUMP)
f877e3
 	{
f877e3
 		if (!(opt.flags & FLAG_QUIET))
f877e3
-			printf("Reading SMBIOS/DMI data from file %s.\n",
f877e3
-			       opt.dumpfile);
f877e3
+			pr_info("Reading SMBIOS/DMI data from file %s.",
f877e3
+				opt.dumpfile);
f877e3
 		if ((buf = mem_chunk(0, 0x20, opt.dumpfile)) == NULL)
f877e3
 		{
f877e3
 			ret = 1;
f877e3
@@ -5681,7 +5681,7 @@ int main(int argc, char * const argv[])
f877e3
 	 && (buf = read_file(0, &size, SYS_ENTRY_FILE)) != NULL)
f877e3
 	{
f877e3
 		if (!(opt.flags & FLAG_QUIET))
f877e3
-			printf("Getting SMBIOS data from sysfs.\n");
f877e3
+			pr_info("Getting SMBIOS data from sysfs.");
f877e3
 		if (size >= 24 && memcmp(buf, "_SM3_", 5) == 0)
f877e3
 		{
f877e3
 			if (smbios3_decode(buf, SYS_TABLE_FILE, FLAG_NO_FILE_OFFSET))
f877e3
@@ -5701,7 +5701,7 @@ int main(int argc, char * const argv[])
f877e3
 		if (found)
f877e3
 			goto done;
f877e3
 		if (!(opt.flags & FLAG_QUIET))
f877e3
-			printf("Failed to get SMBIOS data from sysfs.\n");
f877e3
+			pr_info("Failed to get SMBIOS data from sysfs.");
f877e3
 	}
f877e3
 
f877e3
 	/* Next try EFI (ia64, Intel-based Mac, arm64) */
f877e3
@@ -5716,8 +5716,8 @@ int main(int argc, char * const argv[])
f877e3
 	}
f877e3
 
f877e3
 	if (!(opt.flags & FLAG_QUIET))
f877e3
-		printf("Found SMBIOS entry point in EFI, reading table from %s.\n",
f877e3
-		       opt.devmem);
f877e3
+		pr_info("Found SMBIOS entry point in EFI, reading table from %s.",
f877e3
+			opt.devmem);
f877e3
 	if ((buf = mem_chunk(fp, 0x20, opt.devmem)) == NULL)
f877e3
 	{
f877e3
 		ret = 1;
f877e3
@@ -5739,7 +5739,7 @@ int main(int argc, char * const argv[])
f877e3
 memory_scan:
f877e3
 #if defined __i386__ || defined __x86_64__
f877e3
 	if (!(opt.flags & FLAG_QUIET))
f877e3
-		printf("Scanning %s for entry point.\n", opt.devmem);
f877e3
+		pr_info("Scanning %s for entry point.", opt.devmem);
f877e3
 	/* Fallback to memory scan (x86, x86_64) */
f877e3
 	if ((buf = mem_chunk(0xF0000, 0x10000, opt.devmem)) == NULL)
f877e3
 	{
f877e3
diff --git a/dmioutput.c b/dmioutput.c
f877e3
index e762a035f39d..e702f114bb4a 100644
f877e3
--- a/dmioutput.c
f877e3
+++ b/dmioutput.c
f877e3
@@ -33,3 +33,13 @@ void pr_comment(const char *format, ...)
f877e3
 	va_end(args);
f877e3
 	printf("\n");
f877e3
 }
f877e3
+
f877e3
+void pr_info(const char *format, ...)
f877e3
+{
f877e3
+	va_list args;
f877e3
+
f877e3
+	va_start(args, format);
f877e3
+	vprintf(format, args);
f877e3
+	va_end(args);
f877e3
+	printf("\n");
f877e3
+}
f877e3
diff --git a/dmioutput.h b/dmioutput.h
f877e3
index b6cf5ee8b60e..0dd8f0811934 100644
f877e3
--- a/dmioutput.h
f877e3
+++ b/dmioutput.h
f877e3
@@ -20,3 +20,4 @@
f877e3
  */
f877e3
 
f877e3
 void pr_comment(const char *format, ...);
f877e3
+void pr_info(const char *format, ...);
f877e3
-- 
f877e3
2.17.1
f877e3