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 D2CB1425A3; Fri, 15 Sep 2023 11:16:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 962F340A87; Fri, 15 Sep 2023 11:16:22 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2119.outbound.protection.outlook.com [40.107.93.119]) by mails.dpdk.org (Postfix) with ESMTP id B1DF04029E for ; Fri, 15 Sep 2023 11:16:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mWM13fJjz0wltDfxqJXVsXEinQetgjo8BTRRGIPN2t2fe7C2h+1vDPyNcg9NpHsUTMOwPtueRjdvbt28JhuOJPPJGPVPiFlnmxgFHWyCyeCmn0svXpG/eZCnFo0Q38hBrv7vdxek9qgKuLAwQQ6klCUF7soVNLCeOxH5wZol5ivRdvWgzB0fzlaF0jDotmhSFQRZF6piPcPrMKJv4IQyJEm+GUZyExwSN/g9yIL6jxDRcZDlsusn46PRea+h1v/lnGQ5kbLEtlanFEHhR1iJutWwvsF6YjX0sqE8zy3YdRDp7Df7m6DJxqigxRJA4r3aoRtA9/3HFD0wFAVhe2phMQ== 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=yGaBDLXLsScAe1BM2Dm8AbsKvcbb2qkcATEB9A50j4A=; b=L0/0pTIl6NOkDBEpBfhO9qjGQSK7Bnc1vi5U7/7Hlgg2RJkiFjy0yyDEUqa/VBU/Af4UnBSZcVrHkqSqVUcBF6QXkSupcObxAGA4kMzO34RvSEstbbaVd0bh0LP/b+95QPTQMOaQduCI3AnkZhmekhLC7vEKjPC2h+5do9F5LhcacuEy4EurFr8TQIS5muo5lDxoTo4zOOxfOQlrTVmI0GdeoL/WB+Z9k0BOY2tKnRfFtyal0RYV54/7zFqPj/7W6EFEFsT1FHLOPO5AWBZ43mhvoZJ8RTxzH9PFtpRKIQkPaeZCP6vdAemEFwUlsB0HbyNnHNFsSHDGaZzxcNr16Q== 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=yGaBDLXLsScAe1BM2Dm8AbsKvcbb2qkcATEB9A50j4A=; b=WmKQb3c+f0KAcFu7qzxRIuaUNUUuormmYtwFg0qxd7kmh8GLxC/0fdGrk4sDDIVM8NUdfHE/qLf8vEFeX5QrmY+ANEA0vQIlLFPm2wgjYHkeOXvNLUqSJipPrRMdck3KPcOzoPuDmpJ9CbJw885sksU6AxqBQcDA0FBLO8k0AFk= 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 DM6PR13MB3625.namprd13.prod.outlook.com (2603:10b6:5:241::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.21; Fri, 15 Sep 2023 09:16:17 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::c05c:6915:1628:70c4]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::c05c:6915:1628:70c4%7]) with mapi id 15.20.6768.029; Fri, 15 Sep 2023 09:16:16 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH v3 01/27] net/nfp: explicitly compare to null and 0 Date: Fri, 15 Sep 2023 17:15:25 +0800 Message-Id: <20230915091551.1459606-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230915091551.1459606-1-chaoyong.he@corigine.com> References: <20230830021457.2064750-1-chaoyong.he@corigine.com> <20230915091551.1459606-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PH7PR10CA0017.namprd10.prod.outlook.com (2603:10b6:510:23d::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_|DM6PR13MB3625:EE_ X-MS-Office365-Filtering-Correlation-Id: be448c26-c786-4483-77e2-08dbb5cc6a6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mw79O9xTVhcJn9JEQMlWWC7b5x0ui5oAPspZCy65XuFkYZUumiMWH44sPz9z3RzJv/mVQXDJITm5a/AXa0iwAx45712uvyofoEoLjP07O0Fq/QXTM0UB8DgIn7A6WLOqRtuBqOga3EUX722O9657efSg/rGujgf/bePPMgobvltqXfCBV/N1jRlaqXJ64j9rNNCNM+9Xd0/nt3/+LaTkaqAbuNolgYvvL3Q0i3sJHSYHVttj2EEKAqW0/RcaK6db6/NpERxrUdv/brjIftCfEi+MZIZrxOi+XkMIfRHsHX0SVl2x1j+kr4MBqdnG0imMvHpuNL8u6yC2qYW+TAnS/N7p/1PiX5D39ZMC3J+tMI0pOD+KjXMDMBXu1LbwVtSM7CAo28YH/oJxs7WlnxR5LQQljxUjbhgWyD6bRaqSvoSjEFrYDTvZEkE/4voSBFPKGe8UaaTcB1QH22ZlfuklBepv/LcEead7tyb9ruuKwIgxVD6fVIJSIYHOv+L4I+uSJOqGytdZEdugrRVVocXlKG4tgPXj8qZafvePbkTgqwPAK0j0VfwruCIKusdlby2a9+d1nitZ4KHA6/M/Qvk/bFLV0ZV2MBmzM3hDepJxXX0slXd5iJvewMpSUxQjcxfJFL1dg1xBVb9xaF4yx3npMJ9lV6qLTsO8AgK3ZMUpqbE= 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)(39830400003)(346002)(376002)(396003)(366004)(136003)(186009)(1800799009)(451199024)(2906002)(86362001)(6512007)(52116002)(107886003)(2616005)(26005)(1076003)(478600001)(36756003)(6666004)(6506007)(6486002)(38350700002)(38100700002)(83380400001)(66574015)(5660300002)(8676002)(8936002)(4326008)(41300700001)(66946007)(66476007)(66556008)(6916009)(316002)(44832011)(54906003)(30864003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VGwrd3dwdWxEZ1I5dVNVb1ZDcTk3Tk5NeGZuQXlYVWFvZ2NYUXFaUEl0QVBP?= =?utf-8?B?dm8wTXlxTW52OHM5U2tBOEhXOEMvMW1XNklqS2lBbnNkclkyblRlRWRCU0l6?= =?utf-8?B?RDMxaU9BSFZqelhuNDNwQmhnMkdoL29oY0VPblFaUTBSejNDQ04xSCtBSlBN?= =?utf-8?B?Vlo2RVVWMUZ5YUlSQVlqMUlRdXBJdFI3eU1NT3g5M2tGUXNvUGdLR0hrbmNW?= =?utf-8?B?UGpZZGxHcFBac2lQUHFoNW8rVlBUc1NzOW1EQnhxVjZkLzdnWnNnUXc5NFRF?= =?utf-8?B?OUY3MnVvSk1qbDM3LzJDcE1rQmxpVWJoVjRNTDU5VFlVRWxYRnhIVlh1bmVh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f-8?B?NGFQemRETE96dVNBTEtWeUVvdU9DcXlucFlmbWJVMHMyNkNnUHFxMVc0YjRG?= =?utf-8?B?NWc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: be448c26-c786-4483-77e2-08dbb5cc6a6c X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 09:16:16.9430 (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: P79+Lvh/neIhnGFd/NUxPOsVYYopkLNb1OW9/A1EnbtvjToC9gdaVwCR1SQ/fNWSITLRyU+J1Oetf4ufOQKdkZphhIpI/xaRiBNaMQXGkNw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB3625 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 | 16 ++++++++-------- 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, 43 insertions(+), 43 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..31338e0047 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); @@ -833,7 +833,7 @@ __nfp_cpp_model_autodetect(struct nfp_cpp *cpp, uint32_t *model) return err; *model = reg & NFP_PL_DEVICE_MODEL_MASK; - if (*model & NFP_PL_DEVICE_ID_MASK) + if ((*model & NFP_PL_DEVICE_ID_MASK) != 0) *model -= 0x10; return 0; 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