From 25e63d7757f77a15704175c00193753be4176797 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 1 Apr 2020 10:00:36 +0200
Subject: [PATCH 19/23] dmidecode: Add helper function for structure errors
Add a helper function to print structure errors, specifically for
structures which do not fit in the table.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmidecode.c | 2 +-
dmioutput.c | 12 ++++++++++++
dmioutput.h | 1 +
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/dmidecode.c b/dmidecode.c
index 3551637e7b16..59f4fe09e642 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -5195,7 +5195,7 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
if ((unsigned long)(next - buf) > len)
{
if (display && !(opt.flags & FLAG_QUIET))
- printf("\t<TRUNCATED>\n");
+ pr_struct_err("<TRUNCATED>");
pr_sep();
data = next;
break;
diff --git a/dmioutput.c b/dmioutput.c
index ef1c41b2f94e..42f8d3218c43 100644
--- a/dmioutput.c
+++ b/dmioutput.c
@@ -123,3 +123,15 @@ void pr_sep(void)
{
printf("\n");
}
+
+void pr_struct_err(const char *format, ...)
+{
+ va_list args;
+
+ printf("\t");
+
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+ printf("\n");
+}
diff --git a/dmioutput.h b/dmioutput.h
index 6b5f0e0e92c5..a492ec0eb4e7 100644
--- a/dmioutput.h
+++ b/dmioutput.h
@@ -31,3 +31,4 @@ void pr_list_start(const char *name, const char *format, ...);
void pr_list_item(const char *format, ...);
void pr_list_end(void);
void pr_sep(void);
+void pr_struct_err(const char *format, ...);
--
2.17.1