DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/bnxt: fix clang compiler warnings
@ 2021-10-10  4:07 Ajit Khaparde
  2021-10-11 17:55 ` Ajit Khaparde
  2021-10-12  2:46 ` Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Ajit Khaparde @ 2021-10-10  4:07 UTC (permalink / raw)
  To: dev; +Cc: Shahaji Bhosle

[-- Attachment #1: Type: text/plain, Size: 3147 bytes --]

From: Shahaji Bhosle <sbhosle@broadcom.com>

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")

Signed-off-by: Shahaji Bhosle <sbhosle@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
index 3a9c9bba27..b589f2281e 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
@@ -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 */
-- 
2.30.1 (Apple Git-130)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/bnxt: fix clang compiler warnings
  2021-10-10  4:07 [dpdk-dev] [PATCH] net/bnxt: fix clang compiler warnings Ajit Khaparde
@ 2021-10-11 17:55 ` Ajit Khaparde
  2021-10-12  2:46 ` Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: Ajit Khaparde @ 2021-10-11 17:55 UTC (permalink / raw)
  To: dpdk-dev; +Cc: Shahaji Bhosle, Ferruh Yigit

[-- Attachment #1: Type: text/plain, Size: 1926 bytes --]

On Sat, Oct 9, 2021 at 9:07 PM Ajit Khaparde <ajit.khaparde@broadcom.com> wrote:
>
> From: Shahaji Bhosle <sbhosle@broadcom.com>
>
> 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")
>
> Signed-off-by: Shahaji Bhosle <sbhosle@broadcom.com>
> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/bnxt: fix clang compiler warnings
  2021-10-10  4:07 [dpdk-dev] [PATCH] net/bnxt: fix clang compiler warnings Ajit Khaparde
  2021-10-11 17:55 ` Ajit Khaparde
@ 2021-10-12  2:46 ` Stephen Hemminger
  2021-10-12  4:08   ` Ajit Khaparde
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2021-10-12  2:46 UTC (permalink / raw)
  To: Ajit Khaparde; +Cc: dev, Shahaji Bhosle

On Sat,  9 Oct 2021 21:07:55 -0700
Ajit Khaparde <ajit.khaparde@broadcom.com> wrote:

> +		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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/bnxt: fix clang compiler warnings
  2021-10-12  2:46 ` Stephen Hemminger
@ 2021-10-12  4:08   ` Ajit Khaparde
  0 siblings, 0 replies; 4+ messages in thread
From: Ajit Khaparde @ 2021-10-12  4:08 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dpdk-dev, Shahaji Bhosle

[-- Attachment #1: Type: text/plain, Size: 583 bytes --]

On Mon, Oct 11, 2021 at 7:46 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Sat,  9 Oct 2021 21:07:55 -0700
> Ajit Khaparde <ajit.khaparde@broadcom.com> wrote:
>
> > +             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.
Thanks. We will work on the proper fix.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-12  4:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-10  4:07 [dpdk-dev] [PATCH] net/bnxt: fix clang compiler warnings Ajit Khaparde
2021-10-11 17:55 ` Ajit Khaparde
2021-10-12  2:46 ` Stephen Hemminger
2021-10-12  4:08   ` Ajit Khaparde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).