examples: remove useless null checks before rte_free
[dpdk.git] / examples / vhost_xen / vhost_monitor.c
index b9c1cb5..6455993 100644 (file)
@@ -138,7 +138,7 @@ add_xen_guest(int32_t dom_id)
        if ((guest = get_xen_guest(dom_id)) != NULL)
                return guest;
 
-       guest = (struct xen_guest * )calloc(1, sizeof(struct xen_guest));
+       guest = calloc(1, sizeof(struct xen_guest));
        if (guest) {
                RTE_LOG(ERR, XENHOST, "  %s: return newly created guest with %d rings\n", __func__, guest->vring_num);
                TAILQ_INSERT_TAIL(&guest_root, guest, next);
@@ -255,8 +255,8 @@ virtio_net_config_ll *new_device(unsigned int virtio_idx, struct xen_guest *gues
 
        /* Setup device and virtqueues. */
        new_ll_dev   = calloc(1, sizeof(struct virtio_net_config_ll));
-       virtqueue_rx = rte_zmalloc(NULL, sizeof(struct vhost_virtqueue), CACHE_LINE_SIZE);
-       virtqueue_tx = rte_zmalloc(NULL, sizeof(struct vhost_virtqueue), CACHE_LINE_SIZE);
+       virtqueue_rx = rte_zmalloc(NULL, sizeof(struct vhost_virtqueue), RTE_CACHE_LINE_SIZE);
+       virtqueue_tx = rte_zmalloc(NULL, sizeof(struct vhost_virtqueue), RTE_CACHE_LINE_SIZE);
        if (new_ll_dev == NULL || virtqueue_rx == NULL || virtqueue_tx == NULL)
                goto err;
 
@@ -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;
 }
 
@@ -434,8 +433,8 @@ static void virtio_init(void)
                        continue;
 
                for (j = 0; j < RTE_MAX_ETHPORTS; j++) {
-                       rte_snprintf(node, PATH_MAX, "%s%d", VIRTIO_START, j);
-                       rte_snprintf(path, PATH_MAX, XEN_VM_NODE_FMT,
+                       snprintf(node, PATH_MAX, "%s%d", VIRTIO_START, j);
+                       snprintf(path, PATH_MAX, XEN_VM_NODE_FMT,
                                        dom_id, node);
 
                        th = xs_transaction_start(watch.xs);