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 5BD04A034D; Thu, 6 Jan 2022 09:41:46 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7BC2341150; Thu, 6 Jan 2022 09:41:37 +0100 (CET) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mails.dpdk.org (Postfix) with ESMTP id 0A15B4014F for ; Wed, 5 Jan 2022 11:32:36 +0100 (CET) Received: by mail-wr1-f46.google.com with SMTP id s1so82021338wra.6 for ; Wed, 05 Jan 2022 02:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=07V1+tb9xarimfxfPETik1EDR+kunkjAgLwHY3nxlBg=; b=WY3dpwhZ/j86FeRVW6N8eM/ufygxmchpNjJ8zBfqAFgk4A4yn2BfYmX3RHNDBJk80p ngY2oEFLGB6BSuJA8ytekhiPemgPGknzpZEyKqNTi2Klg4nL9golofGZmkHb9bT3fDyB j3DMnF6OetnOB+Fq7Q2aGY0RcdmwTclhOyjuAaiqA4Uds8OBveEYSrQV6Iu+3EWYSyW9 KFnfRHnuUTGnYi+bItIHTXbOvDsXppqL8iqaUWee3sEARjRoC/eoAIRsLFQ63zkOt/h5 kuL5B9WQ4CWhSJTFhkzoB37klVeURUqZN9R1FMtCjSXOHvsDqxQqUCpJGfMJvlq0lfQd 5ksg== 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=07V1+tb9xarimfxfPETik1EDR+kunkjAgLwHY3nxlBg=; b=KOTUc8/BwYIycaytaE0rwpnJ25K9a+7/tcvfPwXUHTZGxuoOAwBoliYx1XNrfUQtfq aHGJ/JI9OslMP96qrdTzwNzvzcRr/Cq6M52HRCC5rYV/X2wK90lPjHSi4WOaE0DENYYe 1wmmBzDO9Hvws5QYqTI9m0JYaOrdAJyJgJMcwNacyXlGpucqn63Jo+2ndfG5VoEMPXAw W1VaMDIP+9gGmA+BU2g3omYWxdtEoatbBTIkBqXfcEFa+8Fgc88F4/Uv0o5JImyGq04M QK9bqMNiKMto7wzXv9+20TLA0PwXhHet0tNd7mqZT6fUldBml2yG02if7bLSAGawuPnK 6Akw== X-Gm-Message-State: AOAM533uulfOa613mGOoY+8aj2/f/lXZlX5ZiTav3GYqW++4NgKNE4tr g4tUaQa8ShJJ1WXFe+Q6pIUHIxgfHmUKRyID X-Google-Smtp-Source: ABdhPJzRDmRfn8MHaBvh1JLtN5x/2QxxwfWPnoq/jBVapZnf1jxo8vXkH27ATuVjTdIrIxuckIznPw== X-Received: by 2002:a05:6000:1845:: with SMTP id c5mr45688516wri.420.1641378755818; Wed, 05 Jan 2022 02:32:35 -0800 (PST) Received: from dokken.dev.6wind.com ([185.13.181.2]) by smtp.gmail.com with ESMTPSA id j11sm1777677wmq.23.2022.01.05.02.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 02:32:35 -0800 (PST) From: Maxime Gouin To: dev@dpdk.org Cc: Maxime Gouin , Heinrich Kuhn , Alejandro Lucero , Olivier Matz Subject: [PATCH 2/2] net/nfp: remove useless range checks Date: Wed, 5 Jan 2022 11:32:03 +0100 Message-Id: <20220105103203.7166-2-maxime.gouin@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220105103203.7166-1-maxime.gouin@6wind.com> References: <20220105103203.7166-1-maxime.gouin@6wind.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Thu, 06 Jan 2022 09:41:35 +0100 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 reported by code analysis tool C++test (version 10.4): > /build/dpdk-20.11/drivers/net/nfp/nfpcore/nfp_target.h > 375 Condition "island < 1" is always evaluated to false > 415 Condition "island < 1" is always evaluated to false > 547 Condition "target < 0" is always evaluated to false All of these conditions have the same error. They call NFP_CPP_ID_ISLAND_of or NFP_CPP_ID_TARGET_of which return a uint8_t and put the result in "island" or "target" which are integers. These variables can only contain values between 0 and 255. Fixes: c7e9729da6b5 ("net/nfp: support CPP") Signed-off-by: Maxime Gouin Reviewed-by: Olivier Matz --- drivers/net/nfp/nfpcore/nfp_target.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/net/nfp/nfpcore/nfp_target.h b/drivers/net/nfp/nfpcore/nfp_target.h index 2884a0034f44..e8dcc9ad1eda 100644 --- a/drivers/net/nfp/nfpcore/nfp_target.h +++ b/drivers/net/nfp/nfpcore/nfp_target.h @@ -37,7 +37,7 @@ pushpull_width(int pp) static inline int target_rw(uint32_t cpp_id, int pp, int start, int len) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); if (island && (island < start || island > (start + len))) return NFP_ERRNO(EINVAL); @@ -117,7 +117,7 @@ nfp6000_nbi_ppc(uint32_t cpp_id) static inline int nfp6000_nbi(uint32_t cpp_id, uint64_t address) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); uint64_t rel_addr = address & 0x3fFFFF; if (island && (island < 8 || island > 9)) @@ -281,7 +281,7 @@ static inline int nfp6000_mu(uint32_t cpp_id, uint64_t address) { int pp; - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); if (island == 0) { if (address < 0x2000000000ULL) @@ -316,7 +316,7 @@ nfp6000_mu(uint32_t cpp_id, uint64_t address) static inline int nfp6000_ila(uint32_t cpp_id) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); if (island && (island < 48 || island > 51)) return NFP_ERRNO(EINVAL); @@ -336,7 +336,7 @@ nfp6000_ila(uint32_t cpp_id) static inline int nfp6000_pci(uint32_t cpp_id) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); if (island && (island < 4 || island > 7)) return NFP_ERRNO(EINVAL); @@ -354,7 +354,7 @@ nfp6000_pci(uint32_t cpp_id) static inline int nfp6000_crypto(uint32_t cpp_id) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); if (island && (island < 12 || island > 15)) return NFP_ERRNO(EINVAL); @@ -370,9 +370,9 @@ nfp6000_crypto(uint32_t cpp_id) static inline int nfp6000_cap_xpb(uint32_t cpp_id) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); - if (island && (island < 1 || island > 63)) + if (island > 63) return NFP_ERRNO(EINVAL); switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { @@ -410,9 +410,9 @@ nfp6000_cap_xpb(uint32_t cpp_id) static inline int nfp6000_cls(uint32_t cpp_id) { - int island = NFP_CPP_ID_ISLAND_of(cpp_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_id); - if (island && (island < 1 || island > 63)) + if (island > 63) return NFP_ERRNO(EINVAL); switch (cpp_id & NFP_CPP_ID(0, ~0, ~0)) { @@ -540,11 +540,11 @@ nfp_target_cpp(uint32_t cpp_island_id, uint64_t cpp_island_address, const uint32_t *imb_table) { int err; - int island = NFP_CPP_ID_ISLAND_of(cpp_island_id); - int target = NFP_CPP_ID_TARGET_of(cpp_island_id); + uint8_t island = NFP_CPP_ID_ISLAND_of(cpp_island_id); + uint8_t target = NFP_CPP_ID_TARGET_of(cpp_island_id); uint32_t imb; - if (target < 0 || target >= 16) + if (target >= 16) return NFP_ERRNO(EINVAL); if (island == 0) { -- 2.30.2