[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/7] SMBIOS: Streamline setting smbios defaults with
From: |
Gabriel L. Somlo |
Subject: |
[Qemu-devel] [PATCH 3/7] SMBIOS: Streamline setting smbios defaults with macro |
Date: |
Sat, 8 Mar 2014 22:02:28 -0500 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
The function smbios_set_defaults() uses a repeating code pattern
for each field. This patch replaces that pattern with a macro.
Signed-off-by: Gabriel Somlo <address@hidden>
---
hw/i386/smbios.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index 89dc070..f4ee7b4 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -256,18 +256,17 @@ static void smbios_build_type_1_fields(void)
}
}
+#define SMBIOS_SET_DEFAULT(field, value) \
+ if (!field) { \
+ field = value; \
+ }
+
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;
- }
+ SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer);
+ SMBIOS_SET_DEFAULT(type1.product, product);
+ SMBIOS_SET_DEFAULT(type1.version, version);
}
uint8_t *smbios_get_table(size_t *length)
--
1.8.1.4
- [Qemu-devel] [PATCH 2/2 (RFC)] QEMU: SMBIOS: Build full smbios tables, Gabriel L. Somlo, 2014/03/04
- Re: [Qemu-devel] [PATCH 2/2 (RFC)] QEMU: SMBIOS: Build full smbios tables, Kevin O'Connor, 2014/03/04
- Re: [Qemu-devel] [PATCH 2/2 (RFC)] QEMU: SMBIOS: Build full smbios tables, Gerd Hoffmann, 2014/03/05
- Re: [Qemu-devel] [PATCH 2/2 (RFC)] QEMU: SMBIOS: Build full smbios tables, Gabriel L. Somlo, 2014/03/05
- Re: [Qemu-devel] [PATCH 2/2 (RFC)] QEMU: SMBIOS: Build full smbios tables, Gerd Hoffmann, 2014/03/06
- Re: [Qemu-devel] [PATCH 2/2 (RFC)] QEMU: SMBIOS: Build full smbios tables, Gabriel L. Somlo, 2014/03/06
- Re: [Qemu-devel] [PATCH 2/2 (RFC)] QEMU: SMBIOS: Build full smbios tables, Laszlo Ersek, 2014/03/06
- Re: [Qemu-devel] QEMU: SMBIOS: Build full smbios tables, Gabriel L. Somlo, 2014/03/08
- [Qemu-devel] [PATCH 1/7] SMBIOS: Update all table definitions to smbios spec v2.3, Gabriel L. Somlo, 2014/03/08
- [Qemu-devel] [PATCH 2/7] SMBIOS: Rename smbios_set_type1_defaults() for more general use, Gabriel L. Somlo, 2014/03/08
- [Qemu-devel] [PATCH 3/7] SMBIOS: Streamline setting smbios defaults with macro,
Gabriel L. Somlo <=
- [Qemu-devel] [PATCH 4/7] SMBIOS: Replace type collision check mechanism with bitmaps, Gabriel L. Somlo, 2014/03/08
- [Qemu-devel] [PATCH 5/7] SMBIOS: Add code to build full smbios tables, Gabriel L. Somlo, 2014/03/08
- [Qemu-devel] [PATCH 6/7] SMBIOS: Build full tables for types 0 and 1, Gabriel L. Somlo, 2014/03/08
- [Qemu-devel] [PATCH 7/7] SMBIOS: Remove unused code for passing individual fields to bios, Gabriel L. Somlo, 2014/03/08