From 25998ddcc56ff8c11bf7d2e19e672e3f1d4f034f Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Fri, 23 Oct 2020 13:11:02 +0200 Subject: process_ms_ctx_status: refactor to avoid code duplication Change-Id: I1d1a1284c1563b3a5598e79d8ffd544288de4d62 --- src/sgsn/gprs_gmm.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'src/sgsn') diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c index bf72cd6fe..0ad600376 100644 --- a/src/sgsn/gprs_gmm.c +++ b/src/sgsn/gprs_gmm.c @@ -1524,21 +1524,16 @@ static void process_ms_ctx_status(struct sgsn_mm_ctx *mmctx, * being in state PDP-INACTIVE. */ llist_for_each_entry_safe(pdp, pdp2, &mmctx->pdp_list, list) { - if (pdp->nsapi < 8) { - if (!(pdp_status[0] & (1 << pdp->nsapi))) { - LOGMMCTXP(LOGL_NOTICE, mmctx, "Dropping PDP context for NSAPI=%u " - "due to PDP CTX STATUS IE= 0x%02x%02x\n", - pdp->nsapi, pdp_status[1], pdp_status[0]); - sgsn_delete_pdp_ctx(pdp); - } - } else { - if (!(pdp_status[1] & (1 << (pdp->nsapi - 8)))) { - LOGMMCTXP(LOGL_NOTICE, mmctx, "Dropping PDP context for NSAPI=%u " - "due to PDP CTX STATUS IE= 0x%02x%02x\n", - pdp->nsapi, pdp_status[1], pdp_status[0]); - sgsn_delete_pdp_ctx(pdp); - } - } + bool inactive = (pdp->nsapi < 8) ? + !(pdp_status[0] & (1 << pdp->nsapi)) : + !(pdp_status[1] & (1 << (pdp->nsapi - 8))); + if (!inactive) + continue; + + LOGMMCTXP(LOGL_NOTICE, mmctx, "Dropping PDP context for NSAPI=%u " + "due to PDP CTX STATUS IE=0x%02x%02x\n", + pdp->nsapi, pdp_status[1], pdp_status[0]); + sgsn_delete_pdp_ctx(pdp); } } -- cgit v1.2.3