Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6db20f6d authored by Myles Watson's avatar Myles Watson Committed by Pavlin Radoslavov
Browse files

btif: Add do-while blocks to macros

Test: mma -j32
Change-Id: Ie82465b8cef6c4f527fad13892abb365e15dad7c
parent 6abd01ee
Loading
Loading
Loading
Loading
+16 −12
Original line number Diff line number Diff line
@@ -34,10 +34,12 @@
 *******************************************************************************/

#define ASSERTC(cond, msg, val)                                              \
  do {                                                                       \
    if (!(cond)) {                                                           \
      LOG_ERROR(LOG_TAG, "### ASSERT : %s %s line %d %s (%d) ###", __FILE__, \
              __func__, __LINE__, msg, val);                               \
  }
                __func__, __LINE__, (msg), (val));                           \
    }                                                                        \
  } while (0)

/* Calculate start of event enumeration; id is top 8 bits of event */
#define BTIF_SIG_START(id) ((id) << 8)
@@ -73,12 +75,14 @@
extern bt_callbacks_t* bt_hal_cbacks;

#define HAL_CBACK(P_CB, P_CBACK, ...)                \
  do {                                               \
    if ((P_CB) && (P_CB)->P_CBACK) {                 \
      BTIF_TRACE_API("HAL %s->%s", #P_CB, #P_CBACK); \
      (P_CB)->P_CBACK(__VA_ARGS__);                  \
    } else {                                         \
      ASSERTC(0, "Callback is NULL", 0);             \
  }
    }                                                \
  } while (0)

/**
 * BTIF events for requests that require context switch to btif task
+5 −3
Original line number Diff line number Diff line
@@ -28,9 +28,11 @@
 *  Constants & Macros
 *******************************************************************************/
#define BTIF_STORAGE_FILL_PROPERTY(p_prop, t, l, p_v) \
  (p_prop)->type = t;                                 \
  (p_prop)->len = l;                                  \
  (p_prop)->val = (p_v);
  do {                                                \
    (p_prop)->type = (t);                             \
    (p_prop)->len = (l);                              \
    (p_prop)->val = (p_v);                            \
  } while (0)

/*******************************************************************************
 *  Functions
+10 −8
Original line number Diff line number Diff line
@@ -100,13 +100,15 @@ static alarm_t* av_open_on_rc_timer = NULL;

/* both interface and media task needs to be ready to alloc incoming request */
#define CHECK_BTAV_INIT()                                                    \
  do {                                                                       \
    if (((bt_av_src_callbacks == NULL) && (bt_av_sink_callbacks == NULL)) || \
        (btif_av_cb.sm_handle == NULL)) {                                    \
      BTIF_TRACE_WARNING("%s: BTAV not initialized", __func__);              \
      return BT_STATUS_NOT_READY;                                            \
    } else {                                                                 \
      BTIF_TRACE_EVENT("%s", __func__);                                      \
  }
    }                                                                        \
  } while (0)

/* Helper macro to avoid code duplication in the state machine handlers */
#define CHECK_RC_EVENT(e, d)       \
+19 −15
Original line number Diff line number Diff line
@@ -69,20 +69,24 @@ extern const btgatt_callbacks_t* bt_gatt_callbacks;
 *******************************************************************************/

#define CLI_CBACK_IN_JNI(P_CBACK, ...)                                         \
  do {                                                                         \
    if (bt_gatt_callbacks && bt_gatt_callbacks->client->P_CBACK) {             \
      BTIF_TRACE_API("HAL bt_gatt_callbacks->client->%s", #P_CBACK);           \
      do_in_jni_thread(Bind(bt_gatt_callbacks->client->P_CBACK, __VA_ARGS__)); \
    } else {                                                                   \
      ASSERTC(0, "Callback is NULL", 0);                                       \
  }
    }                                                                          \
  } while (0)

#define CHECK_BTGATT_INIT()                                      \
  do {                                                           \
    if (bt_gatt_callbacks == NULL) {                             \
      LOG_WARN(LOG_TAG, "%s: BTGATT not initialized", __func__); \
      return BT_STATUS_NOT_READY;                                \
    } else {                                                     \
      LOG_VERBOSE(LOG_TAG, "%s", __func__);                      \
  }
    }                                                            \
  } while (0)

#define BLE_RESOLVE_ADDR_MSB                                                   \
  0x40                             /* bit7, bit6 is 01 to be resolvable random \
+9 −7
Original line number Diff line number Diff line
@@ -61,12 +61,14 @@ extern bt_status_t do_in_jni_thread(const base::Closure& task);
 ***********************************************************************************/

#define CHECK_BTGATT_INIT()                                      \
  do {                                                           \
    if (bt_gatt_callbacks == NULL) {                             \
      LOG_WARN(LOG_TAG, "%s: BTGATT not initialized", __func__); \
      return BT_STATUS_NOT_READY;                                \
    } else {                                                     \
      LOG_VERBOSE(LOG_TAG, "%s", __func__);                      \
  }
    }                                                            \
  } while (0)

/************************************************************************************
 *  Static variables
Loading