From 34f61af3d041ee38262095e630758652e16b93fe Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 26 Apr 2021 18:02:52 +0200 Subject: 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 --- src/gprs_rlcmac_sched.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/gprs_rlcmac_sched.cpp') diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp index ab7e57ec..85c9be81 100644 --- a/src/gprs_rlcmac_sched.cpp +++ b/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) -- cgit v1.2.3