diff --git a/subsys/bluetooth/host/buf.c b/subsys/bluetooth/host/buf.c index b6c325f9b6f..9d87a6390e2 100644 --- a/subsys/bluetooth/host/buf.c +++ b/subsys/bluetooth/host/buf.c @@ -89,36 +89,28 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout) struct net_buf *bt_buf_get_evt(uint8_t evt, bool discardable, k_timeout_t timeout) { + struct net_buf *buf; + switch (evt) { #if defined(CONFIG_BT_CONN) || defined(CONFIG_BT_ISO) case BT_HCI_EVT_NUM_COMPLETED_PACKETS: - { - struct net_buf *buf; - - buf = net_buf_alloc(&num_complete_pool, timeout); - if (buf) { - net_buf_reserve(buf, BT_BUF_RESERVE); - bt_buf_set_type(buf, BT_BUF_EVT); - } - - return buf; - } + buf = net_buf_alloc(&num_complete_pool, timeout); + break; #endif /* CONFIG_BT_CONN || CONFIG_BT_ISO */ default: if (discardable) { - struct net_buf *buf; - buf = net_buf_alloc(&discardable_pool, timeout); - if (buf) { - net_buf_reserve(buf, BT_BUF_RESERVE); - bt_buf_set_type(buf, BT_BUF_EVT); - } - - return buf; + } else { + return bt_buf_get_rx(BT_BUF_EVT, timeout); } - - return bt_buf_get_rx(BT_BUF_EVT, timeout); } + + if (buf) { + net_buf_reserve(buf, BT_BUF_RESERVE); + bt_buf_set_type(buf, BT_BUF_EVT); + } + + return buf; } #ifdef ZTEST_UNITTEST