DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1] bbdev: prevent clang 3.4.2 compilation error
@ 2022-10-10 17:04 Nicolas Chautru
  2022-10-10 18:39 ` Ali Alnubani
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Chautru @ 2022-10-10 17:04 UTC (permalink / raw)
  To: thomas, dev, gakhil; +Cc: Nicolas Chautru

Casting explicitly from enum to uint8_t to avoid compilation
warning with clang 3.4.2 -Wtautological-constant-out-of-range-compare

Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
---
 lib/bbdev/rte_bbdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/bbdev/rte_bbdev.c b/lib/bbdev/rte_bbdev.c
index 453e5747b6..1521cdbc53 100644
--- a/lib/bbdev/rte_bbdev.c
+++ b/lib/bbdev/rte_bbdev.c
@@ -1159,7 +1159,8 @@ rte_bbdev_device_status_str(enum rte_bbdev_device_status status)
 		"RTE_BBDEV_DEV_CORRECT_ERR",
 	};
 
-	if (status < sizeof(dev_sta_string) / sizeof(char *))
+	/* Cast from enum required for clang. */
+	if ((uint8_t)status < sizeof(dev_sta_string) / sizeof(char *))
 		return dev_sta_string[status];
 
 	rte_bbdev_log(ERR, "Invalid device status");
@@ -1176,7 +1177,8 @@ rte_bbdev_enqueue_status_str(enum rte_bbdev_enqueue_status status)
 		"RTE_BBDEV_ENQ_STATUS_INVALID_OP",
 	};
 
-	if (status < sizeof(enq_sta_string) / sizeof(char *))
+	/* Cast from enum required for clang. */
+	if ((uint8_t)status < sizeof(enq_sta_string) / sizeof(char *))
 		return enq_sta_string[status];
 
 	rte_bbdev_log(ERR, "Invalid enqueue status");
-- 
2.37.1


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

* RE: [PATCH v1] bbdev: prevent clang 3.4.2 compilation error
  2022-10-10 17:04 [PATCH v1] bbdev: prevent clang 3.4.2 compilation error Nicolas Chautru
@ 2022-10-10 18:39 ` Ali Alnubani
  2022-10-10 23:27   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Ali Alnubani @ 2022-10-10 18:39 UTC (permalink / raw)
  To: Nicolas Chautru, NBU-Contact-Thomas Monjalon (EXTERNAL), dev, gakhil

> -----Original Message-----
> From: Nicolas Chautru <nicolas.chautru@intel.com>
> Sent: Monday, October 10, 2022 8:04 PM
> To: NBU-Contact-Thomas Monjalon (EXTERNAL) <thomas@monjalon.net>;
> dev@dpdk.org; gakhil@marvell.com
> Cc: Nicolas Chautru <nicolas.chautru@intel.com>
> Subject: [PATCH v1] bbdev: prevent clang 3.4.2 compilation error
> 
> Casting explicitly from enum to uint8_t to avoid compilation
> warning with clang 3.4.2 -Wtautological-constant-out-of-range-compare
> 
> Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
> ---

Verified that the build passes with this patch. Thanks Nicolas.

Tested-by: Ali Alnubani <alialnu@nvidia.com>

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

* Re: [PATCH v1] bbdev: prevent clang 3.4.2 compilation error
  2022-10-10 18:39 ` Ali Alnubani
@ 2022-10-10 23:27   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2022-10-10 23:27 UTC (permalink / raw)
  To: Nicolas Chautru; +Cc: dev, gakhil, Ali Alnubani

> > Casting explicitly from enum to uint8_t to avoid compilation
> > warning with clang 3.4.2 -Wtautological-constant-out-of-range-compare
> > 
> > Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
> 
> Verified that the build passes with this patch. Thanks Nicolas.
> 
> Tested-by: Ali Alnubani <alialnu@nvidia.com>

Applied with more complete commit message, thanks:

bbdev: fix build with clang 3.4.2

Casting explicitly from enum to uint8_t to avoid compilation
warning with clang 3.4.2:

  rte_bbdev.c:1179:13: error:
  comparison of constant 4 with expression
  of type 'enum rte_bbdev_enqueue_status' is always true
  [-Werror,-Wtautological-constant-out-of-range-compare]

Bugzilla ID: 1095
Fixes: 1be86f2e94e4 ("bbdev: add device status info")
Fixes: 4f08028c5e24 ("bbdev: expose queue related warning and status")



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

end of thread, other threads:[~2022-10-10 23:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-10 17:04 [PATCH v1] bbdev: prevent clang 3.4.2 compilation error Nicolas Chautru
2022-10-10 18:39 ` Ali Alnubani
2022-10-10 23:27   ` Thomas Monjalon

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