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 0828D430EF; Thu, 24 Aug 2023 13:10:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 207BD42B8B; Thu, 24 Aug 2023 13:10:53 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2139.outbound.protection.outlook.com [40.107.220.139]) by mails.dpdk.org (Postfix) with ESMTP id 727A540EE1 for ; Thu, 24 Aug 2023 13:10:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VAcRxgwaLFV9UvQMQ5Qp+5cOuM1lE2bME3LMSoSndtbTNLVeJRtAWJ4nizIoMzcGLWW/6i4fcTmPbKOklYDU6q8ZlWUsgeX+lSNjCpT3IjPbTgOLTe2pqclvfONwU9aq0l1Detyvu0JKZuH2UofVclNPCtWathvAAKe1dtOUSnlScm/O+HUgkFjl69fFTYUKIvsyrPPnZ5B+A9M9Q6TiErIJapg3na9d4brajrsk+PYRQVmKWdLwIvT8K/h1WqD6OCLyQMPVrrskckYyA0eCbe3NVfT4MtrLJcX2M5Eb1TRs5B7/tVdXVa1x1FAKCdOQ5g+UBZaTWlV9kgqvN0K29A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zvWl+qB/SZ+zUqQiGVDXk+Ykk5k2dt7/jLdrYqZJTis=; b=T++idyb/nOfBrs3tA3itSLr+vqlw1+LX5xhBef40KltMxiyoJDu1Amhd9dYID1vf127GzaVqt3qq6qNcZBXEEwxz6fw6SWlpKRP7H0Orpt0wh71/0QTZ08PfOiG/ysejtTZZFNZg0HVzQBZ9PI5V//VwPO/GKRB+sPNvOD8O+5JX2Bw2r9oqYyUqbDnjXXyxG4Z5ilK4eBAEtuZPMvzLYM23ll0kFFzcgo+mcxvuUeSLV8ztSbH4zjuPEmcTr3umFGPhS8SYbdNdZF226P1rN3HM9fHJJmWbGqJiCwhfhmMRrPIRql0gKfcnUrQ9jvRYuHAjMNnyb+OD/nmonOhszQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zvWl+qB/SZ+zUqQiGVDXk+Ykk5k2dt7/jLdrYqZJTis=; b=pSTeSqz/kObqNvdFKnWNIXvv5/qMnch0vg/7FtmlaYNYHYVpY802GDBllAKiGuua0yzA9O0ojIOINZ02QOnxKRTmd9I6Cr9I7VHsA7GNwsuAzWVMjtNnt+zPb9phfA9j4TMmGuN7ywI5t/aaeEkohH7/Tn6FBrEHaeT8AO42NvA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by PH0PR13MB6134.namprd13.prod.outlook.com (2603:10b6:510:295::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.26; Thu, 24 Aug 2023 11:10:47 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::51fe:5846:af8b:bace]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::51fe:5846:af8b:bace%3]) with mapi id 15.20.6699.020; Thu, 24 Aug 2023 11:10:47 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 01/27] net/nfp: explicitly compare to null and 0 Date: Thu, 24 Aug 2023 19:09:30 +0800 Message-Id: <20230824110956.1943559-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230824110956.1943559-1-chaoyong.he@corigine.com> References: <20230824110956.1943559-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SJ0PR05CA0005.namprd05.prod.outlook.com (2603:10b6:a03:33b::10) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH0PR13MB6134:EE_ X-MS-Office365-Filtering-Correlation-Id: 78f0a323-eea5-43d2-1489-08dba492c49c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 35uf8hmtN2+yBULEO27y4C5N0CwW4oteI7NpQXQgTL67UskOXp7hp1Qa08L8x/e6NX1NAxTwSNxDItT1psRPhaGj1eUkVVVHCisoQyNcEokI0D2v+pRtmu00n35G37p8nRFJtgFPZkHvNtP9zWqnQIQn5HMFOUfh/LkOR6hLXcjN/y+bod3tyjNFj6PDc7T+r8JFclc2BntYHV/Ja1E1YrmDAYEjvYcpSnG8HjtoZUKgzL9p/XB4zQe8VzuSV6+kIaUd1TfYjhPQLukW5eZq/S0l1xW8rMkHA36Cq7VVDw1/KtcEip8uy3jm9dDxsyNKrjmNw7scZAqvXjHDutLKiFn60a6lyBkyPwIhQpToRB0o6YAUu8zuR3wZrnHT3H+TpWX2f99jIRSybZtwwbIB0JKjDqfafEys7L8Qs9kiX+exL/Jj9bkbgRUKniw+RlDlTrPHJnSKV2RjWlBUP7ZKnc2XEa5UdE114HCQ90M8WFSOfPIuPkhBV5CPGbDq1caOKnv50yugysPfMiq4W08prth0Fg/OdEnweRzPuEOFhezEuoCHB4O2p5W6agDvsLEA9MWGOZcWNbfnUAVm419tOJJlVlMdSOc4RXELJtnf04iS/0+oYTny7RRA4CM8CxDuzE5wXmRxMdiI+aLtKCXyDhSSv0k1+o0YMicwx2aRRLfKrxg+UtJmxPKyzYyqTGX6P/Tv8DEVy4h/sarVsXgTvg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(396003)(366004)(136003)(376002)(39830400003)(1800799009)(451199024)(186009)(316002)(66556008)(6916009)(66946007)(66476007)(12101799020)(41300700001)(44832011)(5660300002)(8936002)(8676002)(38100700002)(66574015)(38350700002)(4326008)(30864003)(2906002)(83380400001)(26005)(86362001)(478600001)(107886003)(52116002)(36756003)(6506007)(6666004)(6512007)(6486002)(2616005)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZUVyb1pyTnVDMU5LcWxKbTh3aG13cEtkeVdZbXJ6dm02eDdUVzJkeDRUYVRJ?= =?utf-8?B?UnI2QkVpK2ZBbUFrYUt5cHAyb0VZamZUanhnZTg0b2FhRmVRRFlRVWF1bjhv?= =?utf-8?B?T1ExZDNmRHhjeHNqK1htdkpYdUtkSFFCMDdHbHJHelFmVkJnczRjODR6WHlH?= =?utf-8?B?cnpudGo3akRERzgvWmpVeUwyRGNUVmVmc3VXK3VKL08wN2drUVlmWkRZYUpW?= =?utf-8?B?anQwTmVMMlFCdnkyV1FLMFZFaXNUcW5yMjBScXdTUVpaUGxSdWFVc2J4UTl4?= =?utf-8?B?QXVEeVZLTDJ4bEp3VTJQQTVqVUpNb0Rxb2o1R3VMRjB3ZWVLcGtpd3NjS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F1d2FHV2ZwWFd6ejU1bGFLeVBHVHlFVE5H?= =?utf-8?B?ZFE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78f0a323-eea5-43d2-1489-08dba492c49c X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 11:10:47.7358 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4+DRGv2jouNK6ISrTVjhq8/fwmXd29VDmseitMIrOweh6qhhUo0epvJxhK8E5XWEzMHpaIkQj1P5UNDYycsQMHzq8lMR6P2jefQejsgwnVE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6134 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 To compliance with the coding standard, make the pointer variable explicitly comparing to 'NULL' and the integer variable explicitly comparing to '0'. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 12 ++++++------ drivers/net/nfp/nfpcore/nfp_cppcore.c | 14 +++++++------- drivers/net/nfp/nfpcore/nfp_hwinfo.c | 8 ++++---- drivers/net/nfp/nfpcore/nfp_mip.c | 4 ++-- drivers/net/nfp/nfpcore/nfp_mutex.c | 2 +- drivers/net/nfp/nfpcore/nfp_nffw.c | 4 ++-- drivers/net/nfp/nfpcore/nfp_nsp.c | 20 ++++++++++---------- drivers/net/nfp/nfpcore/nfp_nsp_eth.c | 10 +++++----- drivers/net/nfp/nfpcore/nfp_resource.c | 6 +++--- drivers/net/nfp/nfpcore/nfp_rtsym.c | 4 ++-- 10 files changed, 42 insertions(+), 42 deletions(-) diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c index 658c618ee6..2ee60eefc3 100644 --- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c @@ -224,10 +224,10 @@ nfp_compute_bar(const struct nfp_bar *bar, uint32_t *bar_config, newcfg |= offset >> bitsize; - if (bar_base) + if (bar_base != NULL) *bar_base = offset; - if (bar_config) + if (bar_config != NULL) *bar_config = newcfg; return 0; @@ -266,7 +266,7 @@ nfp_reconfigure_bar(struct nfp_pcie_user *nfp, struct nfp_bar *bar, int tgt, err = nfp_compute_bar(bar, &newcfg, &newbase, tgt, act, tok, offset, size, width); - if (err) + if (err != 0) return err; bar->base = newbase; @@ -515,7 +515,7 @@ nfp6000_area_read(struct nfp_cpp_area *area, void *kernel_vaddr, return -EINVAL; /* Unaligned? Translate to an explicit access */ - if ((priv->offset + offset) & (width - 1)) { + if (((priv->offset + offset) & (width - 1)) != 0) { PMD_DRV_LOG(ERR, "aread_read unaligned!!!"); return -EINVAL; } @@ -583,7 +583,7 @@ nfp6000_area_write(struct nfp_cpp_area *area, const void *kernel_vaddr, return -EINVAL; /* Unaligned? Translate to an explicit access */ - if ((priv->offset + offset) & (width - 1)) + if (((priv->offset + offset) & (width - 1)) != 0) return -EINVAL; is_64 = width == TARGET_WIDTH_64; @@ -764,7 +764,7 @@ nfp6000_init(struct nfp_cpp *cpp, struct rte_pci_device *dev) if (rte_eal_process_type() == RTE_PROC_PRIMARY && cpp->driver_lock_needed) { ret = nfp_acquire_process_lock(desc); - if (ret) + if (ret != 0) goto error; } diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c index 6daee313ce..2c6ec3e126 100644 --- a/drivers/net/nfp/nfpcore/nfp_cppcore.c +++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c @@ -235,7 +235,7 @@ nfp_cpp_area_alloc_acquire(struct nfp_cpp *cpp, uint32_t destination, if (area == NULL) return NULL; - if (nfp_cpp_area_acquire(area)) { + if (nfp_cpp_area_acquire(area) != 0) { nfp_cpp_area_free(area); return NULL; } @@ -252,7 +252,7 @@ nfp_cpp_area_alloc_acquire(struct nfp_cpp *cpp, uint32_t destination, void nfp_cpp_area_free(struct nfp_cpp_area *area) { - if (area->cpp->op->area_cleanup) + if (area->cpp->op->area_cleanup != NULL) area->cpp->op->area_cleanup(area); free(area); } @@ -280,7 +280,7 @@ nfp_cpp_area_release_free(struct nfp_cpp_area *area) int nfp_cpp_area_acquire(struct nfp_cpp_area *area) { - if (area->cpp->op->area_acquire) { + if (area->cpp->op->area_acquire != NULL) { int err = area->cpp->op->area_acquire(area); if (err < 0) @@ -299,7 +299,7 @@ nfp_cpp_area_acquire(struct nfp_cpp_area *area) void nfp_cpp_area_release(struct nfp_cpp_area *area) { - if (area->cpp->op->area_release) + if (area->cpp->op->area_release != NULL) area->cpp->op->area_release(area); } @@ -319,7 +319,7 @@ nfp_cpp_area_iomem(struct nfp_cpp_area *area) { void *iomem = NULL; - if (area->cpp->op->area_iomem) + if (area->cpp->op->area_iomem != NULL) iomem = area->cpp->op->area_iomem(area); return iomem; @@ -621,10 +621,10 @@ nfp_cpp_alloc(struct rte_pci_device *dev, int driver_lock_needed) void nfp_cpp_free(struct nfp_cpp *cpp) { - if (cpp->op && cpp->op->free) + if (cpp->op != NULL && cpp->op->free != NULL) cpp->op->free(cpp); - if (cpp->serial_len) + if (cpp->serial_len != 0) free(cpp->serial); free(cpp); diff --git a/drivers/net/nfp/nfpcore/nfp_hwinfo.c b/drivers/net/nfp/nfpcore/nfp_hwinfo.c index 9054bb0315..a9d166c4dc 100644 --- a/drivers/net/nfp/nfpcore/nfp_hwinfo.c +++ b/drivers/net/nfp/nfpcore/nfp_hwinfo.c @@ -37,7 +37,7 @@ nfp_hwinfo_db_walk(struct nfp_hwinfo *hwinfo, uint32_t size) { const char *key, *val, *end = hwinfo->data + size; - for (key = hwinfo->data; *key && key < end; + for (key = hwinfo->data; *key != 0 && key < end; key = val + strlen(val) + 1) { val = key + strlen(key) + 1; if (val >= end) { @@ -141,7 +141,7 @@ nfp_hwinfo_fetch(struct nfp_cpp *cpp, size_t *hwdb_size) for (;;) { db = nfp_hwinfo_try_fetch(cpp, hwdb_size); - if (db) + if (db != NULL) return db; nanosleep(&wait, NULL); @@ -164,7 +164,7 @@ nfp_hwinfo_read(struct nfp_cpp *cpp) return NULL; err = nfp_hwinfo_db_validate(db, hwdb_size); - if (err) { + if (err != 0) { free(db); return NULL; } @@ -188,7 +188,7 @@ nfp_hwinfo_lookup(struct nfp_hwinfo *hwinfo, const char *lookup) end = hwinfo->data + hwinfo->size - sizeof(uint32_t); - for (key = hwinfo->data; *key && key < end; + for (key = hwinfo->data; *key != 0 && key < end; key = val + strlen(val) + 1) { val = key + strlen(key) + 1; diff --git a/drivers/net/nfp/nfpcore/nfp_mip.c b/drivers/net/nfp/nfpcore/nfp_mip.c index 6b392ad5eb..f9723dd136 100644 --- a/drivers/net/nfp/nfpcore/nfp_mip.c +++ b/drivers/net/nfp/nfpcore/nfp_mip.c @@ -75,7 +75,7 @@ nfp_mip_read_resource(struct nfp_cpp *cpp, struct nfp_mip *mip) return -ENODEV; err = nfp_nffw_info_mip_first(nffw_info, &cpp_id, &addr); - if (err) + if (err != 0) goto exit_close_nffw; err = nfp_mip_try_read(cpp, cpp_id, addr, mip); @@ -105,7 +105,7 @@ nfp_mip_open(struct nfp_cpp *cpp) return NULL; err = nfp_mip_read_resource(cpp, mip); - if (err) { + if (err != 0) { free(mip); return NULL; } diff --git a/drivers/net/nfp/nfpcore/nfp_mutex.c b/drivers/net/nfp/nfpcore/nfp_mutex.c index f967a29351..0410a00856 100644 --- a/drivers/net/nfp/nfpcore/nfp_mutex.c +++ b/drivers/net/nfp/nfpcore/nfp_mutex.c @@ -38,7 +38,7 @@ static int _nfp_cpp_mutex_validate(uint32_t model, int *target, unsigned long long address) { /* Address must be 64-bit aligned */ - if (address & 7) + if ((address & 7) != 0) return -EINVAL; if (NFP_CPP_MODEL_IS_6000(model)) { diff --git a/drivers/net/nfp/nfpcore/nfp_nffw.c b/drivers/net/nfp/nfpcore/nfp_nffw.c index 07d63900dc..433780a5e7 100644 --- a/drivers/net/nfp/nfpcore/nfp_nffw.c +++ b/drivers/net/nfp/nfpcore/nfp_nffw.c @@ -190,7 +190,7 @@ nfp_nffw_info_fwid_first(struct nfp_nffw_info *state) return NULL; for (i = 0; i < cnt; i++) - if (nffw_fwinfo_loaded_get(&fwinfo[i])) + if (nffw_fwinfo_loaded_get(&fwinfo[i]) != 0) return &fwinfo[i]; return NULL; @@ -217,7 +217,7 @@ nfp_nffw_info_mip_first(struct nfp_nffw_info *state, uint32_t *cpp_id, *cpp_id = nffw_fwinfo_mip_cppid_get(fwinfo); *off = nffw_fwinfo_mip_offset_get(fwinfo); - if (nffw_fwinfo_mip_mu_da_get(fwinfo)) { + if (nffw_fwinfo_mip_mu_da_get(fwinfo) != 0) { int locality_off; if (NFP_CPP_ID_TARGET_of(*cpp_id) != NFP_CPP_TARGET_MU) diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c index 1f6b7bd85c..6474abf0c2 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp.c +++ b/drivers/net/nfp/nfpcore/nfp_nsp.c @@ -95,7 +95,7 @@ nfp_nsp_check(struct nfp_nsp *state) return -EINVAL; } - if (reg & NSP_STATUS_BUSY) { + if ((reg & NSP_STATUS_BUSY) != 0) { PMD_DRV_LOG(ERR, "Service processor busy!"); return -EBUSY; } @@ -128,7 +128,7 @@ nfp_nsp_open(struct nfp_cpp *cpp) state->res = res; err = nfp_nsp_check(state); - if (err) { + if (err != 0) { nfp_nsp_close(state); return NULL; } @@ -219,7 +219,7 @@ nfp_nsp_command(struct nfp_nsp *state, uint16_t code, uint32_t option, nsp_buffer = nsp_base + NSP_BUFFER; err = nfp_nsp_check(state); - if (err) + if (err != 0) return err; if (!FIELD_FIT(NSP_BUFFER_CPP, buff_cpp >> 8) || @@ -245,7 +245,7 @@ nfp_nsp_command(struct nfp_nsp *state, uint16_t code, uint32_t option, /* Wait for NSP_COMMAND_START to go to 0 */ err = nfp_nsp_wait_reg(cpp, ®, nsp_cpp, nsp_command, NSP_COMMAND_START, 0); - if (err) { + if (err != 0) { PMD_DRV_LOG(ERR, "Error %d waiting for code 0x%04x to start", err, code); return err; @@ -254,7 +254,7 @@ nfp_nsp_command(struct nfp_nsp *state, uint16_t code, uint32_t option, /* Wait for NSP_STATUS_BUSY to go to 0 */ err = nfp_nsp_wait_reg(cpp, ®, nsp_cpp, nsp_status, NSP_STATUS_BUSY, 0); - if (err) { + if (err != 0) { PMD_DRV_LOG(ERR, "Error %d waiting for code 0x%04x to start", err, code); return err; @@ -266,7 +266,7 @@ nfp_nsp_command(struct nfp_nsp *state, uint16_t code, uint32_t option, ret_val = FIELD_GET(NSP_COMMAND_OPTION, ret_val); err = FIELD_GET(NSP_STATUS_RESULT, reg); - if (err) { + if (err != 0) { PMD_DRV_LOG(ERR, "Result (error) code set: %d (%d) command: %d", -err, (int)ret_val, code); nfp_nsp_print_extended_error(ret_val); @@ -319,13 +319,13 @@ nfp_nsp_command_buf(struct nfp_nsp *nsp, uint16_t code, uint32_t option, cpp_id = FIELD_GET(NSP_BUFFER_CPP, reg) << 8; cpp_buf = FIELD_GET(NSP_BUFFER_ADDRESS, reg); - if (in_buf && in_size) { + if (in_buf != NULL && in_size > 0) { err = nfp_cpp_write(cpp, cpp_id, cpp_buf, in_buf, in_size); if (err < 0) return err; } /* Zero out remaining part of the buffer */ - if (out_buf && out_size && out_size > in_size) { + if (out_buf != NULL && out_size > 0 && out_size > in_size) { memset(out_buf, 0, out_size - in_size); err = nfp_cpp_write(cpp, cpp_id, cpp_buf + in_size, out_buf, out_size - in_size); @@ -337,7 +337,7 @@ nfp_nsp_command_buf(struct nfp_nsp *nsp, uint16_t code, uint32_t option, if (ret < 0) return ret; - if (out_buf && out_size) { + if (out_buf != NULL && out_size > 0) { err = nfp_cpp_read(cpp, cpp_id, cpp_buf, out_buf, out_size); if (err < 0) return err; @@ -369,7 +369,7 @@ nfp_nsp_wait(struct nfp_nsp *state) break; } } - if (err) + if (err != 0) PMD_DRV_LOG(ERR, "NSP failed to respond %d", err); return err; diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c index 01b4652280..825a84a8cd 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c +++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c @@ -212,7 +212,7 @@ nfp_eth_port_translate(struct nfp_nsp *nsp, const union eth_table_entry *src, dst->fec_modes_supported |= fec << NFP_FEC_BASER_BIT; fec = FIELD_GET(NSP_ETH_PORT_FEC_SUPP_RS, port); dst->fec_modes_supported |= fec << NFP_FEC_REED_SOLOMON_BIT; - if (dst->fec_modes_supported) + if (dst->fec_modes_supported != 0) dst->fec_modes_supported |= NFP_FEC_AUTO | NFP_FEC_DISABLED; dst->fec = 1 << FIELD_GET(NSP_ETH_STATE_FEC, state); @@ -285,7 +285,7 @@ __nfp_eth_read_ports(struct nfp_nsp *nsp) */ for (i = 0; i < NSP_ETH_MAX_COUNT; i++) { mac = (const struct rte_ether_addr *)entries[i].mac_addr; - if ((entries[i].port & NSP_ETH_PORT_LANES_MASK) && + if ((entries[i].port & NSP_ETH_PORT_LANES_MASK) != 0 && !rte_is_zero_ether_addr(mac)) cnt++; } @@ -294,7 +294,7 @@ __nfp_eth_read_ports(struct nfp_nsp *nsp) * those that give a port count, verify it against the value calculated * above. */ - if (ret && ret != cnt) { + if (ret != 0 && ret != cnt) { PMD_DRV_LOG(ERR, "table entry count (%d) unmatch entries present (%d)", ret, cnt); goto err; @@ -309,7 +309,7 @@ __nfp_eth_read_ports(struct nfp_nsp *nsp) table->count = cnt; for (i = 0, j = 0; i < NSP_ETH_MAX_COUNT; i++) { mac = (const struct rte_ether_addr *)entries[i].mac_addr; - if ((entries[i].port & NSP_ETH_PORT_LANES_MASK) && + if ((entries[i].port & NSP_ETH_PORT_LANES_MASK) != 0 && !rte_is_zero_ether_addr(mac)) nfp_eth_port_translate(nsp, &entries[i], i, &table->ports[j++]); @@ -621,7 +621,7 @@ nfp_eth_set_fec(struct nfp_cpp *cpp, unsigned int idx, enum nfp_eth_fec mode) return -EIO; err = __nfp_eth_set_fec(nsp, mode); - if (err) { + if (err != 0) { nfp_eth_config_cleanup_end(nsp); return err; } diff --git a/drivers/net/nfp/nfpcore/nfp_resource.c b/drivers/net/nfp/nfpcore/nfp_resource.c index 351bc623ed..838cd6e0ef 100644 --- a/drivers/net/nfp/nfpcore/nfp_resource.c +++ b/drivers/net/nfp/nfpcore/nfp_resource.c @@ -115,15 +115,15 @@ nfp_resource_try_acquire(struct nfp_cpp *cpp, struct nfp_resource *res, { int err; - if (nfp_cpp_mutex_lock(dev_mutex)) + if (nfp_cpp_mutex_lock(dev_mutex) != 0) return -EINVAL; err = nfp_cpp_resource_find(cpp, res); - if (err) + if (err != 0) goto err_unlock_dev; err = nfp_cpp_mutex_trylock(res->mutex); - if (err) + if (err != 0) goto err_res_mutex_free; nfp_cpp_mutex_unlock(dev_mutex); diff --git a/drivers/net/nfp/nfpcore/nfp_rtsym.c b/drivers/net/nfp/nfpcore/nfp_rtsym.c index 343b0d0bcf..4c45aec5c1 100644 --- a/drivers/net/nfp/nfpcore/nfp_rtsym.c +++ b/drivers/net/nfp/nfpcore/nfp_rtsym.c @@ -362,10 +362,10 @@ nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name, int *error) if (err) err = -EIO; exit: - if (error) + if (error != NULL) *error = err; - if (err) + if (err != 0) return ~0ULL; return val; -- 2.39.1