DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 3/6] examples: get rid of unneeded null checks before rte_free
Date: Tue,  7 Apr 2015 14:21:00 -0700	[thread overview]
Message-ID: <1428441663-3825-3-git-send-email-stephen@networkplumber.org> (raw)
In-Reply-To: <1428441663-3825-1-git-send-email-stephen@networkplumber.org>

rte_free handles getting passed a NULL pointer.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/vhost/main.c                       | 3 +--
 examples/vhost_xen/vhost_monitor.c          | 7 +++----
 examples/vm_power_manager/channel_manager.c | 6 ++----
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index c3fcb80..ad10f82 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -2747,8 +2747,7 @@ new_device (struct virtio_net *dev)
 		RTE_LOG(INFO, VHOST_DATA, "(%"PRIu64") Failed to add device to data core\n", dev->device_fh);
 		vdev->ready = DEVICE_SAFE_REMOVE;
 		destroy_device(dev);
-		if (vdev->regions_hpa)
-			rte_free(vdev->regions_hpa);
+		rte_free(vdev->regions_hpa);
 		rte_free(vdev);
 		return -1;
 	}
diff --git a/examples/vhost_xen/vhost_monitor.c b/examples/vhost_xen/vhost_monitor.c
index 9d99962..6455993 100644
--- a/examples/vhost_xen/vhost_monitor.c
+++ b/examples/vhost_xen/vhost_monitor.c
@@ -298,10 +298,9 @@ virtio_net_config_ll *new_device(unsigned int virtio_idx, struct xen_guest *gues
 err:
 	if (new_ll_dev)
 		free(new_ll_dev);
-	if (virtqueue_rx)
-		rte_free(virtqueue_rx);
-	if (virtqueue_tx)
-		rte_free(virtqueue_tx);
+	rte_free(virtqueue_rx);
+	rte_free(virtqueue_tx);
+
 	return NULL;
 }
 
diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c
index 04344ae..7d892e2 100644
--- a/examples/vm_power_manager/channel_manager.c
+++ b/examples/vm_power_manager/channel_manager.c
@@ -800,9 +800,7 @@ channel_manager_exit(void)
 		rte_free(vm_info);
 	}
 
-	if (global_cpumaps != NULL)
-		rte_free(global_cpumaps);
-	if (global_vircpuinfo != NULL)
-		rte_free(global_vircpuinfo);
+	rte_free(global_cpumaps);
+	rte_free(global_vircpuinfo);
 	disconnect_hypervisor();
 }
-- 
2.1.4

  parent reply	other threads:[~2015-04-07 21:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 21:20 [dpdk-dev] [PATCH v2 1/6] test: remove useless memset Stephen Hemminger
2015-04-07 21:20 ` [dpdk-dev] [PATCH v2 2/6] test: remove useless check of NULL before rte_free Stephen Hemminger
2015-04-07 21:21 ` Stephen Hemminger [this message]
2015-04-07 21:21 ` [dpdk-dev] [PATCH v2 4/6] pmd: remove unnecessary if() " Stephen Hemminger
2015-04-07 21:21 ` [dpdk-dev] [PATCH v2 5/6] test: put dev_ops in private Stephen Hemminger
2015-04-07 21:21 ` [dpdk-dev] [PATCH v2 6/6] eth: make dev_ops const Stephen Hemminger
2015-04-08 11:49 ` [dpdk-dev] [PATCH v2 1/6] test: remove useless memset Neil Horman
2015-04-13 20:36   ` Thomas Monjalon

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=1428441663-3825-3-git-send-email-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.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).