You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/08/22 19:18:43 UTC
[mynewt-nimble] 02/02: nimble/ll: Fix adv macros
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 2aafc341ae85f50433625bded347a45a30b87e34
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Aug 22 19:31:56 2022 +0200
nimble/ll: Fix adv macros
Use parentheses around macro parameters to avoid issue when expanding
macro. Also some macros uses "advsm" instead of "_advsm" parameter.
---
nimble/controller/src/ble_ll_adv.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/nimble/controller/src/ble_ll_adv.c b/nimble/controller/src/ble_ll_adv.c
index f0e0ae6b..0ffa1afc 100644
--- a/nimble/controller/src/ble_ll_adv.c
+++ b/nimble/controller/src/ble_ll_adv.c
@@ -193,19 +193,23 @@ struct ble_ll_adv_sm
#define BLE_LL_ADV_SM_FLAG_CONN_RSP_TXD_ERR 0x8000
#define ADV_DATA_LEN(_advsm) \
- ((_advsm->adv_data) ? OS_MBUF_PKTLEN(advsm->adv_data) : 0)
+ (((_advsm)->adv_data) ? OS_MBUF_PKTLEN((_advsm)->adv_data) : 0)
#define SCAN_RSP_DATA_LEN(_advsm) \
- ((_advsm->scan_rsp_data) ? OS_MBUF_PKTLEN(advsm->scan_rsp_data) : 0)
-#define AUX_DATA_LEN(_advsm) \
- (*(_advsm->aux_data) ? OS_MBUF_PKTLEN(*advsm->aux_data) : 0)
+ (((_advsm)->scan_rsp_data) ? OS_MBUF_PKTLEN((_advsm)->scan_rsp_data) : 0)
-#define AUX_CURRENT(_advsm) (&(_advsm->aux[_advsm->aux_index]))
-#define AUX_NEXT(_advsm) (&(_advsm->aux[_advsm->aux_index ^ 1]))
+#define AUX_CURRENT(_advsm) \
+ (&((_advsm)->aux[(_advsm)->aux_index]))
+#define AUX_NEXT(_advsm) \
+ (&((_advsm)->aux[(_advsm)->aux_index ^ 1]))
+#define AUX_DATA_LEN(_advsm) \
+ (*((_advsm)->aux_data) ? OS_MBUF_PKTLEN(*(_advsm)->aux_data) : 0)
-#define SYNC_CURRENT(_advsm) (&(_advsm->periodic_sync[_advsm->periodic_sync_index]))
-#define SYNC_NEXT(_advsm) (&(_advsm->periodic_sync[_advsm->periodic_sync_index ^ 1]))
+#define SYNC_CURRENT(_advsm) \
+ (&((_advsm)->periodic_sync[(_advsm)->periodic_sync_index]))
+#define SYNC_NEXT(_advsm) \
+ (&((_advsm)->periodic_sync[(_advsm)->periodic_sync_index ^ 1]))
#define SYNC_DATA_LEN(_advsm) \
- (_advsm->periodic_adv_data ? OS_MBUF_PKTLEN(advsm->periodic_adv_data) : 0)
+ ((_advsm)->periodic_adv_data ? OS_MBUF_PKTLEN((_advsm)->periodic_adv_data) : 0)
/* The advertising state machine global object */
struct ble_ll_adv_sm g_ble_ll_adv_sm[BLE_ADV_INSTANCES];