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 CAC10A04AD; Mon, 24 Jan 2022 18:47:40 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 58DCF427E6; Mon, 24 Jan 2022 18:47:28 +0100 (CET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id D20AC427E3 for ; Mon, 24 Jan 2022 18:47:25 +0100 (CET) Received: by mail-pl1-f169.google.com with SMTP id d1so16300348plh.10 for ; Mon, 24 Jan 2022 09:47:25 -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=TNFTY4lice/dZPTBYg9Avv4Lr9A8xdw/ptuoLV9oUuo=; b=SpVxbDo5HlYr39yHDqFCbjHwphRZdbAfpUUeJ560+XPC3pLb5fn6y1FBYSP55jSAAd e3gzhzNBe94dn7/tBywA90XQQsNC9jzLUk3C17KeXj989lw6YaquFgEYNhKU/Czibpva sVTuBtxKBHPZYF5ZoUzXalfCvtsGPhlYsF7L27txBZPAh2xYI+oy630uEBBmRJVBXU5n Hn/hBM9lHZXwUKMLRlvplY9oegIwzr+Tn6nMSG3AYUpOTlDiZEPPURlYe3hsgq7VkJzy 5WhNVKcWmYnmqzA8s3IvkYUaLjSGPxcRoTuv+zXjq6ODjACx7zJ+EGvvN14Psht45r48 aKRA== 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=TNFTY4lice/dZPTBYg9Avv4Lr9A8xdw/ptuoLV9oUuo=; b=t3PTMrvSNBwYuNYQm1J51CCyZ0bv1KX+Zldx4rn1CAT8FwNxiqvdh3D7PhRelR9L8t 3Bgh6oqx74Bvn2b0aKlOD3hsgNIaPrHR3z2XRO28wmpY9HlhIwQY2KuEC63jE0a27osP bvmFgB2lmMSy9K6v92cjQ6f9W1Nc5mjyUrdxT7GlFOR994mVKQbU3CCKRQ8znyrCiMcy Yu3Suj53D9kBmQPzppQIZ2ji5Dn/7dnHi3NzUCASLeEfCOhlbBymW3QOrjjjJOaSM9Ug 1ohuB6iwngmFumfBLuM1mbc5bZZyM0O0ZWbDNPK+zibSj83Ay1u5CnaRfUz+SFq5ZOdk yDaA== X-Gm-Message-State: AOAM532QSgYUO6IZ6LT0GuIOfOWXL2hs1r9HbNlub64bxpCXj0ewFMuH KLR9d5e4u6z1yDIrUXU0zqWdfdvljmGmUg== X-Google-Smtp-Source: ABdhPJzVbLEkzS6kbyswnnIaqRMIYV1iDImA1lg5kErSIH+bjLle11Iz7VWTjw0thv4kiWeSXQLBnQ== X-Received: by 2002:a17:90a:8a02:: with SMTP id w2mr2994600pjn.177.1643046444833; Mon, 24 Jan 2022 09:47:24 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id q7sm15835082pfs.37.2022.01.24.09.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 09:47:24 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Anatoly Burakov , Jerin Jacob , Sunil Kumar Kori , Bruce Richardson Subject: [PATCH v2 03/83] eal: remove unnecessary NULL checks Date: Mon, 24 Jan 2022 09:45:59 -0800 Message-Id: <20220124174719.14417-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220124174719.14417-1-stephen@networkplumber.org> References: <20220124000518.319850-1-stephen@networkplumber.org> <20220124174719.14417-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() 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 +++------- 6 files changed, 12 insertions(+), 26 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 1cfdd75f3b79..09b7b17ffa06 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -1962,12 +1962,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 60b49248388e..f8e39b7e4277 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; -- 2.30.2