[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [QEMU v8 PATCH 5/7] SMBIOS: Use macro to set smbios default
From: |
Gabriel L. Somlo |
Subject: |
[Qemu-devel] [QEMU v8 PATCH 5/7] SMBIOS: Use macro to set smbios defaults |
Date: |
Wed, 23 Apr 2014 09:42:40 -0400 |
The function smbios_set_defaults() uses a repeating code pattern
for each field. This patch replaces that pattern with a macro.
This patch contains no functional changes.
Signed-off-by: Gabriel Somlo <address@hidden>
---
hw/i386/smbios.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index e734d4c..9f83bfb 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -260,20 +260,6 @@ static void smbios_build_type_1_fields(void)
}
}
-void smbios_set_defaults(const char *manufacturer, const char *product,
- const char *version)
-{
- if (!type1.manufacturer) {
- type1.manufacturer = manufacturer;
- }
- if (!type1.product) {
- type1.product = product;
- }
- if (!type1.version) {
- type1.version = version;
- }
-}
-
uint8_t *smbios_get_table_legacy(size_t *length)
{
if (!smbios_immutable) {
@@ -288,6 +274,19 @@ uint8_t *smbios_get_table_legacy(size_t *length)
/* end: legacy setup functions for <= 2.0 machines */
+#define SMBIOS_SET_DEFAULT(field, value) \
+ if (!field) { \
+ field = value; \
+ }
+
+void smbios_set_defaults(const char *manufacturer, const char *product,
+ const char *version)
+{
+ SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer);
+ SMBIOS_SET_DEFAULT(type1.product, product);
+ SMBIOS_SET_DEFAULT(type1.version, version);
+}
+
static void save_opt(const char **dest, QemuOpts *opts, const char *name)
{
const char *val = qemu_opt_get(opts, name);
--
1.9.0
- [Qemu-devel] [QEMU v8 PATCH 0/7] SMBIOS: build full tables in QEMU, Gabriel L. Somlo, 2014/04/23
- [Qemu-devel] [QEMU v8 PATCH 1/7] E820: Add interface for accessing e820 table, Gabriel L. Somlo, 2014/04/23
- [Qemu-devel] [QEMU v8 PATCH 4/7] SMBIOS: Update header file definitions, Gabriel L. Somlo, 2014/04/23
- [Qemu-devel] [QEMU v8 PATCH 7/7] SMBIOS: Build aggregate smbios tables and entry point, Gabriel L. Somlo, 2014/04/23
- [Qemu-devel] [QEMU v8 PATCH 5/7] SMBIOS: Use macro to set smbios defaults,
Gabriel L. Somlo <=
- [Qemu-devel] [QEMU v8 PATCH 3/7] SMBIOS: Rename symbols to better reflect future use, Gabriel L. Somlo, 2014/04/23
- [Qemu-devel] [QEMU v8 PATCH 2/7] PC: Add machine version 2.1 for piix and q35, Gabriel L. Somlo, 2014/04/23
- [Qemu-devel] [QEMU v8 PATCH 6/7] SMBIOS: Use bitmaps to prevent incompatible comand line options, Gabriel L. Somlo, 2014/04/23
- Re: [Qemu-devel] [QEMU v8 PATCH 0/7] SMBIOS: build full tables in QEMU, Gerd Hoffmann, 2014/04/23