Neels Hofmeyr has uploaded this change for review. ( 
https://gerrit.osmocom.org/12158


Change subject: gsm48_mi_to_string(): style tweak: break on error first
......................................................................

gsm48_mi_to_string(): style tweak: break on error first

In the TMSI case, use early-exit paradigm. It's debatable which way would be
early exit, since the success case is also a 'return', but early-exit in the
sense of: handle error paths in sub-clauses, with the success path below.

Change-Id: Ic76bc5e84ad1278fa3b2db5f5e28cadf1d90a343
---
M src/gsm/gsm48.c
1 file changed, 6 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/58/12158/1

diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index 2d4b840..6568523 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -659,11 +659,12 @@
        switch (mi_type) {
        case GSM_MI_TYPE_TMSI:
                /* Table 10.5.4.3, reverse generate_mid_from_tmsi */
-               if (mi_len == GSM48_TMSI_LEN && mi[0] == (0xf0 | 
GSM_MI_TYPE_TMSI)) {
-                       tmsi = osmo_load32be(&mi[1]);
-                       return snprintf(string, str_len, "%"PRIu32, tmsi);
-               }
-               break;
+               if (mi_len != GSM48_TMSI_LEN
+                   || mi[0] != (0xf0 | GSM_MI_TYPE_TMSI))
+                       break;
+               tmsi = osmo_load32be(&mi[1]);
+               return snprintf(string, str_len, "%"PRIu32, tmsi);
+
        case GSM_MI_TYPE_IMSI:
        case GSM_MI_TYPE_IMEI:
        case GSM_MI_TYPE_IMEISV:

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic76bc5e84ad1278fa3b2db5f5e28cadf1d90a343
Gerrit-Change-Number: 12158
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <[email protected]>

Reply via email to