Skip to content

Commit c21e613

Browse files
PavelVPVkartben
authored andcommitted
bluetooth: host: mark internal functions and variables as static
Mark functions and variables as static when not used outside a unit. Signed-off-by: Pavel Vasilyev <[email protected]>
1 parent c846939 commit c21e613

File tree

8 files changed

+36
-36
lines changed

8 files changed

+36
-36
lines changed

subsys/bluetooth/host/adv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ static void le_adv_stop_free_conn(const struct bt_le_ext_adv *adv, uint8_t statu
888888
}
889889
}
890890

891-
int bt_le_adv_start_legacy(struct bt_le_ext_adv *adv,
891+
static int bt_le_adv_start_legacy(struct bt_le_ext_adv *adv,
892892
const struct bt_le_adv_param *param,
893893
const struct bt_data *ad, size_t ad_len,
894894
const struct bt_data *sd, size_t sd_len)

subsys/bluetooth/host/att.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ NET_BUF_POOL_DEFINE(prep_pool, CONFIG_BT_ATT_PREPARE_COUNT, BT_ATT_BUF_SIZE,
8080
sizeof(struct bt_attr_data), NULL);
8181
#endif /* CONFIG_BT_ATT_PREPARE_COUNT */
8282

83-
K_MEM_SLAB_DEFINE(req_slab, sizeof(struct bt_att_req),
83+
K_MEM_SLAB_DEFINE_STATIC(req_slab, sizeof(struct bt_att_req),
8484
CONFIG_BT_ATT_TX_COUNT, __alignof__(struct bt_att_req));
8585

8686
enum {
@@ -171,9 +171,9 @@ struct bt_att {
171171
#endif /* CONFIG_BT_EATT */
172172
};
173173

174-
K_MEM_SLAB_DEFINE(att_slab, sizeof(struct bt_att),
174+
K_MEM_SLAB_DEFINE_STATIC(att_slab, sizeof(struct bt_att),
175175
CONFIG_BT_MAX_CONN, __alignof__(struct bt_att));
176-
K_MEM_SLAB_DEFINE(chan_slab, sizeof(struct bt_att_chan),
176+
K_MEM_SLAB_DEFINE_STATIC(chan_slab, sizeof(struct bt_att_chan),
177177
CONFIG_BT_MAX_CONN * ATT_CHAN_MAX,
178178
__alignof__(struct bt_att_chan));
179179
static struct bt_att_req cancel;
@@ -194,7 +194,7 @@ static k_tid_t att_handle_rsp_thread;
194194

195195
static struct bt_att_tx_meta_data tx_meta_data_storage[CONFIG_BT_ATT_TX_COUNT];
196196

197-
struct bt_att_tx_meta_data *bt_att_get_tx_meta_data(const struct net_buf *buf);
197+
static struct bt_att_tx_meta_data *bt_att_get_tx_meta_data(const struct net_buf *buf);
198198
static void att_on_sent_cb(struct bt_att_tx_meta_data *meta);
199199

200200
#if defined(CONFIG_BT_ATT_ERR_TO_STR)
@@ -289,7 +289,7 @@ NET_BUF_POOL_DEFINE(att_pool, CONFIG_BT_ATT_TX_COUNT,
289289
BT_L2CAP_SDU_BUF_SIZE(BT_ATT_BUF_SIZE),
290290
CONFIG_BT_CONN_TX_USER_DATA_SIZE, att_tx_destroy);
291291

292-
struct bt_att_tx_meta_data *bt_att_get_tx_meta_data(const struct net_buf *buf)
292+
static struct bt_att_tx_meta_data *bt_att_get_tx_meta_data(const struct net_buf *buf)
293293
{
294294
__ASSERT_NO_MSG(net_buf_pool_get(buf->pool_id) == &att_pool);
295295

@@ -304,7 +304,7 @@ static int bt_att_chan_send(struct bt_att_chan *chan, struct net_buf *buf);
304304
static void att_chan_mtu_updated(struct bt_att_chan *updated_chan);
305305
static void bt_att_disconnected(struct bt_l2cap_chan *chan);
306306

307-
struct net_buf *bt_att_create_rsp_pdu(struct bt_att_chan *chan, uint8_t op);
307+
static struct net_buf *bt_att_create_rsp_pdu(struct bt_att_chan *chan, uint8_t op);
308308

309309
static void att_disconnect(struct bt_att_chan *chan)
310310
{
@@ -3064,7 +3064,7 @@ struct net_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op, size_t len)
30643064
return NULL;
30653065
}
30663066

3067-
struct net_buf *bt_att_create_rsp_pdu(struct bt_att_chan *chan, uint8_t op)
3067+
static struct net_buf *bt_att_create_rsp_pdu(struct bt_att_chan *chan, uint8_t op)
30683068
{
30693069
size_t headroom;
30703070
struct bt_att_hdr *hdr;

subsys/bluetooth/host/conn.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static struct bt_conn sco_conns[CONFIG_BT_MAX_SCO_CONN];
137137
#endif /* CONFIG_BT_CONN */
138138

139139
#if defined(CONFIG_BT_CONN_TX)
140-
void frag_destroy(struct net_buf *buf);
140+
static void frag_destroy(struct net_buf *buf);
141141

142142
/* Storage for fragments (views) into the upper layers' PDUs. */
143143
/* TODO: remove user-data requirements */
@@ -147,14 +147,14 @@ NET_BUF_POOL_FIXED_DEFINE(fragments, CONFIG_BT_CONN_FRAG_COUNT, 0,
147147
struct frag_md {
148148
struct bt_buf_view_meta view_meta;
149149
};
150-
struct frag_md frag_md_pool[CONFIG_BT_CONN_FRAG_COUNT];
150+
static struct frag_md frag_md_pool[CONFIG_BT_CONN_FRAG_COUNT];
151151

152-
struct frag_md *get_frag_md(struct net_buf *fragment)
152+
static struct frag_md *get_frag_md(struct net_buf *fragment)
153153
{
154154
return &frag_md_pool[net_buf_id(fragment)];
155155
}
156156

157-
void frag_destroy(struct net_buf *frag)
157+
static void frag_destroy(struct net_buf *frag)
158158
{
159159
/* allow next view to be allocated (and unlock the parent buf) */
160160
bt_buf_destroy_view(frag, &get_frag_md(frag)->view_meta);
@@ -935,7 +935,7 @@ __maybe_unused static bool dont_have_methods(struct bt_conn *conn)
935935
(conn->has_data == NULL);
936936
}
937937

938-
struct bt_conn *get_conn_ready(void)
938+
static struct bt_conn *get_conn_ready(void)
939939
{
940940
struct bt_conn *conn, *tmp;
941941
sys_snode_t *prev = NULL;
@@ -1125,8 +1125,8 @@ static void process_unack_tx(struct bt_conn *conn)
11251125
}
11261126
}
11271127

1128-
struct bt_conn *conn_lookup_handle(struct bt_conn *conns, size_t size,
1129-
uint16_t handle)
1128+
static struct bt_conn *conn_lookup_handle(struct bt_conn *conns, size_t size,
1129+
uint16_t handle)
11301130
{
11311131
int i;
11321132

subsys/bluetooth/host/gatt.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,19 @@ static bool is_host_managed_ccc(const struct bt_gatt_attr *attr)
11171117
return (attr->write == bt_gatt_attr_write_ccc);
11181118
}
11191119

1120+
#if defined(CONFIG_BT_SETTINGS)
1121+
static int bt_gatt_store_ccc(uint8_t id, const bt_addr_le_t *addr);
1122+
#else
1123+
static int bt_gatt_store_ccc(uint8_t id, const bt_addr_le_t *addr)
1124+
{
1125+
/* This function shall never be used without CONFIG_BT_SETTINGS. */
1126+
__ASSERT_NO_MSG(false);
1127+
1128+
return -ENOTSUP;
1129+
}
1130+
#endif /* CONFIG_BT_SETTINGS */
1131+
1132+
11201133
#if defined(CONFIG_BT_SETTINGS) && defined(CONFIG_BT_SMP)
11211134
/** Struct used to store both the id and the random address of a device when replacing
11221135
* random addresses in the ccc attribute's cfg array with the device's id address after
@@ -6153,7 +6166,7 @@ static uint8_t ccc_save(const struct bt_gatt_attr *attr, uint16_t handle,
61536166
return BT_GATT_ITER_CONTINUE;
61546167
}
61556168

6156-
int bt_gatt_store_ccc(uint8_t id, const bt_addr_le_t *addr)
6169+
static int bt_gatt_store_ccc(uint8_t id, const bt_addr_le_t *addr)
61576170
{
61586171
struct ccc_save save;
61596172
size_t len;

subsys/bluetooth/host/gatt_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ void bt_gatt_disconnected(struct bt_conn *conn);
4343

4444
bool bt_gatt_change_aware(struct bt_conn *conn, bool req);
4545

46-
int bt_gatt_store_ccc(uint8_t id, const bt_addr_le_t *addr);
47-
4846
int bt_gatt_clear(uint8_t id, const bt_addr_le_t *addr);
4947

5048
#if defined(CONFIG_BT_GATT_CLIENT)

subsys/bluetooth/host/id.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ struct bt_id_conflict {
953953
* must refuse bonds that conflict in the resolve list. Notably, this prevents
954954
* multiple local identities to bond with the same remote identity.
955955
*/
956-
void find_rl_conflict(struct bt_keys *resident, void *user_data)
956+
static void find_rl_conflict(struct bt_keys *resident, void *user_data)
957957
{
958958
struct bt_id_conflict *conflict = user_data;
959959
bool addr_conflict;

subsys/bluetooth/host/l2cap.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ const char *bt_l2cap_chan_state_str(bt_l2cap_chan_state_t state)
200200

201201
#if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL)
202202
#if defined(CONFIG_BT_L2CAP_LOG_LEVEL_DBG)
203-
void bt_l2cap_chan_set_state_debug(struct bt_l2cap_chan *chan,
203+
#define bt_l2cap_chan_set_state(_chan, _state) \
204+
bt_l2cap_chan_set_state_debug(_chan, _state, __func__, __LINE__)
205+
206+
static void bt_l2cap_chan_set_state_debug(struct bt_l2cap_chan *chan,
204207
bt_l2cap_chan_state_t state,
205208
const char *func, int line)
206209
{
@@ -244,7 +247,7 @@ void bt_l2cap_chan_set_state_debug(struct bt_l2cap_chan *chan,
244247
le_chan->state = state;
245248
}
246249
#else
247-
void bt_l2cap_chan_set_state(struct bt_l2cap_chan *chan,
250+
static void bt_l2cap_chan_set_state(struct bt_l2cap_chan *chan,
248251
bt_l2cap_chan_state_t state)
249252
{
250253
BT_L2CAP_LE_CHAN(chan)->state = state;
@@ -254,7 +257,7 @@ void bt_l2cap_chan_set_state(struct bt_l2cap_chan *chan,
254257

255258
static void cancel_data_ready(struct bt_l2cap_le_chan *lechan);
256259
static bool chan_has_data(struct bt_l2cap_le_chan *lechan);
257-
void bt_l2cap_chan_del(struct bt_l2cap_chan *chan)
260+
static void bt_l2cap_chan_del(struct bt_l2cap_chan *chan)
258261
{
259262
const struct bt_l2cap_chan_ops *ops = chan->ops;
260263
struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan);

subsys/bluetooth/host/l2cap_internal.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,22 +190,8 @@ void bt_l2cap_chan_add(struct bt_conn *conn, struct bt_l2cap_chan *chan,
190190
/* Remove channel from the connection */
191191
void bt_l2cap_chan_remove(struct bt_conn *conn, struct bt_l2cap_chan *chan);
192192

193-
/* Delete channel */
194-
void bt_l2cap_chan_del(struct bt_l2cap_chan *chan);
195-
196193
const char *bt_l2cap_chan_state_str(bt_l2cap_chan_state_t state);
197194

198-
#if defined(CONFIG_BT_L2CAP_LOG_LEVEL_DBG)
199-
void bt_l2cap_chan_set_state_debug(struct bt_l2cap_chan *chan,
200-
bt_l2cap_chan_state_t state,
201-
const char *func, int line);
202-
#define bt_l2cap_chan_set_state(_chan, _state) \
203-
bt_l2cap_chan_set_state_debug(_chan, _state, __func__, __LINE__)
204-
#else
205-
void bt_l2cap_chan_set_state(struct bt_l2cap_chan *chan,
206-
bt_l2cap_chan_state_t state);
207-
#endif /* CONFIG_BT_L2CAP_LOG_LEVEL_DBG */
208-
209195
/*
210196
* Notify L2CAP channels of a change in encryption state passing additionally
211197
* HCI status of performed security procedure.

0 commit comments

Comments
 (0)