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 75DACA034E; Wed, 9 Feb 2022 20:19:09 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B5E26411B2; Wed, 9 Feb 2022 20:18:07 +0100 (CET) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTP id C49DF411E1 for ; Wed, 9 Feb 2022 20:18:04 +0100 (CET) Received: by mail-pf1-f172.google.com with SMTP id y8so3245716pfa.11 for ; Wed, 09 Feb 2022 11:18:04 -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=6od5cKMQGFeVbk1AWsKTGhIHPEDLeF1CnY0hZNL23Xk=; b=0JASQjtMfymcraBowUidDSlq1D8PazKiCuejaWbopMz5DbUMioaMK5sw+IOPKkldMT 1qfpV8OUQJILHGaLOYoQsbAKbrm7eFKhmZ1KpH8v8iBWRi/N9g5xrk/9/9vaX7Ic79Rw 05hlyS3fApyn8sL082uwUhZJjcM8ZSa9/9xgpKEvyugs5xqyMzAX316wqKY8hkj6BxWI kTQ+tvOR3MIPeDA+QTFgJFyuoM5SQcyvuDtkevqbuxDusfXWDNT0LFS5z2l5pAiN/9eM fDUDb/3LONXeqCebOTTLh+qpb55hfiMHoVuv25mvxQjH+DfB55OTlVoBcMz6YNra6/Ab +WyA== 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=6od5cKMQGFeVbk1AWsKTGhIHPEDLeF1CnY0hZNL23Xk=; b=Hjlu4I5gV6GpcCgp/13CgEGPWPVGsWJ4SnQaI5CurKnGgJQetsw/trnLty/ApFxkb1 rHwt1AtEE4A5nqguoH3gQfzIXxJkwyIt4u40EHWOM5e4+z9canndGB1xBTsGIOcHP1K0 fmm9qe+3njcYoNv1Xi3sjfRXH031or/NCHn9YupJY2n+zEVjWvUKnpMC8dmhQBJbwr6y jiIxPV6mGjnchM/4KFzSa+sX47MN2+eFIAYTUA0BWB0YzYPRQp5nHZ9POicn1bk1SkfZ wbBoxdbm8SowJC/3DUjNTtpKVlu9dshYmpbRum/9q19YKHZvDybv3Szpizt5kzkDIahk avfA== X-Gm-Message-State: AOAM530q32BxVdjqB1h8DvrYf9NfHzW1lC3Yi7eVLqKODrp2JGCXBy/s wHVDSzrV+KpjQuzSFPmHvzm1igMIVggN7tXF X-Google-Smtp-Source: ABdhPJwCIfyXxt9tMAEZK1sVTtQlnr7662XeMVJ9caMMW2IHW0GVu7pV2gk5hJWdjWi1Lo1ubXLhSg== X-Received: by 2002:a63:6882:: with SMTP id d124mr3077247pgc.305.1644434283751; Wed, 09 Feb 2022 11:18:03 -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.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 11:18:03 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Anoob Joseph , Hemant Agrawal , Sachin Saxena , Matan Azrad , Viacheslav Ovsiienko , John Griffin , Fiona Trahe , Deepak Kumar Jain Subject: [PATCH v3 10/36] common/*: remove unnecessary NULL checks Date: Wed, 9 Feb 2022 11:17:22 -0800 Message-Id: <20220209191748.377729-11-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 Remove redundant NULL pointer checks before free functions found by nullfree.cocci Signed-off-by: Stephen Hemminger --- drivers/common/cpt/cpt_ucode_asym.h | 6 ++---- drivers/common/dpaax/compat.h | 11 ++--------- drivers/common/mlx5/mlx5_common_mr.c | 3 +-- drivers/common/mlx5/mlx5_common_pci.c | 3 +-- drivers/common/qat/qat_qp.c | 9 +++------ 5 files changed, 9 insertions(+), 23 deletions(-) diff --git a/drivers/common/cpt/cpt_ucode_asym.h b/drivers/common/cpt/cpt_ucode_asym.h index f0b5dddd8cdf..f5d91f2583bd 100644 --- a/drivers/common/cpt/cpt_ucode_asym.h +++ b/drivers/common/cpt/cpt_ucode_asym.h @@ -192,13 +192,11 @@ cpt_free_asym_session_parameters(struct cpt_asym_sess_misc *sess) switch (sess->xfrm_type) { case RTE_CRYPTO_ASYM_XFORM_RSA: rsa = &sess->rsa_ctx; - if (rsa->n.data) - rte_free(rsa->n.data); + rte_free(rsa->n.data); break; case RTE_CRYPTO_ASYM_XFORM_MODEX: mod = &sess->mod_ctx; - if (mod->modulus.data) - rte_free(mod->modulus.data); + rte_free(mod->modulus.data); break; case RTE_CRYPTO_ASYM_XFORM_ECDSA: /* Fall through */ diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h index 7166f8cceb41..cbabc1588b21 100644 --- a/drivers/common/dpaax/compat.h +++ b/drivers/common/dpaax/compat.h @@ -339,16 +339,9 @@ static inline void copy_bytes(void *dest, const void *src, size_t sz) /* Allocator stuff */ #define kmalloc(sz, t) rte_malloc(NULL, sz, 0) +#define kzalloc(sz, t) rte_zmalloc(NULL, sz, 0) #define vmalloc(sz) rte_malloc(NULL, sz, 0) -#define kfree(p) { if (p) rte_free(p); } -static inline void *kzalloc(size_t sz, gfp_t __foo __rte_unused) -{ - void *ptr = rte_malloc(NULL, sz, 0); - - if (ptr) - memset(ptr, 0, sz); - return ptr; -} +#define kfree(p) rte_free(p) static inline unsigned long get_zeroed_page(gfp_t __foo __rte_unused) { diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c index 5f7e4f6734aa..fa27bd98de04 100644 --- a/drivers/common/mlx5/mlx5_common_mr.c +++ b/drivers/common/mlx5/mlx5_common_mr.c @@ -516,8 +516,7 @@ mlx5_mr_free(struct mlx5_mr *mr, mlx5_dereg_mr_t dereg_mr_cb) return; DRV_LOG(DEBUG, "freeing MR(%p):", (void *)mr); dereg_mr_cb(&mr->pmd_mr); - if (mr->ms_bmp != NULL) - rte_bitmap_free(mr->ms_bmp); + rte_bitmap_free(mr->ms_bmp); mlx5_free(mr); } diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c index 8b38091d8741..458630351cd1 100644 --- a/drivers/common/mlx5/mlx5_common_pci.c +++ b/drivers/common/mlx5/mlx5_common_pci.c @@ -97,8 +97,7 @@ pci_ids_table_update(const struct rte_pci_id *driver_id_table) updated_table[i].vendor_id = 0; mlx5_common_pci_driver.id_table = updated_table; mlx5_pci_id_table = updated_table; - if (old_table) - free(old_table); + free(old_table); return 0; } diff --git a/drivers/common/qat/qat_qp.c b/drivers/common/qat/qat_qp.c index cde421eb7716..57ac8fefca3d 100644 --- a/drivers/common/qat/qat_qp.c +++ b/drivers/common/qat/qat_qp.c @@ -175,11 +175,9 @@ qat_qp_setup(struct qat_pci_device *qat_dev, create_err: if (qp) { - if (qp->op_cookie_pool) - rte_mempool_free(qp->op_cookie_pool); + rte_mempool_free(qp->op_cookie_pool); - if (qp->op_cookies) - rte_free(qp->op_cookies); + rte_free(qp->op_cookies); rte_free(qp); } @@ -329,8 +327,7 @@ qat_qp_release(enum qat_device_gen qat_dev_gen, struct qat_qp **qp_addr) for (i = 0; i < qp->nb_descriptors; i++) rte_mempool_put(qp->op_cookie_pool, qp->op_cookies[i]); - if (qp->op_cookie_pool) - rte_mempool_free(qp->op_cookie_pool); + rte_mempool_free(qp->op_cookie_pool); rte_free(qp->op_cookies); rte_free(qp); -- 2.34.1