patch 'net/nfp: remove useless range checks' has been queued to stable release 20.11.5

luca.boccassi at gmail.com luca.boccassi at gmail.com
Fri Feb 18 13:38:16 CET 2022


Hi,

FYI, your patch has been queued to stable release 20.11.5

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/20/22. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/238f205dd5c574ec8583dc95b753eebbd5e0af70

Thanks.

Luca Boccassi

---
>From 238f205dd5c574ec8583dc95b753eebbd5e0af70 Mon Sep 17 00:00:00 2001
From: Maxime Gouin <maxime.gouin at 6wind.com>
Date: Wed, 5 Jan 2022 11:32:03 +0100
Subject: [PATCH] net/nfp: remove useless range checks

[ upstream commit a52c79642ab4296763189dd8efadbb679d32c9a0 ]

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 <maxime.gouin at 6wind.com>
Reviewed-by: Olivier Matz <olivier.matz at 6wind.com>
Acked-by: Kevin Traynor <ktraynor at redhat.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit at intel.com>
---
 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 2884a0034f..e8dcc9ad1e 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

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-02-18 12:37:39.877005113 +0000
+++ 0047-net-nfp-remove-useless-range-checks.patch	2022-02-18 12:37:37.662791295 +0000
@@ -1 +1 @@
-From a52c79642ab4296763189dd8efadbb679d32c9a0 Mon Sep 17 00:00:00 2001
+From 238f205dd5c574ec8583dc95b753eebbd5e0af70 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit a52c79642ab4296763189dd8efadbb679d32c9a0 ]
+
@@ -19 +20,0 @@
-Cc: stable at dpdk.org


More information about the stable mailing list