Add a helper function to print structure errors, specifically for
structures which do not fit in the table.

Signed-off-by: Jean Delvare <jdelv...@suse.de>
---
 dmidecode.c |    2 +-
 dmioutput.c |   12 ++++++++++++
 dmioutput.h |    1 +
 3 files changed, 14 insertions(+), 1 deletion(-)

--- dmidecode.orig/dmidecode.c  2020-03-24 15:01:50.906283939 +0100
+++ dmidecode/dmidecode.c       2020-03-24 15:02:07.140481636 +0100
@@ -5195,7 +5195,7 @@ static void dmi_table_decode(u8 *buf, u3
                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;
--- dmidecode.orig/dmioutput.c  2020-03-24 15:01:50.906283939 +0100
+++ dmidecode/dmioutput.c       2020-03-24 15:02:07.140481636 +0100
@@ -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");
+}
--- dmidecode.orig/dmioutput.h  2020-03-24 15:01:50.906283939 +0100
+++ dmidecode/dmioutput.h       2020-03-24 15:02:07.140481636 +0100
@@ -31,3 +31,4 @@ void pr_list_start(const char *name, con
 void pr_list_item(const char *format, ...);
 void pr_list_end(void);
 void pr_sep(void);
+void pr_struct_err(const char *format, ...);

-- 
Jean Delvare
SUSE L3 Support

_______________________________________________
https://lists.nongnu.org/mailman/listinfo/dmidecode-devel

Reply via email to