From ef1e1e0782e99c9dcf2b35e5310cdd8ca9211374 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 26 Aug 2015 12:17:18 +0100 Subject: maint: avoid useless "if (foo) free(foo)" pattern The free() and g_free() functions both happily accept NULL on any platform QEMU builds on. As such putting a conditional 'if (foo)' check before calls to 'free(foo)' merely serves to bloat the lines of code. Signed-off-by: Daniel P. Berrange Reviewed-by: Markus Armbruster Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- hw/core/loader.c | 3 +-- hw/core/qdev-properties.c | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'hw/core') diff --git a/hw/core/loader.c b/hw/core/loader.c index 216eeeb917..a96a74e579 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -594,8 +594,7 @@ static int load_uboot_image(const char *filename, hwaddr *ep, hwaddr *loadaddr, ret = hdr->ih_size; out: - if (data) - g_free(data); + g_free(data); close(fd); return ret; } diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 04fd80a4de..33e245e12f 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -422,9 +422,7 @@ static void set_string(Object *obj, Visitor *v, void *opaque, error_propagate(errp, local_err); return; } - if (*ptr) { - g_free(*ptr); - } + g_free(*ptr); *ptr = str; } -- cgit v1.2.3