From 9c7db76f373a1d25e52177b81e97bb9e0f9c32b5 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 1 Apr 2020 10:00:33 +0200
Subject: [PATCH 18/23] dmidecode: Add helper function for separators
A simple helper function to print a blank line between records.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmidecode.c | 9 +++++----
dmioutput.c | 5 +++++
dmioutput.h | 1 +
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/dmidecode.c b/dmidecode.c
index 5e9b9899ec1f..3551637e7b16 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -5068,7 +5068,7 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
h->type >= 128 ? "OEM-specific" : "Unknown");
dmi_dump(h);
}
- printf("\n");
+ pr_sep();
}
static void to_dmi_header(struct dmi_header *h, u8 *data)
@@ -5195,7 +5195,8 @@ 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\n");
+ printf("\t<TRUNCATED>\n");
+ pr_sep();
data = next;
break;
}
@@ -5213,7 +5214,7 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
if (opt.flags & FLAG_DUMP)
{
dmi_dump(&h);
- printf("\n");
+ pr_sep();
}
else
dmi_decode(&h, ver);
@@ -5271,7 +5272,7 @@ static void dmi_table(off_t base, u32 len, u16 num, u32 ver, const char *devmem,
pr_info("Table at 0x%08llX.",
(unsigned long long)base);
}
- printf("\n");
+ pr_sep();
}
if ((flags & FLAG_NO_FILE_OFFSET) || (opt.flags & FLAG_FROM_DUMP))
diff --git a/dmioutput.c b/dmioutput.c
index da04450494f7..ef1c41b2f94e 100644
--- a/dmioutput.c
+++ b/dmioutput.c
@@ -118,3 +118,8 @@ void pr_list_end(void)
{
/* a no-op for text output */
}
+
+void pr_sep(void)
+{
+ printf("\n");
+}
diff --git a/dmioutput.h b/dmioutput.h
index 58ca5a854a79..6b5f0e0e92c5 100644
--- a/dmioutput.h
+++ b/dmioutput.h
@@ -30,3 +30,4 @@ void pr_subattr(const char *name, const char *format, ...);
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);
--
2.17.1