Blob Blame History Raw
From d37eed24b07da16719ce969f119b4c636e0e2d96 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 1 Apr 2020 09:51:57 +0200
Subject: [PATCH 12/23] dmidecode: Add helper function pr_handle

Print the handle information through a helper function pr_handle.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
 dmidecode.c | 3 +--
 dmioutput.c | 6 ++++++
 dmioutput.h | 3 +++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/dmidecode.c b/dmidecode.c
index e3f6e300efc2..8ba8d078614e 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -5212,8 +5212,7 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
 
 		if (display
 		 && (!(opt.flags & FLAG_QUIET) || (opt.flags & FLAG_DUMP)))
-			printf("Handle 0x%04X, DMI type %d, %d bytes\n",
-				h.handle, h.type, h.length);
+			pr_handle(&h);
 
 		/* Look for the next handle */
 		next = data + h.length;
diff --git a/dmioutput.c b/dmioutput.c
index e702f114bb4a..ad3b0398c446 100644
--- a/dmioutput.c
+++ b/dmioutput.c
@@ -43,3 +43,9 @@ void pr_info(const char *format, ...)
 	va_end(args);
 	printf("\n");
 }
+
+void pr_handle(const struct dmi_header *h)
+{
+	printf("Handle 0x%04X, DMI type %d, %d bytes\n",
+	       h->handle, h->type, h->length);
+}
diff --git a/dmioutput.h b/dmioutput.h
index 0dd8f0811934..6ef60f0ee3cd 100644
--- a/dmioutput.h
+++ b/dmioutput.h
@@ -19,5 +19,8 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
+#include "dmidecode.h"
+
 void pr_comment(const char *format, ...);
 void pr_info(const char *format, ...);
+void pr_handle(const struct dmi_header *h);
-- 
2.17.1