qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Gabriel L. Somlo" <gsomlo@gmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Gabriel Somlo <somlo@cmu.edu>,
	Anthony Liguori <aliguori@amazon.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL v2 5/7] SMBIOS: Use macro to set smbios defaults
Date: Mon,  5 May 2014 13:23:14 +0200	[thread overview]
Message-ID: <1399288996-9721-6-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1399288996-9721-1-git-send-email-kraxel@redhat.com>

From: "Gabriel L. Somlo" <gsomlo@gmail.com>

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 <somlo@cmu.edu>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 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

  parent reply	other threads:[~2014-05-05 11:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-05 11:23 [Qemu-devel] [PULL v2 0/7] smbios: make qemu generate smbios tables Gerd Hoffmann
2014-05-05 11:23 ` [Qemu-devel] [PULL v2 1/7] pc: add 2.1 machine type Gerd Hoffmann
2014-05-05 11:23 ` [Qemu-devel] [PULL v2 2/7] E820: Add interface for accessing e820 table Gerd Hoffmann
2014-05-05 11:23 ` [Qemu-devel] [PULL v2 3/7] SMBIOS: Rename symbols to better reflect future use Gerd Hoffmann
2014-05-05 11:23 ` [Qemu-devel] [PULL v2 4/7] SMBIOS: Update header file definitions Gerd Hoffmann
2014-05-05 11:23 ` Gerd Hoffmann [this message]
2014-05-05 11:23 ` [Qemu-devel] [PULL v2 6/7] SMBIOS: Use bitmaps to prevent incompatible comand line options Gerd Hoffmann
2014-05-05 11:23 ` [Qemu-devel] [PULL v2 7/7] SMBIOS: Build aggregate smbios tables and entry point Gerd Hoffmann
2014-05-06 12:08 ` [Qemu-devel] [PULL v2 0/7] smbios: make qemu generate smbios tables Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399288996-9721-6-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=gsomlo@gmail.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=somlo@cmu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).