Change in libosmo-sccp[master]: sccp: Convert ifelse to switch statement

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/.

pespin gerrit-no-reply at lists.osmocom.org
Fri Jan 17 15:14:13 UTC 2020


pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/16900 )

Change subject: sccp: Convert ifelse to switch statement
......................................................................

sccp: Convert ifelse to switch statement

Change-Id: I1f3129f5b949fc70913e8103ef17c696002b8ed2
---
M src/sccp2sua.c
1 file changed, 8 insertions(+), 7 deletions(-)

Approvals:
  Jenkins Builder: Verified
  osmith: Looks good to me, approved
  laforge: Looks good to me, but someone else must approve



diff --git a/src/sccp2sua.c b/src/sccp2sua.c
index 1106888..e68662f 100644
--- a/src/sccp2sua.c
+++ b/src/sccp2sua.c
@@ -712,13 +712,14 @@
 	oneopt = opt_start;
 
 	while (oneopt < msg->tail) {
-		uint8_t opt_type = oneopt[0];
+		enum sccp_parameter_name_codes opt_type = oneopt[0];
+		uint8_t opt_len;
+		uint16_t opt_len16;
 
-		if (opt_type == SCCP_PNC_END_OF_OPTIONAL)
+		switch (opt_type) {
+		case SCCP_PNC_END_OF_OPTIONAL:
 			return xua;
-
-		if (opt_type == SCCP_PNC_LONG_DATA) {
-			uint16_t opt_len16;
+		case SCCP_PNC_LONG_DATA:
 			/* two byte length field */
 			if (oneopt + 2 > msg->tail)
 				return NULL;
@@ -727,8 +728,8 @@
 				return NULL;
 			xua_msg_add_sccp_opt(xua, opt_type, opt_len16, oneopt+3);
 			oneopt += 3 + opt_len16;
-		} else {
-			uint8_t opt_len;
+			break;
+		default:
 			/* one byte length field */
 			if (oneopt + 1 > msg->tail)
 				return NULL;

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/16900
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I1f3129f5b949fc70913e8103ef17c696002b8ed2
Gerrit-Change-Number: 16900
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200117/639b6b4b/attachment.htm>


More information about the gerrit-log mailing list