From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2D9AAA034E; Wed, 9 Feb 2022 20:18:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 963E24115F; Wed, 9 Feb 2022 20:17:58 +0100 (CET) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mails.dpdk.org (Postfix) with ESMTP id EA96341157 for ; Wed, 9 Feb 2022 20:17:55 +0100 (CET) Received: by mail-pj1-f54.google.com with SMTP id d15-20020a17090a564f00b001b937f4ae2fso799409pji.4 for ; Wed, 09 Feb 2022 11:17:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+a5XAIa7rQ1Ark+VE6c8XjCE2YUmozsoazXkaEfznOc=; b=CaXWjIHLrPt5KIvbFm9i98Q1su9/DnAJdtQYkPfP2uHCymHHNRy2FeZ3Q62G3RzrWi Ikf6AuZxFnbSpvX0ND4tMJiPIRRI8xupVJZl3VflIjYZXck/s5AgnqowECs6VaV/3XNl TQnsgGv/T5KzCOZbAsrqJbhzOhvHnjqLs27JnVAKWiNUpO2wHftUN1stAvuvjhhjJvfC zoSDvltenP7jVxzKzFazoBYZ09ZrMcwxZFw4mODreyaOhM4aoeVTUN/oLa+pjtmrQH6B 7J20aTLAB5WDmhXpDcmCXX+awReGbSd2IYbhUyuhIIX2kXvFvD3OSnJ9pqMEBe920dDm eGHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+a5XAIa7rQ1Ark+VE6c8XjCE2YUmozsoazXkaEfznOc=; b=4FEUmlhc3zcx0NBDeTd8IC3wewdXwiBjjHN5RmvArc0kEnaF2bIk/KjDufL06d81BL P5QYNpViVa2M7pabucoZqaXQtjg28rb1MqmZomDDk7f7heFlGmICfdIfTVt4txUfB2NK sTvq7UORCcOBN1lWunxsDQUsJsEUAPrVSMn+BjruNQk+WxFDBPVsxIhvtd1HB1g7Iq/M NoRlQnl8Jr/naNYDcA3S7SBEmluSwlqDQI1g8QL6xe5+n8jNeeD0kDDVnlAidxVySee0 Tdekj9xdoVdgY1M5ZQtx5nTSwj9ff2PTP/zzuu0sPMAGP7w1ra2V/VfNd5uuGcwKN2dT fPVw== X-Gm-Message-State: AOAM531eA0idvdUkCCtdosFtQzPeO5DJ/t0yUyB8IyNea0sPGEC7oTAR erw2LXVFor8ltw2WgX4+2LrBjJ0Xk3byFSmG X-Google-Smtp-Source: ABdhPJzo1LVUuitIlOI93Vm7fwGAmNQIdH4k8l+Q3QG4QOg3f+gUbfCgwBfBY6Q53kGfXt0iNYxpyw== X-Received: by 2002:a17:90a:7844:: with SMTP id y4mr5046934pjl.13.1644434274858; Wed, 09 Feb 2022 11:17:54 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id u16sm14378401pgh.54.2022.02.09.11.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 11:17:54 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Anatoly Burakov , Jerin Jacob , Sunil Kumar Kori , Bruce Richardson , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Subject: [PATCH v3 03/36] eal: remove unnecessary NULL checks Date: Wed, 9 Feb 2022 11:17:15 -0800 Message-Id: <20220209191748.377729-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220209191748.377729-1-stephen@networkplumber.org> References: <20220124000518.319850-1-stephen@networkplumber.org> <20220209191748.377729-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Functions like free, rte_free, and rte_mempool_free already handle NULL pointer so the checks here are not necessary. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_devargs.c | 6 ++---- lib/eal/common/eal_common_memzone.c | 3 +-- lib/eal/common/eal_common_options.c | 9 +++------ lib/eal/common/eal_common_trace_ctf.c | 6 ++---- lib/eal/freebsd/eal.c | 4 +--- lib/eal/linux/eal.c | 10 +++------- lib/eal/windows/eal_alarm.c | 3 +-- lib/eal/windows/eal_memory.c | 3 +-- 8 files changed, 14 insertions(+), 30 deletions(-) diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c index 8c7650cf6c27..69004b0a2d2f 100644 --- a/lib/eal/common/eal_common_devargs.c +++ b/lib/eal/common/eal_common_devargs.c @@ -161,8 +161,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs, get_out: for (i = 0; i < RTE_DIM(layers); i++) { - if (layers[i].kvlist) - rte_kvargs_free(layers[i].kvlist); + rte_kvargs_free(layers[i].kvlist); } if (ret != 0) { if (allocated_data) { @@ -285,8 +284,7 @@ rte_devargs_reset(struct rte_devargs *da) { if (da == NULL) return; - if (da->data) - free(da->data); + free(da->data); da->data = NULL; } diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c index ecde9441ee90..9a0c5309ac7e 100644 --- a/lib/eal/common/eal_common_memzone.c +++ b/lib/eal/common/eal_common_memzone.c @@ -300,8 +300,7 @@ rte_memzone_free(const struct rte_memzone *mz) rte_rwlock_write_unlock(&mcfg->mlock); - if (addr != NULL) - rte_free(addr); + rte_free(addr); rte_eal_trace_memzone_free(name, addr, ret); return ret; diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index 45d393b3937e..ff44d2124bab 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -1989,12 +1989,9 @@ compute_ctrl_threads_cpuset(struct internal_config *internal_cfg) int eal_cleanup_config(struct internal_config *internal_cfg) { - if (internal_cfg->hugefile_prefix != NULL) - free(internal_cfg->hugefile_prefix); - if (internal_cfg->hugepage_dir != NULL) - free(internal_cfg->hugepage_dir); - if (internal_cfg->user_mbuf_pool_ops_name != NULL) - free(internal_cfg->user_mbuf_pool_ops_name); + free(internal_cfg->hugefile_prefix); + free(internal_cfg->hugepage_dir); + free(internal_cfg->user_mbuf_pool_ops_name); return 0; } diff --git a/lib/eal/common/eal_common_trace_ctf.c b/lib/eal/common/eal_common_trace_ctf.c index 33e419aac7fb..3b83bcdf57fd 100644 --- a/lib/eal/common/eal_common_trace_ctf.c +++ b/lib/eal/common/eal_common_trace_ctf.c @@ -52,8 +52,7 @@ meta_copy(char **meta, int *offset, char *str, int rc) return rc; free_str: - if (str) - free(str); + free(str); return -ENOMEM; } @@ -291,8 +290,7 @@ trace_metadata_create(void) return 0; fail: - if (meta) - free(meta); + free(meta); return -EBADF; } diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index a1cd2462db1b..00ba32f1d664 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -544,9 +544,7 @@ eal_parse_args(int argc, char **argv) RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n"); else { /* free old ops name */ - if (internal_conf->user_mbuf_pool_ops_name != - NULL) - free(internal_conf->user_mbuf_pool_ops_name); + free(internal_conf->user_mbuf_pool_ops_name); internal_conf->user_mbuf_pool_ops_name = ops_name; diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 9c8395ab14d0..68fcf86a2e4c 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -730,8 +730,7 @@ eal_parse_args(int argc, char **argv) RTE_LOG(ERR, EAL, "Could not store hugepage directory\n"); else { /* free old hugepage dir */ - if (internal_conf->hugepage_dir != NULL) - free(internal_conf->hugepage_dir); + free(internal_conf->hugepage_dir); internal_conf->hugepage_dir = hdir; } break; @@ -743,8 +742,7 @@ eal_parse_args(int argc, char **argv) RTE_LOG(ERR, EAL, "Could not store file prefix\n"); else { /* free old prefix */ - if (internal_conf->hugefile_prefix != NULL) - free(internal_conf->hugefile_prefix); + free(internal_conf->hugefile_prefix); internal_conf->hugefile_prefix = prefix; } break; @@ -804,9 +802,7 @@ eal_parse_args(int argc, char **argv) RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n"); else { /* free old ops name */ - if (internal_conf->user_mbuf_pool_ops_name != - NULL) - free(internal_conf->user_mbuf_pool_ops_name); + free(internal_conf->user_mbuf_pool_ops_name); internal_conf->user_mbuf_pool_ops_name = ops_name; diff --git a/lib/eal/windows/eal_alarm.c b/lib/eal/windows/eal_alarm.c index 103c1f909da3..51fe752c16d4 100644 --- a/lib/eal/windows/eal_alarm.c +++ b/lib/eal/windows/eal_alarm.c @@ -162,8 +162,7 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg) fail: if (timer != NULL) CloseHandle(timer); - if (ap != NULL) - free(ap); + free(ap); exit: rte_eal_trace_alarm_set(us, cb_fn, cb_arg, ret); diff --git a/lib/eal/windows/eal_memory.c b/lib/eal/windows/eal_memory.c index 2fd37d97085e..215d768e2c57 100644 --- a/lib/eal/windows/eal_memory.c +++ b/lib/eal/windows/eal_memory.c @@ -190,8 +190,7 @@ eal_mem_virt2iova_init(void) ret = 0; exit: - if (detail != NULL) - free(detail); + free(detail); if (list != INVALID_HANDLE_VALUE) SetupDiDestroyDeviceInfoList(list); -- 2.34.1