[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [v3 PATCH 02/13] SMBIOS: Use macro to set smbios defaults
From: |
Gabriel L. Somlo |
Subject: |
[Qemu-devel] [v3 PATCH 02/13] SMBIOS: Use macro to set smbios defaults |
Date: |
Wed, 12 Mar 2014 12:40:01 -0400 |
From: "Gabriel L. Somlo" <address@hidden>
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
- Re: [Qemu-devel] [v2 PATCH 11/13] SMBIOS: Build full type 19 tables, (continued)
- Re: [Qemu-devel] [v2 PATCH 11/13] SMBIOS: Build full type 19 tables, Gabriel L. Somlo, 2014/03/12
- Re: [Qemu-devel] [v2 PATCH 00/13] SMBIOS: build full tables in QEMU, Kevin O'Connor, 2014/03/11
- Re: [Qemu-devel] [v2 PATCH 00/13] SMBIOS: build full tables in QEMU, Gabriel L. Somlo, 2014/03/11
- Re: [Qemu-devel] [v2 PATCH 00/13] SMBIOS: build full tables in QEMU, Gerd Hoffmann, 2014/03/12
- [Qemu-devel] [v3 PATCH 00/13] SMBIOS: build full tables in QEMU, Gabriel L. Somlo, 2014/03/12
- [Qemu-devel] [v3 PATCH 03/13] SMBIOS: Use bitmaps to check for smbios table collisions, Gabriel L. Somlo, 2014/03/12
- [Qemu-devel] [v3 PATCH 05/13] SMBIOS: Build full tables for types 0 and 1, Gabriel L. Somlo, 2014/03/12
- [Qemu-devel] [v3 PATCH 02/13] SMBIOS: Use macro to set smbios defaults,
Gabriel L. Somlo <=
- [Qemu-devel] [v3 PATCH 04/13] SMBIOS: Add code to build full smbios tables; build type 2 table, Gabriel L. Somlo, 2014/03/12
- [Qemu-devel] [v3 PATCH 06/13] SMBIOS: Remove unused code for passing individual fields to bios, Gabriel L. Somlo, 2014/03/12
- [Qemu-devel] [v3 PATCH 01/13] SMBIOS: Rename smbios_set_type1_defaults() for more general use, Gabriel L. Somlo, 2014/03/12
- [Qemu-devel] [v3 PATCH 07/13] SMBIOS: Build full type 3 table, Gabriel L. Somlo, 2014/03/12
- [Qemu-devel] [v3 PATCH 08/13] SMBIOS: Build full type 4 tables, Gabriel L. Somlo, 2014/03/12
- [Qemu-devel] [v3 PATCH 11/13] SMBIOS: Build full type 20 tables, Gabriel L. Somlo, 2014/03/12
- [Qemu-devel] [v3 PATCH 09/13] SMBIOS: Build full smbios type 16 and 17 tables, Gabriel L. Somlo, 2014/03/12
- [Qemu-devel] [v3 PATCH 12/13] SMBIOS: Build full tables for type 32 and 127, Gabriel L. Somlo, 2014/03/12
- [Qemu-devel] [v3 PATCH 13/13] SMBIOS: Update all table definitions to smbios spec v2.3, Gabriel L. Somlo, 2014/03/12
- [Qemu-devel] [v3 PATCH 10/13] SMBIOS: Build full type 19 tables, Gabriel L. Somlo, 2014/03/12