Skip to contentSkip to conversation

net/bnxt: fix clang compiler warnings

PATCH In review Ajit Khaparde 2 participants 4 messages Oct 10, 2021 – Oct 12, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/bnxt: fix clang compiler warnings

From: Shahaji Bhosle <[email protected]>

Fix an error reported during CLANG compilation.

-Wtautological-constant-out-of-range-compare for enums

$ export CC=clang
$ meson --werror --buildtype=debugoptimized build && ninja-build -C build
"
[..]
../../root/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c:140:18: error: comparison of constant 2147483648 with expression of type 'const enum rte_flow_item_type' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
                if (item->type >= (uint32_t)
                    ~~~~~~~~~~ ^  ~~~~~~~~~~
../../root/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c:142:19: error: comparison of constant 2147483650 with expression of type 'const enum rte_flow_item_type' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
                        if (item->type >=
                            ~~~~~~~~~~ ^
../../root/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c:188:25: error: comparison of constant 2147483648 with expression of type 'const enum rte_flow_action_type' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
                if (action_item->type >=
                    ~~~~~~~~~~~~~~~~~ ^
../../root/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c:190:26: error: comparison of constant 2147483650 with expression of type 'const enum rte_flow_action_type' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
                        if (action_item->type >=
                            ~~~~~~~~~~~~~~~~~ ^
4 errors generated.
"

Bugzilla ID: 821

Fixes bdf4a3c6316b ("net/bnxt: support tunnel offload")
---
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +5 -5
index 3a9c9bba27..b589f2281e 100644
@@ -137,9 +137,9 @@ bnxt_ulp_rte_parser_hdr_parse(const struct rte_flow_item pattern[],
 
 	/* Parse all the items in the pattern */
 	while (item && item->type != RTE_FLOW_ITEM_TYPE_END) {
-		if (item->type >= (uint32_t)
-		    BNXT_RTE_FLOW_ITEM_TYPE_END) {
-			if (item->type >=
+		if ((uint32_t)item->type >=
+		    (uint32_t)BNXT_RTE_FLOW_ITEM_TYPE_END) {
+			if ((uint32_t)item->type >=
 			    (uint32_t)BNXT_RTE_FLOW_ITEM_TYPE_LAST)
 				goto hdr_parser_error;
 			/* get the header information */
@@ -185,9 +185,9 @@ bnxt_ulp_rte_parser_act_parse(const struct rte_flow_action actions[],
 
 	/* Parse all the items in the pattern */
 	while (action_item && action_item->type != RTE_FLOW_ACTION_TYPE_END) {
-		if (action_item->type >=
+		if ((uint32_t)action_item->type >=
 		    (uint32_t)BNXT_RTE_FLOW_ACTION_TYPE_END) {
-			if (action_item->type >=
+			if ((uint32_t)action_item->type >=
 			    (uint32_t)BNXT_RTE_FLOW_ACTION_TYPE_LAST)
 				goto act_parser_error;
 			/* get the header information from bnxt actinfo table */
Signature · 1 line
2.30.1 (Apple Git-130)
#1 lore raw
Quoted 26 lines · Ajit Khaparde

From: Shahaji Bhosle <[email protected]>

Fix an error reported during CLANG compilation.

-Wtautological-constant-out-of-range-compare for enums

$ export CC=clang
$ meson --werror --buildtype=debugoptimized build && ninja-build -C build
"
[..]
../../root/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c:140:18: error: comparison of constant 2147483648 with expression of type 'const enum rte_flow_item_type' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
                if (item->type >= (uint32_t)
                    ~~~~~~~~~~ ^  ~~~~~~~~~~
../../root/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c:142:19: error: comparison of constant 2147483650 with expression of type 'const enum rte_flow_item_type' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
                        if (item->type >=
                            ~~~~~~~~~~ ^
../../root/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c:188:25: error: comparison of constant 2147483648 with expression of type 'const enum rte_flow_action_type' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
                if (action_item->type >=
                    ~~~~~~~~~~~~~~~~~ ^
../../root/dpdk/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c:190:26: error: comparison of constant 2147483650 with expression of type 'const enum rte_flow_action_type' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
                        if (action_item->type >=
                            ~~~~~~~~~~~~~~~~~ ^
4 errors generated.
"
Quoted 5 lines

Bugzilla ID: 821

Fixes bdf4a3c6316b ("net/bnxt: support tunnel offload")

Patch applied to dpdk-next-net-brcm. Thanks

#2 lore raw
In reply to Ajit Khaparde

drivers/net/bnxt/tf_ulp/ulp_rte_parser.c bnxt_ulp_rte_parser_hdr_parse(const struct rte_flow_item pattern[], · line 141

Quoted 2 lines · On Sat, 9 Oct 2021 21:07:55 -0700 Ajit Khaparde <[email protected]>…
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +2 -0
+		if ((uint32_t)item->type >=
+		    (uint32_t)BNXT_RTE_FLOW_ITEM_TYPE_END) {

This doesn't look right, you are casting away your troubles, not addressing the root cause.

item->type is type rte_flow_item_type BNXT_FLOW_ITEM_TYPE_END is the first item in that enum.

So yes the warning is valid and the code is wrong.

#3 lore raw
Quoted 8 lines · Stephen Hemminger

drivers/net/bnxt/tf_ulp/ulp_rte_parser.c bnxt_ulp_rte_parser_hdr_parse(const struct rte_flow_item pattern[], · line 141

Quoted 2 lines · On Sat, 9 Oct 2021 21:07:55 -0700 Ajit Khaparde <[email protected]>…
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +2 -0
+             if ((uint32_t)item->type >=
+                 (uint32_t)BNXT_RTE_FLOW_ITEM_TYPE_END) {
Quoted 7 lines

This doesn't look right, you are casting away your troubles, not addressing the root cause.

item->type is type rte_flow_item_type BNXT_FLOW_ITEM_TYPE_END is the first item in that enum.

So yes the warning is valid and the code is wrong.

Thanks. We will work on the proper fix.