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

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