dmidecode-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dmidecode] [Patch 2/4] dmidecode: use common function to put SMBIOS in


From: Ivan Khoronzhuk
Subject: [dmidecode] [Patch 2/4] dmidecode: use common function to put SMBIOS in dumpfile
Date: Thu, 29 Jan 2015 18:50:10 +0200

It's needed in order to generalize code before adding dmi sysfs
support. It' more convenient to hold common code in separate function.

Signed-off-by: Ivan Khoronzhuk <address@hidden>
---
 dmidecode.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/dmidecode.c b/dmidecode.c
index c4b4fd1..4e4a82f 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4503,6 +4503,24 @@ static void overwrite_dmi_address(u8 *buf)
        buf[0x0B] = 0;
 }
 
+/**
+ * smbios_in_dumpfile - put SMBIOS entry table in dump file
+ * @smbios: pointer on SMBIOS entry table
+ */
+static void smbios_in_dumpfile(unsigned char *smbios)
+{
+       u8 crafted[32];
+
+       memcpy(crafted, smbios, 32);
+       overwrite_dmi_address(crafted + 0x10);
+
+       if (!(opt.flags & FLAG_QUIET))
+               printf("# Writing %d bytes to %s.\n", crafted[0x05],
+                      opt.dumpfile);
+
+       write_dump(0, crafted[0x05], crafted, opt.dumpfile, 1);
+}
+
 static int smbios_decode(u8 *buf, const char *devmem)
 {
        u16 ver;
@@ -4518,17 +4536,7 @@ static int smbios_decode(u8 *buf, const char *devmem)
                ver, devmem);
 
        if (opt.flags & FLAG_DUMP_BIN)
-       {
-               u8 crafted[32];
-
-               memcpy(crafted, buf, 32);
-               overwrite_dmi_address(crafted + 0x10);
-
-               if (!(opt.flags & FLAG_QUIET))
-                       printf("# Writing %d bytes to %s.\n", crafted[0x05],
-                               opt.dumpfile);
-               write_dump(0, crafted[0x05], crafted, opt.dumpfile, 1);
-       }
+               smbios_in_dumpfile(buf);
 
        return 1;
 }
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]