Skip to content

Commit f3cda7d

Browse files
alwa-nordiccvinayak
authored andcommitted
Bluetooth: Host: Refactor bt_buf_get_evt
This is purely a syntactical refactor. Signed-off-by: Aleksander Wasaznik <[email protected]> (cherry picked from commit 9426309) Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 180b51d commit f3cda7d

File tree

1 file changed

+12
-20
lines changed
  • subsys/bluetooth/host

1 file changed

+12
-20
lines changed

subsys/bluetooth/host/buf.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,36 +89,28 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
8989
struct net_buf *bt_buf_get_evt(uint8_t evt, bool discardable,
9090
k_timeout_t timeout)
9191
{
92+
struct net_buf *buf;
93+
9294
switch (evt) {
9395
#if defined(CONFIG_BT_CONN) || defined(CONFIG_BT_ISO)
9496
case BT_HCI_EVT_NUM_COMPLETED_PACKETS:
95-
{
96-
struct net_buf *buf;
97-
98-
buf = net_buf_alloc(&num_complete_pool, timeout);
99-
if (buf) {
100-
net_buf_reserve(buf, BT_BUF_RESERVE);
101-
bt_buf_set_type(buf, BT_BUF_EVT);
102-
}
103-
104-
return buf;
105-
}
97+
buf = net_buf_alloc(&num_complete_pool, timeout);
98+
break;
10699
#endif /* CONFIG_BT_CONN || CONFIG_BT_ISO */
107100
default:
108101
if (discardable) {
109-
struct net_buf *buf;
110-
111102
buf = net_buf_alloc(&discardable_pool, timeout);
112-
if (buf) {
113-
net_buf_reserve(buf, BT_BUF_RESERVE);
114-
bt_buf_set_type(buf, BT_BUF_EVT);
115-
}
116-
117-
return buf;
103+
} else {
104+
return bt_buf_get_rx(BT_BUF_EVT, timeout);
118105
}
106+
}
119107

120-
return bt_buf_get_rx(BT_BUF_EVT, timeout);
108+
if (buf) {
109+
net_buf_reserve(buf, BT_BUF_RESERVE);
110+
bt_buf_set_type(buf, BT_BUF_EVT);
121111
}
112+
113+
return buf;
122114
}
123115

124116
#ifdef ZTEST_UNITTEST

0 commit comments

Comments
 (0)