bluetooth: host: conn.c fix Constant variable guards dead code issue

This commit replaces the assignment of IS_ENABLED(x) macros to
various variables with direct condition checking. This should fix the
coverity issue and also promotes more uniformity in code.

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
This commit is contained in:
Jilay Pandya 2024-12-06 18:28:48 +01:00 committed by Benjamin Cabé
commit 1d7826c2ad

View file

@ -1721,15 +1721,12 @@ static bool can_initiate_feature_exchange(struct bt_conn *conn)
* controller, as we know at compile time whether it supports or not
* peripheral feature exchange.
*/
bool onboard_controller = IS_ENABLED(CONFIG_HAS_BT_CTLR);
bool supports_peripheral_feature_exchange = IS_ENABLED(CONFIG_BT_CTLR_PER_INIT_FEAT_XCHG);
bool is_central = IS_ENABLED(CONFIG_BT_CENTRAL) && conn->role == BT_HCI_ROLE_CENTRAL;
if (is_central) {
if (IS_ENABLED(CONFIG_BT_CENTRAL) && (conn->role == BT_HCI_ROLE_CENTRAL)) {
return true;
}
if (onboard_controller && supports_peripheral_feature_exchange) {
if (IS_ENABLED(CONFIG_HAS_BT_CTLR) && IS_ENABLED(CONFIG_BT_CTLR_PER_INIT_FEAT_XCHG)) {
return true;
}