sched: Simplify else-if condition

The code path running into first call of "create_packet_access_reject()"
is a superset condition of the second one, so the second one will never
be hit.

As a result first, this block:
"""
else if (tbf == tbfs->ul_ass && tbf->direction == GPRS_RLCMAC_DL_TBF)
    if (tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
        msg = tbfs->ul_ass->create_packet_access_reject();
    else
        msg = tbfs->ul_ass->create_ul_ass(fn, ts);
"""

Can be simplified into:
"""
else if (tbf == tbfs->ul_ass && tbf->direction == GPRS_RLCMAC_DL_TBF &&
	     !tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
        msg = tbfs->ul_ass->create_ul_ass(fn, ts);
"""

Next, one can see that previous condition still forces
!tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ) to be always true
if we ever reach that code, so it can be dropped.

Change-Id: I62e2255e28fc4f43fe0a31259ebf18ad00e7e357
changes/09/23909/1
Pau Espin 2 years ago
parent 2ab840a1fa
commit 34f61af3d0
  1. 8
      src/gprs_rlcmac_sched.cpp

@ -175,12 +175,8 @@ static struct msgb *sched_select_ctrl_msg(struct gprs_rlcmac_pdch *pdch, uint32_
*/
if (tbf == tbfs->ul_ass && tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
msg = tbfs->ul_ass->create_packet_access_reject();
else if (tbf == tbfs->ul_ass && tbf->direction ==
GPRS_RLCMAC_DL_TBF)
if (tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
msg = tbfs->ul_ass->create_packet_access_reject();
else
msg = tbfs->ul_ass->create_ul_ass(fn, ts);
else if (tbf == tbfs->ul_ass && tbf->direction == GPRS_RLCMAC_DL_TBF)
msg = tbfs->ul_ass->create_ul_ass(fn, ts);
else if (tbf == tbfs->dl_ass && tbf->direction == GPRS_RLCMAC_UL_TBF)
msg = tbfs->dl_ass->create_dl_ass(fn, ts);
else if (tbf == tbfs->ul_ack)

Loading…
Cancel
Save