From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: [Qemu-devel] [PATCH] smbios: use g_free directly on NULL pointers
Date: Wed, 4 Jun 2014 18:00:28 +0200 [thread overview]
Message-ID: <1401897628-13422-1-git-send-email-pbonzini@redhat.com> (raw)
No need to wrap it with an if.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/i386/smbios.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index 7660718..ab89420 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -740,11 +740,6 @@ void smbios_set_cpuid(uint32_t version, uint32_t features)
field = value; \
}
-#define G_FREE_UNLESS_NULL(ptr) \
- if (ptr != NULL) { \
- g_free(ptr); \
- }
-
void smbios_set_defaults(const char *manufacturer, const char *product,
const char *version, bool legacy_mode)
{
@@ -753,7 +748,7 @@ void smbios_set_defaults(const char *manufacturer, const char *product,
/* drop unwanted version of command-line file blob(s) */
if (smbios_legacy) {
- G_FREE_UNLESS_NULL(smbios_tables);
+ g_free(smbios_tables);
/* in legacy mode, also complain if fields were given for types > 1 */
if (find_next_bit(have_fields_bitmap,
SMBIOS_MAX_TYPE+1, 2) < SMBIOS_MAX_TYPE+1) {
@@ -762,7 +757,7 @@ void smbios_set_defaults(const char *manufacturer, const char *product,
exit(1);
}
} else {
- G_FREE_UNLESS_NULL(smbios_entries);
+ g_free(smbios_entries);
}
SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer);
--
1.8.3.1
next reply other threads:[~2014-06-04 16:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-04 16:00 Paolo Bonzini [this message]
2014-06-05 15:40 ` [Qemu-devel] [PATCH] smbios: use g_free directly on NULL pointers Benoît Canet
2014-06-08 13:16 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
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=1401897628-13422-1-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/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).