From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@amazon.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] virtio: Drop superfluous conditionals around g_free()
Date: Fri, 6 Jun 2014 18:43:29 +0200 [thread overview]
Message-ID: <1402073010-9445-2-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1402073010-9445-1-git-send-email-armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/9pfs/virtio-9p.c | 4 +---
hw/net/virtio-net.c | 24 ++++++++----------------
hw/virtio/vhost.c | 8 ++------
hw/virtio/virtio.c | 12 ++++--------
4 files changed, 15 insertions(+), 33 deletions(-)
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 9aa6725..5861a5b 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -299,9 +299,7 @@ static int v9fs_xattr_fid_clunk(V9fsPDU *pdu, V9fsFidState *fidp)
free_out:
v9fs_string_free(&fidp->fs.xattr.name);
free_value:
- if (fidp->fs.xattr.value) {
- g_free(fidp->fs.xattr.value);
- }
+ g_free(fidp->fs.xattr.value);
return retval;
}
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 940a7cf..dd28a5a 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1509,14 +1509,10 @@ void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
*/
assert(type != NULL);
- if (n->netclient_name) {
- g_free(n->netclient_name);
- n->netclient_name = NULL;
- }
- if (n->netclient_type) {
- g_free(n->netclient_type);
- n->netclient_type = NULL;
- }
+ g_free(n->netclient_name);
+ n->netclient_name = NULL;
+ g_free(n->netclient_type);
+ n->netclient_type = NULL;
if (name != NULL) {
n->netclient_name = g_strdup(name);
@@ -1616,14 +1612,10 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)
unregister_savevm(dev, "virtio-net", n);
- if (n->netclient_name) {
- g_free(n->netclient_name);
- n->netclient_name = NULL;
- }
- if (n->netclient_type) {
- g_free(n->netclient_type);
- n->netclient_type = NULL;
- }
+ g_free(n->netclient_name);
+ n->netclient_name = NULL;
+ g_free(n->netclient_type);
+ n->netclient_type = NULL;
g_free(n->mac_table.macs);
g_free(n->vlans);
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 9e336ad..d2bd1f7 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -297,9 +297,7 @@ static inline void vhost_dev_log_resize(struct vhost_dev* dev, uint64_t size)
if (dev->log_size) {
vhost_log_sync_range(dev, 0, dev->log_size * VHOST_LOG_CHUNK - 1);
}
- if (dev->log) {
- g_free(dev->log);
- }
+ g_free(dev->log);
dev->log = log;
dev->log_size = size;
}
@@ -603,9 +601,7 @@ static int vhost_migration_log(MemoryListener *listener, int enable)
if (r < 0) {
return r;
}
- if (dev->log) {
- g_free(dev->log);
- }
+ g_free(dev->log);
dev->log = NULL;
dev->log_size = 0;
} else {
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 3557c17..c8e36a5 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1164,10 +1164,8 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq)
void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name)
{
- if (vdev->bus_name) {
- g_free(vdev->bus_name);
- vdev->bus_name = NULL;
- }
+ g_free(vdev->bus_name);
+ vdev->bus_name = NULL;
if (bus_name) {
vdev->bus_name = g_strdup(bus_name);
@@ -1206,10 +1204,8 @@ static void virtio_device_unrealize(DeviceState *dev, Error **errp)
}
}
- if (vdev->bus_name) {
- g_free(vdev->bus_name);
- vdev->bus_name = NULL;
- }
+ g_free(vdev->bus_name);
+ vdev->bus_name = NULL;
}
static void virtio_device_class_init(ObjectClass *klass, void *data)
--
1.9.3
next prev parent reply other threads:[~2014-06-06 16:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-06 16:43 [Qemu-devel] [PATCH 0/2] virtio: Drop some superfluous conditionals Markus Armbruster
2014-06-06 16:43 ` Markus Armbruster [this message]
2014-06-06 16:43 ` [Qemu-devel] [PATCH 2/2] virtio: Drop superfluous conditionals around g_strdup() Markus Armbruster
2014-06-06 16:56 ` [Qemu-devel] [PATCH 0/2] virtio: Drop some superfluous conditionals Eric Blake
2014-06-08 15:18 ` Michael S. Tsirkin
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=1402073010-9445-2-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=aliguori@amazon.com \
--cc=mst@redhat.com \
--cc=qemu-devel@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).