]> git.droids-corp.org - dpdk.git/commitdiff
pmd: remove useless null checks before rte_free
authorStephen Hemminger <stephen@networkplumber.org>
Tue, 7 Apr 2015 21:21:01 +0000 (14:21 -0700)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 13 Apr 2015 20:50:10 +0000 (22:50 +0200)
Since rte_free accept NULL and does nothing, better to save
space and remove these useless checks.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
lib/librte_pmd_af_packet/rte_eth_af_packet.c
lib/librte_pmd_bond/rte_eth_bond_api.c
lib/librte_pmd_enic/enic_main.c
lib/librte_pmd_mlx4/mlx4.c
lib/librte_pmd_null/rte_eth_null.c
lib/librte_pmd_pcap/rte_eth_pcap.c
lib/librte_pmd_ring/rte_eth_ring.c
lib/librte_pmd_xenvirt/rte_eth_xenvirt.c

index 2ac50ba3130c1a9b805bb545d09f055f9c19f04e..c10da6c4d1f79bdee322464f4b848691c37c660e 100644 (file)
@@ -680,18 +680,16 @@ rte_pmd_init_internals(const char *name,
        return 0;
 
 error:
-       if (data)
-               rte_free(data);
-       if (pci_dev)
-               rte_free(pci_dev);
+       rte_free(data);
+       rte_free(pci_dev);
+
        if (*internals) {
                for (q = 0; q < nb_queues; q++) {
                        munmap((*internals)->rx_queue[q].map,
                               2 * req->tp_block_size * req->tp_block_nr);
-                       if ((*internals)->rx_queue[q].rd)
-                               rte_free((*internals)->rx_queue[q].rd);
-                       if ((*internals)->tx_queue[q].rd)
-                               rte_free((*internals)->tx_queue[q].rd);
+
+                       rte_free((*internals)->rx_queue[q].rd);
+                       rte_free((*internals)->tx_queue[q].rd);
                        if (((*internals)->rx_queue[q].sockfd != 0) &&
                                ((*internals)->rx_queue[q].sockfd != qsockfd))
                                close((*internals)->rx_queue[q].sockfd);
index 13f39417ea9571804be1ade2621c19b4618069bc..f594fe153bdbeb45fde2d69f8c6940c5f922067f 100644 (file)
@@ -318,14 +318,11 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
        return eth_dev->data->port_id;
 
 err:
-       if (pci_dev)
-               rte_free(pci_dev);
-       if (pci_id_table)
-               rte_free(pci_id_table);
-       if (eth_drv)
-               rte_free(eth_drv);
-       if (internals)
-               rte_free(internals);
+       rte_free(pci_dev);
+       rte_free(pci_id_table);
+       rte_free(eth_drv);
+       rte_free(internals);
+
        return -1;
 }
 
index 0892b3e2b20b0436e85b07f70f2d5c36363a390c..0e40d4665d16824e4f2d8babf44dc74ee458173f 100644 (file)
@@ -983,8 +983,7 @@ static void enic_dev_deinit(struct enic *enic)
 {
        struct rte_eth_dev *eth_dev = enic->rte_dev;
 
-       if (eth_dev->data->mac_addrs)
-               rte_free(eth_dev->data->mac_addrs);
+       rte_free(eth_dev->data->mac_addrs);
 }
 
 
index fa749f45415dafd2d1e836915468173430d08825..0eca322d5de1b0dd62882e8372e33a470138ebf2 100644 (file)
@@ -792,10 +792,10 @@ txq_alloc_elts(struct txq *txq, unsigned int elts_n)
 error:
        if (mr_linear != NULL)
                claim_zero(ibv_dereg_mr(mr_linear));
-       if (elts_linear != NULL)
-               rte_free(elts_linear);
-       if (elts != NULL)
-               rte_free(elts);
+
+       rte_free(elts_linear);
+       rte_free(elts);
+
        DEBUG("%p: failed, freed everything", (void *)txq);
        assert(ret > 0);
        return ret;
@@ -823,8 +823,8 @@ txq_free_elts(struct txq *txq)
        txq->mr_linear = NULL;
        if (mr_linear != NULL)
                claim_zero(ibv_dereg_mr(mr_linear));
-       if (elts_linear != NULL)
-               rte_free(elts_linear);
+
+       rte_free(elts_linear);
        if (elts == NULL)
                return;
        for (i = 0; (i != elemof(*elts)); ++i) {
@@ -4602,8 +4602,7 @@ mlx4_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                continue;
 
 port_error:
-               if (priv)
-                       rte_free(priv);
+               rte_free(priv);
                if (pd)
                        claim_zero(ibv_dealloc_pd(pd));
                if (ctx)
index 0e1850270490fe6329a45b2dbf1cbf860e390e1d..036faafaeb760a1d1bf36a7a820ebcba0a716f65 100644 (file)
@@ -355,8 +355,7 @@ eth_queue_release(void *q)
                return;
 
        nq = q;
-       if (nq->dummy_packet)
-               rte_free(nq->dummy_packet);
+       rte_free(nq->dummy_packet);
 }
 
 static int
@@ -458,12 +457,10 @@ eth_dev_null_create(const char *name,
        return 0;
 
 error:
-       if (data)
-               rte_free(data);
-       if (pci_dev)
-               rte_free(pci_dev);
-       if (internals)
-               rte_free(internals);
+       rte_free(data);
+       rte_free(pci_dev);
+       rte_free(internals);
+
        return -1;
 }
 
index 204ae6825a4a5abf20c167dd3a6652a2d101719d..3a7db98d049ac2a10f91e874a247dff6b67e1de5 100644 (file)
@@ -760,12 +760,11 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 
        return 0;
 
-       error: if (data)
-               rte_free(data);
-       if (pci_dev)
-               rte_free(pci_dev);
-       if (*internals)
-               rte_free(*internals);
+error: 
+       rte_free(data);
+       rte_free(pci_dev);
+       rte_free(*internals);
+
        return -1;
 }
 
index 1e66d4ec194d51b914e120ebf0e2d05c13c100fd..199e15fcbf96d88cf069d683ad9de40561dc85b4 100644 (file)
@@ -349,12 +349,10 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
        return 0;
 
 error:
-       if (data)
-               rte_free(data);
-       if (pci_dev)
-               rte_free(pci_dev);
-       if (internals)
-               rte_free(internals);
+       rte_free(data);
+       rte_free(pci_dev);
+       rte_free(internals);
+
        return -1;
 }
 
index bc403d60b7c4576292758bfb60cdf2e204b6cdf0..edf2a5fa69c4539899f609f458dbf3dd6a84f49c 100644 (file)
@@ -679,12 +679,10 @@ eth_dev_xenvirt_create(const char *name, const char *params,
        return 0;
 
 err:
-       if (data)
-               rte_free(data);
-       if (pci_dev)
-               rte_free(pci_dev);
-       if (internals)
-               rte_free(internals);
+       rte_free(data);
+       rte_free(pci_dev);
+       rte_free(internals);
+
        return -1;
 }