<p style="white-space: pre-wrap; word-wrap: break-word;">what, I accidentally commented on an old patch set? but I think the comments still apply.</p><p>Patch set 5:<span style="border-radius: 3px; display: inline-block; margin: 0 2px; padding: 4px;background-color: #ffd4d4;">Code-Review -1</span></p><p><a href="https://gerrit.osmocom.org/12020">View Change</a></p><p>13 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/#/c/12020/4/include/osmocom/gsm/gsm0808_utils.h">File include/osmocom/gsm/gsm0808_utils.h:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/include/osmocom/gsm/gsm0808_utils.h@86">Patch Set #4, Line 86:</a> <code style="font-family:monospace,monospace"> </code></p><p style="white-space: pre-wrap; word-wrap: break-word;">(ws)</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/include/osmocom/gsm/gsm0808_utils.h@87">Patch Set #4, Line 87:</a> <code style="font-family:monospace,monospace">int gsm0808_dec_gcr(struct gsm29205_gcr *g, struct tlv_parsed *tp);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">constify the tp arg plz.</p><p style="white-space: pre-wrap; word-wrap: break-word;">kind of weird that the function name says 0808 and the struct says 29205. (edit) I think I get it now, this is the GCR 0808 message, and the IE is defined in 29.205?</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/#/c/12020/4/src/gsm/gsm0808_utils.c">File src/gsm/gsm0808_utils.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/src/gsm/gsm0808_utils.c@485">Patch Set #4, Line 485:</a> <code style="font-family:monospace,monospace">/*! Create BSSMAP Global Call Reference, 3GPP TS 48.008 ยง3.2.2.115</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">always end the summary with a '.' for doxygen</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/src/gsm/gsm0808_utils.c@493">Patch Set #4, Line 493:</a> <code style="font-family:monospace,monospace">     len = msgb_v_put(msg, GSM0808_IE_GLOBAL_CALL_REF);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">msbg_v_put works, but the name indicates that you are putting a V, a value, instead of this T, a tag.<br>I see in the rest of the file that we often use mgb_v_put() to add the message discriminator.<br>Which is actually accurate, because it is the start of the 0808 "value".</p><p style="white-space: pre-wrap; word-wrap: break-word;">But for IE tags, let's use something with 't' in the name. There must be other places in this file that set the length after writing?</p><p style="white-space: pre-wrap; word-wrap: break-word;">hmm, looking around, we should have a msgb_tl_put() function for these situations but it doesn't exist, and it seems code is working around variable-length values in different ways.</p><p style="white-space: pre-wrap; word-wrap: break-word;">unless you find something nicer still, maybe rather use msgb_put_u8() instead of msgb_v_put(). Same thing but less misleading name.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/src/gsm/gsm0808_utils.c@499">Patch Set #4, Line 499:</a> <code style="font-family:monospace,monospace">   if (enc) {</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">the general exit-early style would be 'if (!enc) return 0' here instead.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/src/gsm/gsm0808_utils.c@500">Patch Set #4, Line 500:</a> <code style="font-family:monospace,monospace">         len[0] = enc;</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">(I'd prefer '*len = enc' since it isn't an array)</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/src/gsm/gsm0808_utils.c@507">Patch Set #4, Line 507:</a> <code style="font-family:monospace,monospace">/*! Decode BSSMAP Global Call Reference, 3GPP TS 29.205 Table B 2.1.9.1</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">'.'</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/src/gsm/gsm0808_utils.c@518">Patch Set #4, Line 518:</a> <code style="font-family:monospace,monospace">      return 2 + gsm29205_dec_gcr(gcr, buf, TLVP_LEN(tp, GSM0808_IE_GLOBAL_CALL_REF));</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">are you sure gsm29205_dec_gcr can never and will never in the future return negative error / zero?</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/#/c/12020/4/tests/gsm0808/gsm0808_test.c">File tests/gsm0808/gsm0808_test.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/tests/gsm0808/gsm0808_test.c@582">Patch Set #4, Line 582:</a> <code style="font-family:monospace,monospace">            0x4e, 0x4e, 0x4e, 0x4e, 0x4e /* .cr - Call. Ref. */</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">nicer to use different byte value in each position, to ensure correct ordering. wait, didn't I say that before?</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/tests/gsm0808/gsm0808_test.c@586">Patch Set #4, Line 586:</a> <code style="font-family:monospace,monospace">        struct gsm29205_gcr g = { .net_len = 3, .node = 0xDEAD }, p = { 0 };</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">also looks familiar: just write 'p = {}'</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/tests/gsm0808/gsm0808_test.c@594">Patch Set #4, Line 594:</a> <code style="font-family:monospace,monospace">  memset(g.net, 'O', g.net_len);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">nicer to use differing bytes</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/tests/gsm0808/gsm0808_test.c@600">Patch Set #4, Line 600:</a> <code style="font-family:monospace,monospace">    if (!msgb_cmp_data_print(msg, res, ARRAY_SIZE(res)))</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">"!foo_cmp(a, b)" in C convention means "a == b". If you want to use bool return value, don't call it 'cmp'!</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12020/4/tests/gsm0808/gsm0808_test.c@605">Patch Set #4, Line 605:</a> <code style="font-family:monospace,monospace">               printf("parsing failed: %s [%s]\n", strerror(-rc), msgb_hexdump(msg));</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">abort()?</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.osmocom.org/12020">change 12020</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/12020"/><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: comment </div>
<div style="display:none"> Gerrit-Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d </div>
<div style="display:none"> Gerrit-Change-Number: 12020 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: Max <msuraev@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Max <msuraev@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Pau Espin Pedrol <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Comment-Date: Fri, 30 Nov 2018 15:49:25 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-HasLabels: Yes </div>