bbdev: prevent clang 3.4.2 compilation error
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
@@ -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
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_tto avoid compilation warning with clang 3.4.2 -Wtautological-constant-out-of-range-compareSigned-off-by Nicolas Chautru <[email protected]>---
Verified that the build passes with this patch. Thanks Nicolas.
Quoted 8 lines
Quoted 4 lines
Casting explicitly from enum to
uint8_tto avoid compilation warning with clang 3.4.2 -Wtautological-constant-out-of-range-compareSigned-off-by Nicolas Chautru <[email protected]>Verified that the build passes with this patch. Thanks Nicolas.
Tested-by Ali Alnubani <[email protected]>
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