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

Commit 5d5e6c11 authored by Myles Watson's avatar Myles Watson
Browse files

Remove unused context pointer in callback

Bug: 283254594
Test: mma -j32
Change-Id: I3f3033a544bbd9fe276372065cfedacf033623a5
parent 7605a365
Loading
Loading
Loading
Loading
+15 −19
Original line number Diff line number Diff line
@@ -1063,8 +1063,7 @@ static void btu_hcif_esco_connection_chg_evt(uint8_t* p) {
 *
 ******************************************************************************/
static void btu_hcif_hdl_command_complete(uint16_t opcode, uint8_t* p,
                                          uint16_t evt_len,
                                          void* p_cplt_cback) {
                                          uint16_t evt_len) {
  switch (opcode) {
    case HCI_INQUIRY_CANCEL:
      /* Tell inquiry processing that we are done */
@@ -1183,8 +1182,7 @@ static void btu_hcif_hdl_command_complete(uint16_t opcode, uint8_t* p,
 * Returns          void
 *
 ******************************************************************************/
static void btu_hcif_command_complete_evt_on_task(BT_HDR* event,
                                                  void* context) {
static void btu_hcif_command_complete_evt_on_task(BT_HDR* event) {
  command_opcode_t opcode;
  // 2 for event header: event code (1) + parameter length (1)
  // 1 for num_hci_pkt command credit
@@ -1195,15 +1193,16 @@ static void btu_hcif_command_complete_evt_on_task(BT_HDR* event,
  // 2 for event header: event code (1) + parameter length (1)
  // 3 for command complete header: num_hci_pkt (1) + opcode (2)
  uint16_t param_len = static_cast<uint16_t>(event->len - 5);
  btu_hcif_hdl_command_complete(opcode, stream, param_len, context);
  btu_hcif_hdl_command_complete(opcode, stream, param_len);

  osi_free(event);
}

static void btu_hcif_command_complete_evt(BT_HDR* response, void* context) {
static void btu_hcif_command_complete_evt(BT_HDR* response,
                                          void* /* context */) {
  do_in_main_thread(
      FROM_HERE,
      base::BindOnce(btu_hcif_command_complete_evt_on_task, response, context));
      base::BindOnce(btu_hcif_command_complete_evt_on_task, response));
}

/*******************************************************************************
@@ -1216,8 +1215,7 @@ static void btu_hcif_command_complete_evt(BT_HDR* response, void* context) {
 *
 ******************************************************************************/
static void btu_hcif_hdl_command_status(uint16_t opcode, uint8_t status,
                                        const uint8_t* p_cmd,
                                        void* p_vsc_status_cback) {
                                        const uint8_t* p_cmd) {
  CHECK_NE(p_cmd, nullptr) << "Null command for opcode 0x" << loghex(opcode);
  p_cmd++;  // Skip parameter total length

@@ -1327,9 +1325,8 @@ static void btu_hcif_hdl_command_status(uint16_t opcode, uint8_t status,
}

void bluetooth::legacy::testing::btu_hcif_hdl_command_status(
    uint16_t opcode, uint8_t status, const uint8_t* p_cmd,
    void* p_vsc_status_cback) {
  ::btu_hcif_hdl_command_status(opcode, status, p_cmd, p_vsc_status_cback);
    uint16_t opcode, uint8_t status, const uint8_t* p_cmd) {
  ::btu_hcif_hdl_command_status(opcode, status, p_cmd);
}

/*******************************************************************************
@@ -1341,8 +1338,7 @@ void bluetooth::legacy::testing::btu_hcif_hdl_command_status(
 * Returns          void
 *
 ******************************************************************************/
static void btu_hcif_command_status_evt_on_task(uint8_t status, BT_HDR* event,
                                                void* context) {
static void btu_hcif_command_status_evt_on_task(uint8_t status, BT_HDR* event) {
  command_opcode_t opcode;
  uint8_t* stream = event->data + event->offset;
  STREAM_TO_UINT16(opcode, stream);
@@ -1351,15 +1347,15 @@ static void btu_hcif_command_status_evt_on_task(uint8_t status, BT_HDR* event,
  // No need to check length since stream is written by us
  btu_hcif_log_command_metrics(opcode, stream + 1, status, true);

  btu_hcif_hdl_command_status(opcode, status, stream, context);
  btu_hcif_hdl_command_status(opcode, status, stream);
  osi_free(event);
}

static void btu_hcif_command_status_evt(uint8_t status, BT_HDR* command,
                                        void* context) {
  do_in_main_thread(FROM_HERE,
                    base::BindOnce(btu_hcif_command_status_evt_on_task, status,
                                   command, context));
                                        void* /* context */) {
  do_in_main_thread(
      FROM_HERE,
      base::BindOnce(btu_hcif_command_status_evt_on_task, status, command));
}

/*******************************************************************************
+1 −2
Original line number Diff line number Diff line
@@ -37,6 +37,5 @@ void btu_hcif_send_cmd_with_cb(const base::Location& posted_from,
                               base::OnceCallback<void(uint8_t*, uint16_t)> cb);
namespace bluetooth::legacy::testing {
void btu_hcif_hdl_command_status(uint16_t opcode, uint8_t status,
                                 const uint8_t* p_cmd,
                                 void* p_vsc_status_cback);
                                 const uint8_t* p_cmd);
}  // namespace bluetooth::legacy::testing
 No newline at end of file
+2 −3
Original line number Diff line number Diff line
@@ -28,8 +28,7 @@

/* Function for test provided by btu_hcif.cc */
void btu_hcif_hdl_command_status(uint16_t opcode, uint8_t status,
                                 const uint8_t* p_cmd,
                                 void* p_vsc_status_cback);
                                 const uint8_t* p_cmd);

class StackBtuTest : public ::testing::Test {
 protected:
@@ -41,6 +40,6 @@ TEST_F(StackBtuTest, post_on_main) {}
TEST_F(StackBtuTest, btm_sco_connection_failed_called) {
  uint8_t p_cmd[10];  // garbage data for testing
  bluetooth::legacy::testing::btu_hcif_hdl_command_status(
      HCI_SETUP_ESCO_CONNECTION, HCI_ERR_UNSPECIFIED, p_cmd, nullptr);
      HCI_SETUP_ESCO_CONNECTION, HCI_ERR_UNSPECIFIED, p_cmd);
  ASSERT_EQ(1, get_func_call_count("btm_sco_connection_failed"));
}