From patchwork Tue Apr 29 12:11:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 343814 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5266E1400B2 for ; Tue, 29 Apr 2014 22:15:07 +1000 (EST) Received: from localhost ([::1]:49411 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wf6wD-0005SL-7H for incoming@patchwork.ozlabs.org; Tue, 29 Apr 2014 08:15:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wf6sg-0006a3-VU for qemu-devel@nongnu.org; Tue, 29 Apr 2014 08:11:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wf6sc-0000tS-2D for qemu-devel@nongnu.org; Tue, 29 Apr 2014 08:11:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23092) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wf6sb-0000tF-Pw for qemu-devel@nongnu.org; Tue, 29 Apr 2014 08:11:21 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3TCBGsp005330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 29 Apr 2014 08:11:16 -0400 Received: from nilsson.home.kraxel.org (ovpn-116-81.ams2.redhat.com [10.36.116.81]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s3TCBFeN026674; Tue, 29 Apr 2014 08:11:16 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id A835C80656; Tue, 29 Apr 2014 14:11:13 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 29 Apr 2014 14:11:09 +0200 Message-Id: <1398773471-11112-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1398773471-11112-1-git-send-email-kraxel@redhat.com> References: <1398773471-11112-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: "Gabriel L. Somlo" , "Michael S. Tsirkin" , Gabriel Somlo , Anthony Liguori , Gerd Hoffmann Subject: [Qemu-devel] [PULL 5/7] SMBIOS: Use macro to set smbios defaults X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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);