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 C4D2CA04A6; Mon, 24 Jan 2022 01:05:35 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C2D2427B8; Mon, 24 Jan 2022 01:05:26 +0100 (CET) Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by mails.dpdk.org (Postfix) with ESMTP id 75A8740040 for ; Mon, 24 Jan 2022 01:05:24 +0100 (CET) Received: by mail-pj1-f43.google.com with SMTP id s61-20020a17090a69c300b001b4d0427ea2so18757874pjj.4 for ; Sun, 23 Jan 2022 16:05:24 -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=WCno3oN6jWVoA2MTmqLEMukEXE/TbbB+rSIzazHhasoToTBO+cVeau8PLm8ZwVF/dQ 99atH59YaiF7PL1ojgNuQXrLndIRYz/c8CrV+SmAafYdle03IIxAhbQVXAgSsp7WO3V2 nh6rSR1ELr9ruQOHNm+FYX28UHKb6QUqEjOF30vvyS/WxnYi39LlWfNH7A1Sqn6V/vD6 /xayUxoVeBG78/FWN3MEy5Qbbb32NLGfb/6KxwPmrMb4TOqLxbu+4LIhpbNZiJSLGaWb sz72CBsfvPmuANl9M6AG17jDg9y86G3NAs8ziA/r3WXDLwUwOCRhyzefncCRW3+urrWo CnnQ== 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=aFIaK+eTAAPYpq6IiWezj3W2oEEG8n55NOab3bVdmhOzIPl1Ec60nn2jcefN+XV3tF 73XqACXmzU2bmtaXuFHfHgXVUPRNsxZnp5GgnSF7GD6wDj2+IEshvgq/3qLyX9YjLQAv eE2t9aw4Fs2ZU47AZpwA6ucMvUJ38lKHOiZ9tDe8Oq57Q51GRLdj9iNhU/Kddq+5Rcqy 1K4sEJFN66UBbUcVMfNcuJEF0vdEa0ZnqYLMkXcSDo9+SyVfHDg5V38RP0vo07TA68I+ U6QmnN2NA9UnEHlyPyNObDsaTvXGu2zCtzFZtb/7FhrqrWRRBzEJwMPxXSw08XNMmx+O emVg== X-Gm-Message-State: AOAM531MLot5fZ3sBjIKtaZ09h+N83Y49+4Ds+49O0PnABVr2yL63bD+ mW0FXDq48di1pHPWXIquhny9Yclz5cau5A== X-Google-Smtp-Source: ABdhPJw1cLLJ/PRgXz8Hzd2Lvr+nMIklXUWA7f+HOBXbh3dzLy647wSxoe57wUKd9mPnVHbmzeAh4A== X-Received: by 2002:a17:90a:d596:: with SMTP id v22mr10723297pju.87.1642982723439; Sun, 23 Jan 2022 16:05:23 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id ck21sm10935350pjb.51.2022.01.23.16.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 16:05:22 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Anatoly Burakov , Jerin Jacob , Sunil Kumar Kori , Bruce Richardson Subject: [PATCH 02/82] eal: remove unnecessary NULL checks Date: Sun, 23 Jan 2022 16:03:58 -0800 Message-Id: <20220124000518.319850-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220124000518.319850-1-stephen@networkplumber.org> References: <20220124000518.319850-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