Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/10036/?format=api
https://patches.dpdk.org/api/patches/10036/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1453375399-25576-1-git-send-email-david.marchand@6wind.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1453375399-25576-1-git-send-email-david.marchand@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1453375399-25576-1-git-send-email-david.marchand@6wind.com", "date": "2016-01-21T11:23:19", "name": "[dpdk-dev] no need to test for NULL when freeing", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "46f8af288cae4fb3191ee422718d0d1435ee46df", "submitter": { "id": 3, "url": "https://patches.dpdk.org/api/people/3/?format=api", "name": "David Marchand", "email": "david.marchand@6wind.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1453375399-25576-1-git-send-email-david.marchand@6wind.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/10036/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/10036/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id F06818E84;\n\tThu, 21 Jan 2016 12:23:40 +0100 (CET)", "from mail-wm0-f49.google.com (mail-wm0-f49.google.com\n\t[74.125.82.49]) by dpdk.org (Postfix) with ESMTP id 0DD5B8E7B\n\tfor <dev@dpdk.org>; Thu, 21 Jan 2016 12:23:40 +0100 (CET)", "by mail-wm0-f49.google.com with SMTP id l65so215716060wmf.1\n\tfor <dev@dpdk.org>; Thu, 21 Jan 2016 03:23:40 -0800 (PST)", "from alcyon.dev.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net.\n\t[82.239.227.177]) by smtp.gmail.com with ESMTPSA id\n\tl7sm1023699wjx.14.2016.01.21.03.23.38\n\t(version=TLSv1/SSLv3 cipher=OTHER);\n\tThu, 21 Jan 2016 03:23:39 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=6wind-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id;\n\tbh=KPgzWVR2TEjesZX0JPoK3y+RAnXwgUq7isHaUTz0AjE=;\n\tb=we3e6+m01U2eiVZjOEAxenEAaOpRP+IjXx8V4Q86wTCj5zTkUSuSCwFLyhWthz+HpW\n\t46FZepN8AUnsjWyRK59PeEAWJcla/LlZBWteXNVaiTLjj0jdGwvfW1Erv/aS5f3VqII3\n\ttVk9HTyeDnST1agE6Pm4go6YT0Nb3lmu9CatZtWMRomhmpWE2L7q5oUACcYJJdwwcjSN\n\tny/pWvlVqOGLwSjDduFOsJjhNpJPovktEisfjQeS9Lfbvo5YCTiVNlCbKAh7cKDGb1j9\n\tT5LBEzpqNLqv0weGZsIetXbt1U8G3jQLiBCwDwwmFPA3vmgrkejd1zlhjfNts/E5AoMU\n\t7AWQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id;\n\tbh=KPgzWVR2TEjesZX0JPoK3y+RAnXwgUq7isHaUTz0AjE=;\n\tb=UJE2O0JvPC2gcvKoyTjFD6CpUB5NUBdj734twitKrG+nzCmdjVre2n+xv9j54oms7h\n\t599GvJCIVJiPDu9z/CQhmCAvmZvkOPXvUVTjFRwRoMLlt4RcOkLxWgGqmjkweMB+MEKP\n\tH6pqdEbuGCDQlGBsPR/feYynvjGADAn5L2RUbzHDiSe8t/fL4zOe8vXxrz6hODk0AxGt\n\tC5yCmd+XmOgLyfF1qazE13rVAMZpiKrUhlUZOJuRuPpklPbz/k9n65hU2GgnIqHTjRwH\n\tZAeEeyLMoRvZ964AcxKx+AarSZnR3sOJo1FaowVjKB1UbYA9bhPiICOXb6c/ITT9OH5I\n\tJLTQ==", "X-Gm-Message-State": "ALoCoQmxglnAN+63BhFCwosZ1Dv0GQg1wPpYUHros+fmB+tNFk38ja1RDg8a3D+2oIk5hM8Mv2tOesSuMNdf/EYkzR+h/iusDg==", "X-Received": "by 10.194.82.229 with SMTP id l5mr47117541wjy.140.1453375419736; \n\tThu, 21 Jan 2016 03:23:39 -0800 (PST)", "From": "David Marchand <david.marchand@6wind.com>", "To": "dev@dpdk.org", "Date": "Thu, 21 Jan 2016 12:23:19 +0100", "Message-Id": "<1453375399-25576-1-git-send-email-david.marchand@6wind.com>", "X-Mailer": "git-send-email 1.7.10.4", "Subject": "[dpdk-dev] [PATCH] no need to test for NULL when freeing", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "free() already handles NULL pointer.\n\nSigned-off-by: David Marchand <david.marchand@6wind.com>\n---\n app/test/test_devargs.c | 3 +-\n app/test/test_link_bonding.c | 6 ++--\n app/test/test_pci.c | 3 +-\n app/test/test_ring.c | 36 ++++++++--------------\n drivers/net/xenvirt/rte_eth_xenvirt.c | 6 ++--\n drivers/net/xenvirt/rte_mempool_gntalloc.c | 9 ++----\n examples/ip_pipeline/cpu_core_map.c | 3 +-\n .../pipeline/pipeline_flow_classification_be.c | 6 ++--\n examples/vhost_xen/vhost_monitor.c | 3 +-\n examples/vhost_xen/xenstore_parse.c | 33 +++++++-------------\n lib/librte_eal/common/eal_common_devargs.c | 3 +-\n lib/librte_eal/linuxapp/eal/eal_memory.c | 3 +-\n lib/librte_ether/rte_ethdev.c | 6 ++--\n lib/librte_kvargs/rte_kvargs.c | 4 +--\n 14 files changed, 41 insertions(+), 83 deletions(-)", "diff": "diff --git a/app/test/test_devargs.c b/app/test/test_devargs.c\nindex 049f32d..e5a9aa0 100644\n--- a/app/test/test_devargs.c\n+++ b/app/test/test_devargs.c\n@@ -48,8 +48,7 @@ static void free_devargs_list(void)\n \twhile (!TAILQ_EMPTY(&devargs_list)) {\n \t\tdevargs = TAILQ_FIRST(&devargs_list);\n \t\tTAILQ_REMOVE(&devargs_list, devargs, next);\n-\t\tif (devargs->args)\n-\t\t\tfree(devargs->args);\n+\t\tfree(devargs->args);\n \t\tfree(devargs);\n \t}\n }\ndiff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c\nindex 2d98958..7cbc289 100644\n--- a/app/test/test_link_bonding.c\n+++ b/app/test/test_link_bonding.c\n@@ -4023,10 +4023,8 @@ test_close_bonded_device(void)\n static void\n testsuite_teardown(void)\n {\n-\tif (test_params->pkt_eth_hdr != NULL) {\n-\t\tfree(test_params->pkt_eth_hdr);\n-\t\ttest_params->pkt_eth_hdr = NULL;\n-\t}\n+\tfree(test_params->pkt_eth_hdr);\n+\ttest_params->pkt_eth_hdr = NULL;\n \n \t/* Clean up and remove slaves from bonded device */\n \tremove_slaves_and_stop_bonded_device();\ndiff --git a/app/test/test_pci.c b/app/test/test_pci.c\nindex 5530d99..0ed357e 100644\n--- a/app/test/test_pci.c\n+++ b/app/test/test_pci.c\n@@ -139,8 +139,7 @@ static void free_devargs_list(void)\n \twhile (!TAILQ_EMPTY(&devargs_list)) {\n \t\tdevargs = TAILQ_FIRST(&devargs_list);\n \t\tTAILQ_REMOVE(&devargs_list, devargs, next);\n-\t\tif (devargs->args)\n-\t\t\tfree(devargs->args);\n+\t\tfree(devargs->args);\n \t\tfree(devargs);\n \t}\n }\ndiff --git a/app/test/test_ring.c b/app/test/test_ring.c\nindex e5614de..943c350 100644\n--- a/app/test/test_ring.c\n+++ b/app/test/test_ring.c\n@@ -471,17 +471,13 @@ test_ring_basic(void)\n \tif (ret != 0)\n \t\tgoto fail;\n \n-\tif (src)\n-\t\tfree(src);\n-\tif (dst)\n-\t\tfree(dst);\n+\tfree(src);\n+\tfree(dst);\n \treturn 0;\n \n fail:\n-\tif (src)\n-\t\tfree(src);\n-\tif (dst)\n-\t\tfree(dst);\n+\tfree(src);\n+\tfree(dst);\n \treturn -1;\n }\n \n@@ -759,17 +755,13 @@ test_ring_burst_basic(void)\n \t\tgoto fail;\n \n \t/* Free memory before test completed */\n-\tif (src)\n-\t\tfree(src);\n-\tif (dst)\n-\t\tfree(dst);\n+\tfree(src);\n+\tfree(dst);\n \treturn 0;\n \n fail:\n-\tif (src)\n-\t\tfree(src);\n-\tif (dst)\n-\t\tfree(dst);\n+\tfree(src);\n+\tfree(dst);\n \treturn -1;\n }\n \n@@ -1168,17 +1160,13 @@ test_ring_stats(void)\n \tmemset(&r->stats[lcore_id], 0, sizeof(r->stats[lcore_id]));\n \n \t/* Free memory before test completed */\n-\tif (src)\n-\t\tfree(src);\n-\tif (dst)\n-\t\tfree(dst);\n+\tfree(src);\n+\tfree(dst);\n \treturn 0;\n \n fail:\n-\tif (src)\n-\t\tfree(src);\n-\tif (dst)\n-\t\tfree(dst);\n+\tfree(src);\n+\tfree(dst);\n \treturn -1;\n #endif\n }\ndiff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c\nindex 3353bcb..3f31806 100644\n--- a/drivers/net/xenvirt/rte_eth_xenvirt.c\n+++ b/drivers/net/xenvirt/rte_eth_xenvirt.c\n@@ -431,10 +431,8 @@ gntalloc_vring_create(int queue_type, uint32_t size, int vtidx)\n \t\tva = NULL;\n \t}\n out:\n-\tif (pa_arr)\n-\t\tfree(pa_arr);\n-\tif (gref_arr)\n-\t\tfree(gref_arr);\n+\tfree(pa_arr);\n+\tfree(gref_arr);\n \n \treturn va;\n }\ndiff --git a/drivers/net/xenvirt/rte_mempool_gntalloc.c b/drivers/net/xenvirt/rte_mempool_gntalloc.c\nindex 0585f08..7bfbfda 100644\n--- a/drivers/net/xenvirt/rte_mempool_gntalloc.c\n+++ b/drivers/net/xenvirt/rte_mempool_gntalloc.c\n@@ -229,15 +229,12 @@ mmap_failed:\n \t\t\tmunmap(gnt_arr[i].va, pg_sz);\n \t}\n out:\n-\tif (gnt_arr)\n-\t\tfree(gnt_arr);\n+\tfree(gnt_arr);\n \tif (orig_va)\n \t\tmunmap(orig_va, sz);\n \tif (mp == NULL) {\n-\t\tif (gref_arr)\n-\t\t\tfree(gref_arr);\n-\t\tif (pa_arr)\n-\t\t\tfree(pa_arr);\n+\t\tfree(gref_arr);\n+\t\tfree(pa_arr);\n \n \t\t/* some gref has already been de-allocated from the list in the driver,\n \t\t * so dealloc one by one, and it is safe to deallocate twice\ndiff --git a/examples/ip_pipeline/cpu_core_map.c b/examples/ip_pipeline/cpu_core_map.c\nindex 331b946..2a91f31 100644\n--- a/examples/ip_pipeline/cpu_core_map.c\n+++ b/examples/ip_pipeline/cpu_core_map.c\n@@ -488,6 +488,5 @@ cpu_core_map_get_lcore_id(struct cpu_core_map *map,\n void\n cpu_core_map_free(struct cpu_core_map *map)\n {\n-\tif (map)\n-\t\tfree(map);\n+\tfree(map);\n }\ndiff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c\nindex e808e79..ac80fc6 100644\n--- a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c\n+++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c\n@@ -333,10 +333,8 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,\n \treturn 0;\n \n error_parse:\n-\tif (key_mask_str != NULL)\n-\t\tfree(key_mask_str);\n-\tif (p->key_mask != NULL)\n-\t\tfree(p->key_mask);\n+\tfree(key_mask_str);\n+\tfree(p->key_mask);\n \treturn -1;\n }\n \ndiff --git a/examples/vhost_xen/vhost_monitor.c b/examples/vhost_xen/vhost_monitor.c\nindex a891c56..7cc5c2f 100644\n--- a/examples/vhost_xen/vhost_monitor.c\n+++ b/examples/vhost_xen/vhost_monitor.c\n@@ -296,8 +296,7 @@ virtio_net_config_ll *new_device(unsigned int virtio_idx, struct xen_guest *gues\n \tadd_config_ll_entry(new_ll_dev);\n \treturn new_ll_dev;\n err:\n-\tif (new_ll_dev)\n-\t\tfree(new_ll_dev);\n+\tfree(new_ll_dev);\n \trte_free(virtqueue_rx);\n \trte_free(virtqueue_tx);\n \ndiff --git a/examples/vhost_xen/xenstore_parse.c b/examples/vhost_xen/xenstore_parse.c\nindex eb629e2..26d2432 100644\n--- a/examples/vhost_xen/xenstore_parse.c\n+++ b/examples/vhost_xen/xenstore_parse.c\n@@ -203,8 +203,7 @@ xen_free_gntnode(struct xen_gntnode *gntnode)\n {\n \tif (gntnode == NULL)\n \t\treturn;\n-\tif (gntnode->gnt_info)\n-\t\tfree(gntnode->gnt_info);\n+\tfree(gntnode->gnt_info);\n \tfree(gntnode);\n }\n \n@@ -286,14 +285,10 @@ parse_gntnode(int dom_id, char *path)\n \treturn gntnode;\n \n err:\n-\tif (gnt)\n-\t\tfree(gnt);\n-\tif (gntnode)\n-\t\tfree(gntnode);\n-\tif (gref_list)\n-\t\tfree(gref_list);\n-\tif (buf)\n-\t\tfree(buf);\n+\tfree(gnt);\n+\tfree(gntnode);\n+\tfree(gref_list);\n+\tfree(buf);\n \treturn NULL;\n }\n \n@@ -412,8 +407,7 @@ parse_mpool_va(struct xen_mempool *mempool)\n \t}\n \tret = 0;\n out:\n-\tif (buf)\n-\t\tfree(buf);\n+\tfree(buf);\n \treturn ret;\n }\n \n@@ -460,8 +454,7 @@ cleanup_mempool(struct xen_mempool *mempool)\n \t}\n \tmempool->pindex = NULL;\n \n-\tif (mempool->mempfn_tbl)\n-\t\tfree(mempool->mempfn_tbl);\n+\tfree(mempool->mempfn_tbl);\n \tmempool->mempfn_tbl = NULL;\n }\n \n@@ -559,8 +552,7 @@ xen_map_vringflag(struct xen_vring *vring)\n \tfree(buf);\n \treturn 0;\n err:\n-\tif (buf)\n-\t\tfree(buf);\n+\tfree(buf);\n \tif (vring->flag) {\n \t\tmunmap(vring->flag, pg_sz);\n \t\tvring->flag = NULL;\n@@ -622,8 +614,7 @@ cleanup_vring(struct xen_vring *vring)\n \t}\n \tvring->rx_pindex = NULL;\n \n-\tif (vring->rxpfn_tbl)\n-\t\tfree(vring->rxpfn_tbl);\n+\tfree(vring->rxpfn_tbl);\n \tvring->rxpfn_tbl = NULL;\n \n \tif (vring->txvring_addr) {\n@@ -644,8 +635,7 @@ cleanup_vring(struct xen_vring *vring)\n \t}\n \tvring->tx_pindex = NULL;\n \n-\tif (vring->txpfn_tbl)\n-\t\tfree(vring->txpfn_tbl);\n+\tfree(vring->txpfn_tbl);\n \tvring->txpfn_tbl = NULL;\n \n \tif (vring->flag) {\n@@ -680,8 +670,7 @@ xen_parse_etheraddr(struct xen_vring *vring)\n \t\tgoto out;\n \tret = 0;\n out:\n-\tif (buf)\n-\t\tfree(buf);\n+\tfree(buf);\n \treturn ret;\n }\n \ndiff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c\nindex 5d075d0..2bfe54a 100644\n--- a/lib/librte_eal/common/eal_common_devargs.c\n+++ b/lib/librte_eal/common/eal_common_devargs.c\n@@ -120,8 +120,7 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)\n \treturn 0;\n \n fail:\n-\tif (buf)\n-\t\tfree(buf);\n+\tfree(buf);\n \tif (devargs) {\n \t\tfree(devargs->args);\n \t\tfree(devargs);\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c\nindex 846fd31..72568e5 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_memory.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c\n@@ -1412,8 +1412,7 @@ rte_eal_hugepage_init(void)\n \treturn 0;\n \n fail:\n-\tif (tmp_hp)\n-\t\tfree(tmp_hp);\n+\tfree(tmp_hp);\n \treturn -1;\n }\n \ndiff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c\nindex ed971b4..af990e2 100644\n--- a/lib/librte_ether/rte_ethdev.c\n+++ b/lib/librte_ether/rte_ethdev.c\n@@ -586,10 +586,8 @@ rte_eth_dev_attach_vdev(const char *vdevargs, uint8_t *port_id)\n \n \tret = 0;\n end:\n-\tif (name)\n-\t\tfree(name);\n-\tif (args)\n-\t\tfree(args);\n+\tfree(name);\n+\tfree(args);\n \n \tif (ret < 0)\n \t\tRTE_LOG(ERR, EAL, \"Driver, cannot attach the device\\n\");\ndiff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c\nindex c2dd051..8d56abd 100644\n--- a/lib/librte_kvargs/rte_kvargs.c\n+++ b/lib/librte_kvargs/rte_kvargs.c\n@@ -177,9 +177,7 @@ rte_kvargs_free(struct rte_kvargs *kvlist)\n \tif (!kvlist)\n \t\treturn;\n \n-\tif (kvlist->str != NULL)\n-\t\tfree(kvlist->str);\n-\n+\tfree(kvlist->str);\n \tfree(kvlist);\n }\n \n", "prefixes": [ "dpdk-dev" ] }{ "id": 10036, "url": "