From 4cf889a5f0f9adb67f7f206dccda671e65dd98f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Wed, 20 Oct 2021 19:52:43 +0200 Subject: [PATCH] spa: bluez: use switch Use a switch statement instead of an `if` because it is more suitable in the presence of `#ifdef`s, it avoids potential unnecessary extra checks. --- spa/plugins/bluez5/backend-native.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/spa/plugins/bluez5/backend-native.c b/spa/plugins/bluez5/backend-native.c index d163e0626..767bcb822 100644 --- a/spa/plugins/bluez5/backend-native.c +++ b/spa/plugins/bluez5/backend-native.c @@ -1042,18 +1042,26 @@ static void rfcomm_event(struct spa_source *source) buf[len] = 0; spa_log_debug(backend->log, "RFCOMM << %s", buf); + switch (rfcomm->profile) { #ifdef HAVE_BLUEZ_5_BACKEND_HSP_NATIVE - if (rfcomm->profile == SPA_BT_PROFILE_HSP_HS) + case SPA_BT_PROFILE_HSP_HS: res = rfcomm_hsp_ag(source, buf); - else if (rfcomm->profile == SPA_BT_PROFILE_HSP_AG) + break; + case SPA_BT_PROFILE_HSP_AG: res = rfcomm_hsp_hs(source, buf); + break; #endif #ifdef HAVE_BLUEZ_5_BACKEND_HFP_NATIVE - if (rfcomm->profile == SPA_BT_PROFILE_HFP_HF) + case SPA_BT_PROFILE_HFP_HF: res = rfcomm_hfp_ag(source, buf); - else if (rfcomm->profile == SPA_BT_PROFILE_HFP_AG) + break; + case SPA_BT_PROFILE_HFP_AG: res = rfcomm_hfp_hf(source, buf); + break; #endif + default: + break; + } if (!res) { spa_log_debug(backend->log, "RFCOMM receive unsupported command: %s", buf);