Change in osmo-sgsn[master]: gprs_sndcp_comp_free: Replace ifelse with switch and better handling ...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Sat Apr 27 11:36:15 UTC 2019


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/13799


Change subject: gprs_sndcp_comp_free: Replace ifelse with switch and better handling of error
......................................................................

gprs_sndcp_comp_free: Replace ifelse with switch and better handling of error

gprs_sndcp_dcomp_term asserts if compclass is not
SNDCP_XID_DATA_COMPRESSION, so this way by checking in the caller too we
easily now if the unexpected value is in compclass or in algo.dcomp.

Change-Id: I4600e6a137f42f20fdf69637e4a9048b265c1748
---
M src/gprs/gprs_sndcp_comp.c
1 file changed, 9 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/99/13799/1

diff --git a/src/gprs/gprs_sndcp_comp.c b/src/gprs/gprs_sndcp_comp.c
index 0b4c67c..c71cc89 100644
--- a/src/gprs/gprs_sndcp_comp.c
+++ b/src/gprs/gprs_sndcp_comp.c
@@ -160,16 +160,23 @@
 
 	llist_for_each_entry(comp_entity, comp_entities, list) {
 		/* Free compression entity */
-		if (comp_entity->compclass == SNDCP_XID_PROTOCOL_COMPRESSION) {
+		switch (comp_entity->compclass) {
+		case SNDCP_XID_PROTOCOL_COMPRESSION:
 			LOGP(DSNDCP, LOGL_INFO,
 			     "Deleting header compression entity %d ...\n",
 			     comp_entity->entity);
 			gprs_sndcp_pcomp_term(comp_entity);
-		} else {
+			break;
+		case SNDCP_XID_DATA_COMPRESSION:
 			LOGP(DSNDCP, LOGL_INFO,
 			     "Deleting data compression entity %d ...\n",
 			     comp_entity->entity);
 			gprs_sndcp_dcomp_term(comp_entity);
+			break;
+		default:
+			LOGP(DSNDCP, LOGL_INFO,
+			     "Invalid compression class %d!\n", comp_entity->compclass);
+			OSMO_ASSERT(false);
 		}
 	}
 

-- 
To view, visit https://gerrit.osmocom.org/13799
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4600e6a137f42f20fdf69637e4a9048b265c1748
Gerrit-Change-Number: 13799
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190427/143f6793/attachment.htm>


More information about the gerrit-log mailing list