Bluetooth: controller: fix comparision of unsigned int to 0

Fix the coverity issue CWE570, comparison of unsigned int to 0
in the definition of IS_SYNC_ISO_HANDLE

There is a potentially the same issue for IS_ADV_ISO_HANDLE,
fixed that as well

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
This commit is contained in:
Andries Kruithof 2023-09-28 13:35:34 +02:00 committed by Carles Cufí
parent 019ae15f05
commit c5d844fe41

View file

@ -9,11 +9,18 @@
#define LL_BIS_ADV_HANDLE_BASE BT_CTLR_ADV_ISO_STREAM_HANDLE_BASE
#define LL_BIS_ADV_IDX_FROM_HANDLE(conn_handle) \
((conn_handle) - (LL_BIS_ADV_HANDLE_BASE))
/* Conditional compile to prevent coverity issue CWE570, comparison of unsigned int to 0 */
#if (LL_BIS_ADV_HANDLE_BASE > 0)
#define IS_ADV_ISO_HANDLE(conn_handle) \
(((conn_handle) >= (LL_BIS_ADV_HANDLE_BASE)) && \
((conn_handle) <= ((LL_BIS_ADV_HANDLE_BASE) + \
(BT_CTLR_ADV_ISO_STREAM_MAX) - 1U)))
#else
#define IS_ADV_ISO_HANDLE(conn_handle) \
((conn_handle) <= ((LL_BIS_ADV_HANDLE_BASE) + \
(BT_CTLR_ADV_ISO_STREAM_MAX) - 1U))
#endif /* LL_BIS_ADV_HANDLE_BASE */
#else
#define LL_BIS_ADV_IDX_FROM_HANDLE(conn_handle) 0U
#define IS_ADV_ISO_HANDLE(conn_handle) 0U
#endif /* CONFIG_BT_CTLR_ADV_ISO */
@ -23,11 +30,18 @@
#define LL_BIS_SYNC_HANDLE_BASE BT_CTLR_SYNC_ISO_STREAM_HANDLE_BASE
#define LL_BIS_SYNC_IDX_FROM_HANDLE(conn_handle) \
((conn_handle) - (LL_BIS_SYNC_HANDLE_BASE))
/* Conditional compile to prevent coverity issue CWE570, comparison of unsigned int to 0 */
#if (LL_BIS_SYNC_HANDLE_BASE > 0)
#define IS_SYNC_ISO_HANDLE(conn_handle) \
(((conn_handle) >= (LL_BIS_SYNC_HANDLE_BASE)) && \
((conn_handle) <= ((LL_BIS_SYNC_HANDLE_BASE) + \
(BT_CTLR_SYNC_ISO_STREAM_MAX) - 1U)))
#else
#define IS_SYNC_ISO_HANDLE(conn_handle) \
((conn_handle) <= ((LL_BIS_SYNC_HANDLE_BASE) + \
(BT_CTLR_SYNC_ISO_STREAM_MAX) - 1U))
#endif /* LL_BIS_SYNC_HANDLE_BASE */
#else
#define LL_BIS_SYNC_IDX_FROM_HANDLE(conn_handle) 0U
#define IS_SYNC_ISO_HANDLE(conn_handle) 0U
#endif /* CONFIG_BT_CTLR_SYNC_ISO */