diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2015-08-26 12:17:18 +0100 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2015-09-11 10:21:38 +0300 |
commit | ef1e1e0782e99c9dcf2b35e5310cdd8ca9211374 (patch) | |
tree | 0b0f9a746055b66019016ed2d8e4ff9df7d79a8c /hw/net/rocker | |
parent | 4595a48a10e576638795950b61957f83d2ed09b4 (diff) | |
download | qemu-ef1e1e0782e99c9dcf2b35e5310cdd8ca9211374.tar.gz qemu-ef1e1e0782e99c9dcf2b35e5310cdd8ca9211374.tar.bz2 qemu-ef1e1e0782e99c9dcf2b35e5310cdd8ca9211374.zip |
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 <berrange@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'hw/net/rocker')
-rw-r--r-- | hw/net/rocker/rocker.c | 4 | ||||
-rw-r--r-- | hw/net/rocker/rocker_desc.c | 8 |
2 files changed, 3 insertions, 9 deletions
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c index 47d080fd33..7e7bda4987 100644 --- a/hw/net/rocker/rocker.c +++ b/hw/net/rocker/rocker.c @@ -265,9 +265,7 @@ err_bad_io: err_no_mem: err_bad_attr: for (i = 0; i < ROCKER_TX_FRAGS_MAX; i++) { - if (iov[i].iov_base) { - g_free(iov[i].iov_base); - } + g_free(iov[i].iov_base); } return err; diff --git a/hw/net/rocker/rocker_desc.c b/hw/net/rocker/rocker_desc.c index 9d896fe470..b5c0b4a241 100644 --- a/hw/net/rocker/rocker_desc.c +++ b/hw/net/rocker/rocker_desc.c @@ -136,9 +136,7 @@ bool desc_ring_set_size(DescRing *ring, uint32_t size) } for (i = 0; i < ring->size; i++) { - if (ring->info[i].buf) { - g_free(ring->info[i].buf); - } + g_free(ring->info[i].buf); } ring->size = size; @@ -360,9 +358,7 @@ DescRing *desc_ring_alloc(Rocker *r, int index) void desc_ring_free(DescRing *ring) { - if (ring->info) { - g_free(ring->info); - } + g_free(ring->info); g_free(ring); } |