Skip to contentSkip to conversation

bbdev: prevent clang 3.4.2 compilation error

PATCH In review Nicolas Chautru 3 participants 3 messages Oct 10, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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

---
 lib/bbdev/rte_bbdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/bbdev/rte_bbdev.c +4 -2
index 453e5747b6..1521cdbc53 100644
@@ -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");
Signature · 1 line
2.37.1
Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines

-----Original Message-----
From: Nicolas Chautru <[email protected]>
Sent: Monday, October 10, 2022 8:04 PM
To: NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; [email protected]; [email protected]
Cc: Nicolas Chautru <[email protected]>
Subject: [PATCH v1] bbdev: prevent clang 3.4.2 compilation error

Quoted 5 lines

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

---

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

#2 lore raw
Quoted 8 lines
Quoted 4 lines

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

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

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