Skip to content

Commit fa68771

Browse files
bnpfeifeharshavardhana
authored andcommitted
Refactor case-statement to if-statement to avoid implicit fallback. (#310)
1 parent 4235b0e commit fa68771

File tree

1 file changed

+43
-30
lines changed

1 file changed

+43
-30
lines changed

core/rtw_mlme_ext.c

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,8 @@ static void _mgt_dispatcher(_adapter *padapter, struct mlme_handler *ptable, uni
672672

673673
void mgt_dispatcher(_adapter *padapter, union recv_frame *precv_frame)
674674
{
675+
int subtype;
676+
675677
int index;
676678
struct mlme_handler *ptable;
677679
#ifdef CONFIG_AP_MODE
@@ -751,50 +753,61 @@ void mgt_dispatcher(_adapter *padapter, union recv_frame *precv_frame)
751753
#endif
752754

753755
#ifdef CONFIG_AP_MODE
754-
switch (GetFrameSubType(pframe)) {
755-
case WIFI_AUTH:
756+
subtype = GetFrameSubType(pframe);
757+
if ((subtype == WIFI_AUTH) ||
758+
(subtype == WIFI_ASSOCREQ) ||
759+
(subtype == WIFI_REASSOCREQ))
760+
{
756761
if(check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE)
762+
{
757763
ptable->func = &OnAuth;
764+
}
758765
else
766+
{
759767
ptable->func = &OnAuthClient;
760-
//pass through
761-
case WIFI_ASSOCREQ:
762-
case WIFI_REASSOCREQ:
763-
_mgt_dispatcher(padapter, ptable, precv_frame);
764-
#ifdef CONFIG_HOSTAPD_MLME
765-
if(check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE)
766-
rtw_hostapd_mlme_rx(padapter, precv_frame);
767-
#endif
768-
break;
769-
case WIFI_PROBEREQ:
770-
if(check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE) {
771-
#ifdef CONFIG_HOSTAPD_MLME
772-
rtw_hostapd_mlme_rx(padapter, precv_frame);
773-
#else
768+
}
769+
770+
// fallthrough
771+
if ((subtype == WIFI_ASSOCREQ) ||
772+
(subtype == WIFI_REASSOCREQ))
773+
{
774774
_mgt_dispatcher(padapter, ptable, precv_frame);
775-
#endif
776-
} else
775+
776+
if(check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE)
777+
{
778+
rtw_hostapd_mlme_rx(padapter, precv_frame);
779+
}
780+
}
781+
}
782+
else if (subtype == WIFI_PROBEREQ)
783+
{
784+
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE) {
785+
#ifdef CONFIG_HOSTAPD_MLME
786+
rtw_hostapd_mlme_rx(padapter, precv_frame);
787+
#else
788+
_mgt_dispatcher(padapter, ptable, precv_frame);
789+
#endif
790+
}
791+
else
792+
{
777793
_mgt_dispatcher(padapter, ptable, precv_frame);
778-
break;
779-
case WIFI_BEACON:
780-
_mgt_dispatcher(padapter, ptable, precv_frame);
781-
break;
782-
case WIFI_ACTION:
783-
//if(check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE)
794+
}
795+
} else if (subtype == WIFI_BEACON ||
796+
subtype == WIFI_ACTION)
797+
{
784798
_mgt_dispatcher(padapter, ptable, precv_frame);
785-
break;
786-
default:
799+
}
800+
else
801+
{
787802
_mgt_dispatcher(padapter, ptable, precv_frame);
788803
if(check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE)
804+
{
789805
rtw_hostapd_mlme_rx(padapter, precv_frame);
790-
break;
806+
}
791807
}
792808
#else
793-
794809
_mgt_dispatcher(padapter, ptable, precv_frame);
795-
796810
#endif
797-
798811
}
799812

800813
#ifdef CONFIG_P2P

0 commit comments

Comments
 (0)