Skip to content

Commit 7f1589e

Browse files
larsgknashif
authored andcommitted
Bluetooth: ISO: Add ISO BIS bitfield check macro
Checks validity of ISO BIS bitfield (BIT(0)|...|BIT(30)) Signed-off-by: Lars Knudsen <[email protected]>
1 parent 05d59f7 commit 7f1589e

File tree

2 files changed

+9
-1
lines changed
  • include/zephyr/bluetooth
  • subsys/bluetooth/host

2 files changed

+9
-1
lines changed

include/zephyr/bluetooth/iso.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ extern "C" {
140140
/** Maximum pre-transmission offset */
141141
#define BT_ISO_PTO_MAX 0x0FU
142142

143+
/**
144+
* @brief Check if ISO BIS bitfield is valid (BT_ISO_BIS_INDEX_BIT(1)|..|BT_ISO_BIS_INDEX_BIT(31))
145+
*
146+
* @param _bis_bitfield BIS index bitfield (uint32)
147+
*/
148+
#define BT_ISO_VALID_BIS_BITFIELD(_bis_bitfield) \
149+
((_bis_bitfield) != 0U && (_bis_bitfield) <= BIT_MASK(BT_ISO_BIS_INDEX_MAX))
150+
143151
/**
144152
* @brief Life-span states of ISO channel. Used only by internal APIs dealing with setting channel
145153
* to proper state depending on operational context.

subsys/bluetooth/host/iso.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3316,7 +3316,7 @@ int bt_iso_big_sync(struct bt_le_per_adv_sync *sync, struct bt_iso_big_sync_para
33163316
return -EINVAL;
33173317
}
33183318

3319-
CHECKIF(param->bis_bitfield == 0U || param->bis_bitfield > BIT_MASK(BT_ISO_BIS_INDEX_MAX)) {
3319+
CHECKIF(!BT_ISO_VALID_BIS_BITFIELD(param->bis_bitfield)) {
33203320
LOG_DBG("Invalid BIS bitfield 0x%08x", param->bis_bitfield);
33213321
return -EINVAL;
33223322
}

0 commit comments

Comments
 (0)