From patchwork Fri Jun 6 16:43:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 356961 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BEFF214009A for ; Sat, 7 Jun 2014 02:45:29 +1000 (EST) Received: from localhost ([::1]:48411 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsxGh-0001mh-PT for incoming@patchwork.ozlabs.org; Fri, 06 Jun 2014 12:45:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsxF3-00077z-D2 for qemu-devel@nongnu.org; Fri, 06 Jun 2014 12:43:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsxEs-0006gl-Rh for qemu-devel@nongnu.org; Fri, 06 Jun 2014 12:43:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsxEs-0006ga-Jf for qemu-devel@nongnu.org; Fri, 06 Jun 2014 12:43:34 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s56GhXKK022939 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 6 Jun 2014 12:43:33 -0400 Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s56GhUTm027447 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 6 Jun 2014 12:43:32 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 42ABB30403B0; Fri, 6 Jun 2014 18:43:30 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 6 Jun 2014 18:43:29 +0200 Message-Id: <1402073010-9445-2-git-send-email-armbru@redhat.com> In-Reply-To: <1402073010-9445-1-git-send-email-armbru@redhat.com> References: <1402073010-9445-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: aliguori@amazon.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 1/2] virtio: Drop superfluous conditionals around g_free() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Markus Armbruster --- 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)