Received: from eggs.gnu.org ([2001:4830:134:3::10]:53751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhGzd-0004z0-Fa for qemu-devel@nongnu.org; Mon, 05 May 2014 07:23:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhGzU-0000RX-AS for qemu-devel@nongnu.org; Mon, 05 May 2014 07:23:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhGzU-0000RJ-1m for qemu-devel@nongnu.org; Mon, 05 May 2014 07:23:24 -0400 From: Gerd Hoffmann Date: Mon, 5 May 2014 13:23:14 +0200 Message-Id: <1399288996-9721-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1399288996-9721-1-git-send-email-kraxel@redhat.com> References: <1399288996-9721-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL v2 5/7] SMBIOS: Use macro to set smbios defaults List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Gabriel L. Somlo" , "Michael S. Tsirkin" , Gabriel Somlo , Anthony Liguori , Gerd Hoffmann From: "Gabriel L. Somlo" 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 Signed-off-by: Gerd Hoffmann --- 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.8.3.1