rte_free like Glibc free allows rte_free(NULL) as null operation.

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 app/test/test_hash_perf.c |  2 +-
 app/test/virtual_pmd.c    | 18 ++++++------------
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c
index bd531ec..6eabb21 100644
--- a/app/test/test_hash_perf.c
+++ b/app/test/test_hash_perf.c
@@ -387,7 +387,7 @@ struct tbl_perf_test_params tbl_perf_params[] =
        if (cond) {                                                     \
                printf("ERROR line %d: " str "\n", __LINE__, ##__VA_ARGS__); \
                if (handle) rte_fbk_hash_free(handle);                  \
-               if (keys) rte_free(keys);                               \
+               rte_free(keys);                                         \
                return -1;                                              \
        }                                                               \
 } while(0)
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 39ecf80..1f4da96 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -635,18 +635,12 @@ virtual_ethdev_create(const char *name, struct ether_addr 
*mac_addr,
        return eth_dev->data->port_id;

 err:
-       if (pci_dev)
-               rte_free(pci_dev);
-       if (pci_drv)
-               rte_free(pci_drv);
-       if (eth_drv)
-               rte_free(eth_drv);
-       if (dev_ops)
-               rte_free(dev_ops);
-       if (id_table)
-               rte_free(id_table);
-       if (dev_private)
-               rte_free(dev_private);
+       rte_free(pci_dev);
+       rte_free(pci_drv);
+       rte_free(eth_drv);
+       rte_free(dev_ops);
+       rte_free(id_table);
+       rte_free(dev_private);

        return -1;
 }
-- 
2.1.4

Reply via email to