<p>Neels Hofmeyr has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12158">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gsm48_mi_to_string(): style tweak: break on error first<br><br>In the TMSI case, use early-exit paradigm. It's debatable which way would be<br>early exit, since the success case is also a 'return', but early-exit in the<br>sense of: handle error paths in sub-clauses, with the success path below.<br><br>Change-Id: Ic76bc5e84ad1278fa3b2db5f5e28cadf1d90a343<br>---<br>M src/gsm/gsm48.c<br>1 file changed, 6 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/58/12158/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c</span><br><span>index 2d4b840..6568523 100644</span><br><span>--- a/src/gsm/gsm48.c</span><br><span>+++ b/src/gsm/gsm48.c</span><br><span>@@ -659,11 +659,12 @@</span><br><span>        switch (mi_type) {</span><br><span>   case GSM_MI_TYPE_TMSI:</span><br><span>               /* Table 10.5.4.3, reverse generate_mid_from_tmsi */</span><br><span style="color: hsl(0, 100%, 40%);">-            if (mi_len == GSM48_TMSI_LEN && mi[0] == (0xf0 | GSM_MI_TYPE_TMSI)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                   tmsi = osmo_load32be(&mi[1]);</span><br><span style="color: hsl(0, 100%, 40%);">-                       return snprintf(string, str_len, "%"PRIu32, tmsi);</span><br><span style="color: hsl(0, 100%, 40%);">-            }</span><br><span style="color: hsl(0, 100%, 40%);">-               break;</span><br><span style="color: hsl(120, 100%, 40%);">+                if (mi_len != GSM48_TMSI_LEN</span><br><span style="color: hsl(120, 100%, 40%);">+              || mi[0] != (0xf0 | GSM_MI_TYPE_TMSI))</span><br><span style="color: hsl(120, 100%, 40%);">+                    break;</span><br><span style="color: hsl(120, 100%, 40%);">+                tmsi = osmo_load32be(&mi[1]);</span><br><span style="color: hsl(120, 100%, 40%);">+             return snprintf(string, str_len, "%"PRIu32, tmsi);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>       case GSM_MI_TYPE_IMSI:</span><br><span>       case GSM_MI_TYPE_IMEI:</span><br><span>       case GSM_MI_TYPE_IMEISV:</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12158">change 12158</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12158"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ic76bc5e84ad1278fa3b2db5f5e28cadf1d90a343 </div>
<div style="display:none"> Gerrit-Change-Number: 12158 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>