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

Commit 83fb60f6 authored by Henri Chataing's avatar Henri Chataing
Browse files

system/stack/gap: Fix -Wmissing-prototype errors

Bug: 369381361
Test: m com.android.btservices
Flag: EXEMPT, no logical change
Change-Id: I5e5bab4f10e54d928fdae0dbe234f70fe4f5cbd9
parent fdd49146
Loading
Loading
Loading
Loading
+22 −24
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <queue>

#include "gap_api.h"
#include "gap_int.h"
#include "gatt_api.h"
#include "hardware/bt_gatt_types.h"
#include "stack/include/bt_types.h"
@@ -33,9 +34,6 @@
#include "types/bt_transport.h"
#include "types/raw_address.h"

// TODO(b/369381361) Enfore -Wmissing-prototypes
#pragma GCC diagnostic ignored "-Wmissing-prototypes"

using bluetooth::Uuid;
using namespace bluetooth;

@@ -61,10 +59,10 @@ typedef struct {
  tGAP_BLE_ATTR_VALUE attr_value;
} tGAP_ATTR;

void server_attr_request_cback(tCONN_ID, uint32_t, tGATTS_REQ_TYPE, tGATTS_DATA*);
void client_connect_cback(tGATT_IF, const RawAddress&, tCONN_ID, bool, tGATT_DISCONN_REASON,
static void server_attr_request_cback(tCONN_ID, uint32_t, tGATTS_REQ_TYPE, tGATTS_DATA*);
static void client_connect_cback(tGATT_IF, const RawAddress&, tCONN_ID, bool, tGATT_DISCONN_REASON,
                                 tBT_TRANSPORT);
void client_cmpl_cback(tCONN_ID, tGATTC_OPTYPE, tGATT_STATUS, tGATT_CL_COMPLETE*);
static void client_cmpl_cback(tCONN_ID, tGATTC_OPTYPE, tGATT_STATUS, tGATT_CL_COMPLETE*);

tGATT_CBACK gap_cback = {
        .p_conn_cb = client_connect_cback,
@@ -88,7 +86,7 @@ std::array<tGAP_ATTR, GAP_MAX_CHAR_NUM> gatt_attr;
tGATT_IF gatt_if;

/** returns LCB with matching bd address, or nullptr */
tGAP_CLCB* find_clcb_by_bd_addr(const RawAddress& bda) {
static tGAP_CLCB* find_clcb_by_bd_addr(const RawAddress& bda) {
  for (auto& cb : gap_clcbs) {
    if (cb.bda == bda) {
      return &cb;
@@ -99,7 +97,7 @@ tGAP_CLCB* find_clcb_by_bd_addr(const RawAddress& bda) {
}

/** returns LCB with matching connection ID, or nullptr if not found  */
tGAP_CLCB* ble_find_clcb_by_conn_id(tCONN_ID conn_id) {
static tGAP_CLCB* ble_find_clcb_by_conn_id(tCONN_ID conn_id) {
  for (auto& cb : gap_clcbs) {
    if (cb.connected && cb.conn_id == conn_id) {
      return &cb;
@@ -110,7 +108,7 @@ tGAP_CLCB* ble_find_clcb_by_conn_id(tCONN_ID conn_id) {
}

/** allocates a GAP connection link control block */
tGAP_CLCB* clcb_alloc(const RawAddress& bda) {
static tGAP_CLCB* clcb_alloc(const RawAddress& bda) {
  gap_clcbs.emplace_back();
  tGAP_CLCB& cb = gap_clcbs.back();
  cb.bda = bda;
@@ -118,7 +116,7 @@ tGAP_CLCB* clcb_alloc(const RawAddress& bda) {
}

/** The function clean up the pending request queue in GAP */
void clcb_dealloc(tGAP_CLCB& clcb) {
static void clcb_dealloc(tGAP_CLCB& clcb) {
  // put last element into place of current element, and remove last one - just
  // fast remove.
  for (auto it = gap_clcbs.begin(); it != gap_clcbs.end(); it++) {
@@ -132,7 +130,7 @@ void clcb_dealloc(tGAP_CLCB& clcb) {
}

/** GAP Attributes Database Request callback */
tGATT_STATUS read_attr_value(uint16_t handle, tGATT_VALUE* p_value, bool is_long) {
static tGATT_STATUS read_attr_value(uint16_t handle, tGATT_VALUE* p_value, bool is_long) {
  uint8_t* p = p_value->value;
  uint16_t offset = p_value->offset;
  uint8_t* p_dev_name = NULL;
@@ -191,7 +189,7 @@ tGATT_STATUS read_attr_value(uint16_t handle, tGATT_VALUE* p_value, bool is_long
}

/** GAP Attributes Database Read/Read Blob Request process */
tGATT_STATUS proc_read(tGATTS_REQ_TYPE, tGATT_READ_REQ* p_data, tGATTS_RSP* p_rsp) {
static tGATT_STATUS proc_read(tGATTS_REQ_TYPE, tGATT_READ_REQ* p_data, tGATTS_RSP* p_rsp) {
  if (p_data->is_long) {
    p_rsp->attr_value.offset = p_data->offset;
  }
@@ -202,7 +200,7 @@ tGATT_STATUS proc_read(tGATTS_REQ_TYPE, tGATT_READ_REQ* p_data, tGATTS_RSP* p_rs
}

/** GAP ATT server process a write request */
tGATT_STATUS proc_write_req(tGATTS_REQ_TYPE, tGATT_WRITE_REQ* p_data) {
static tGATT_STATUS proc_write_req(tGATTS_REQ_TYPE, tGATT_WRITE_REQ* p_data) {
  for (const auto& db_addr : gatt_attr) {
    if (p_data->handle == db_addr.handle) {
      return GATT_WRITE_NOT_PERMIT;
@@ -213,7 +211,7 @@ tGATT_STATUS proc_write_req(tGATTS_REQ_TYPE, tGATT_WRITE_REQ* p_data) {
}

/** GAP ATT server attribute access request callback */
void server_attr_request_cback(tCONN_ID conn_id, uint32_t trans_id, tGATTS_REQ_TYPE type,
static void server_attr_request_cback(tCONN_ID conn_id, uint32_t trans_id, tGATTS_REQ_TYPE type,
                                      tGATTS_DATA* p_data) {
  tGATT_STATUS status = GATT_INVALID_PDU;
  bool ignore = false;
@@ -262,7 +260,7 @@ void server_attr_request_cback(tCONN_ID conn_id, uint32_t trans_id, tGATTS_REQ_T
 * Utility function to send a read request for GAP characteristics.
 * Returns true if read started, else false if GAP is busy.
 */
bool send_cl_read_request(tGAP_CLCB& clcb) {
static bool send_cl_read_request(tGAP_CLCB& clcb) {
  if (!clcb.requests.size() || clcb.cl_op_uuid != 0) {
    return false;
  }
@@ -288,7 +286,7 @@ bool send_cl_read_request(tGAP_CLCB& clcb) {
}

/** GAP client operation complete callback */
void cl_op_cmpl(tGAP_CLCB& clcb, bool status, uint16_t len, uint8_t* p_name) {
static void cl_op_cmpl(tGAP_CLCB& clcb, bool status, uint16_t len, uint8_t* p_name) {
  tGAP_BLE_CMPL_CBACK* p_cback = clcb.p_cback;
  uint16_t op = clcb.cl_op_uuid;

@@ -311,7 +309,7 @@ void cl_op_cmpl(tGAP_CLCB& clcb, bool status, uint16_t len, uint8_t* p_name) {
}

/** Client connection callback */
void client_connect_cback(tGATT_IF, const RawAddress& bda, tCONN_ID conn_id, bool connected,
static void client_connect_cback(tGATT_IF, const RawAddress& bda, tCONN_ID conn_id, bool connected,
                                 tGATT_DISCONN_REASON /* reason */, tBT_TRANSPORT) {
  tGAP_CLCB* p_clcb = find_clcb_by_bd_addr(bda);
  if (p_clcb == NULL) {
@@ -336,7 +334,7 @@ void client_connect_cback(tGATT_IF, const RawAddress& bda, tCONN_ID conn_id, boo
}

/** Client operation complete callback */
void client_cmpl_cback(tCONN_ID conn_id, tGATTC_OPTYPE op, tGATT_STATUS status,
static void client_cmpl_cback(tCONN_ID conn_id, tGATTC_OPTYPE op, tGATT_STATUS status,
                              tGATT_CL_COMPLETE* p_data) {
  tGAP_CLCB* p_clcb = ble_find_clcb_by_conn_id(conn_id);
  uint16_t op_type;
@@ -396,7 +394,7 @@ void client_cmpl_cback(tCONN_ID conn_id, tGATTC_OPTYPE op, tGATT_STATUS status,
  }
}

bool accept_client_operation(const RawAddress& peer_bda, uint16_t uuid,
static bool accept_client_operation(const RawAddress& peer_bda, uint16_t uuid,
                                    tGAP_BLE_CMPL_CBACK* p_cback) {
  if (p_cback == NULL && uuid != GATT_UUID_GAP_PREF_CONN_PARAM) {
    return false;
+2 −6
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <string.h>

#include "gap_api.h"
#include "gap_int.h"
#include "hci/controller_interface.h"
#include "internal_include/bt_target.h"
#include "main/shim/entry.h"
@@ -34,9 +35,6 @@
#include "types/bt_transport.h"
#include "types/raw_address.h"

// TODO(b/369381361) Enfore -Wmissing-prototypes
#pragma GCC diagnostic ignored "-Wmissing-prototypes"

using namespace bluetooth;

/* Define the GAP Connection Control Block */
@@ -117,7 +115,7 @@ static void gap_checks_con_flags(tGAP_CCB* p_ccb);
 * Returns          void
 *
 ******************************************************************************/
void gap_conn_init(void) {
static void gap_conn_init(void) {
  memset(&conn, 0, sizeof(tGAP_CONN));
  conn.reg_info.pL2CA_ConnectInd_Cb = gap_connect_ind;
  conn.reg_info.pL2CA_ConnectCfm_Cb = gap_connect_cfm;
@@ -1050,8 +1048,6 @@ static void gap_release_ccb(tGAP_CCB* p_ccb) {
  }
}

void gap_attr_db_init(void);

/*
 * This routine should not be called except once per stack invocation.
 */
+20 −0
Original line number Diff line number Diff line
/*
 * Copyright 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

/// GAP ATT database initialization.
void gap_attr_db_init(void);
+1 −3
Original line number Diff line number Diff line
@@ -21,13 +21,11 @@

#include <cstdint>

#include "stack/gap/gap_int.h"
#include "stack/include/gap_api.h"
#include "test/common/mock_functions.h"
#include "types/raw_address.h"

// TODO(b/369381361) Enfore -Wmissing-prototypes
#pragma GCC diagnostic ignored "-Wmissing-prototypes"

bool GAP_BleCancelReadPeerDevName(const RawAddress& /* peer_bda */) {
  inc_func_call_count(__func__);
  return false;
+0 −6
Original line number Diff line number Diff line
@@ -24,9 +24,6 @@
#include "test/common/mock_functions.h"
#include "types/raw_address.h"

// TODO(b/369381361) Enfore -Wmissing-prototypes
#pragma GCC diagnostic ignored "-Wmissing-prototypes"

const RawAddress* GAP_ConnGetRemoteAddr(uint16_t /* gap_handle */) {
  inc_func_call_count(__func__);
  return nullptr;
@@ -65,6 +62,3 @@ uint16_t GAP_ConnWriteData(uint16_t /* gap_handle */, BT_HDR* /* msg */) {
  return 0;
}
void GAP_Init(void) { inc_func_call_count(__func__); }
void gap_tx_complete_ind(uint16_t /* l2cap_cid */, uint16_t /* sdu_sent */) {
  inc_func_call_count(__func__);
}