<p>Patch set 7:<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/12492">View Change</a></p><p>5 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/#/c/12492/7/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/12492/7/src/gsm/gsm0808_utils.c@614">Patch Set #7, Line 614:</a> <code style="font-family:monospace,monospace"> *  \returns string representation of LCLS or NULL on error */</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">missing crucial information: a *talloc* allocated string that the caller must free.</p><p style="white-space: pre-wrap; word-wrap: break-word;">I've done this type of thing before, and most of the time it turns out to be impractical.<br>Instead I'd suggest returning a static string buffer that doesn't need freeing.<br>Drawback is the fixed length, but you avoid leaking strings and you can guarantee a non-NULL return arg.<br>Hence can directly include in printf() args.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12492/7/src/gsm/gsm0808_utils.c@618">Patch Set #7, Line 618:</a> <code style="font-family:monospace,monospace">#if (!EMBEDDED)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Seeing this for the first time. The effect is that callers on embedded arch end up trying to print a NULL pointer? :P</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/12492/7/src/gsm/gsm0808_utils.c@624">Patch Set #7, Line 624:</a> <code style="font-family:monospace,monospace">           return talloc_asprintf_append(s, ", %s", osmo_gcr_dump(lcls->gcr));</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">you can do these two in one printf call:</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;"> "...%s%s", ... , print_gcr? ", " : "", print_gcr ? osmo_gcr_dump() : ""</pre><p style="white-space: pre-wrap; word-wrap: break-word;">(especially useful if you switch to snprintf)</p><p style="white-space: pre-wrap; word-wrap: break-word;">In this current form, this is leaking the talloc string from osmo_gcr_dump().<br>Of course will be cleaned up as soon as the struct osmo_lcls is deallocated, but not so nice nevertheless.</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/#/c/12492/7/src/gsm/gsm29205.c">File src/gsm/gsm29205.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/12492/7/src/gsm/gsm29205.c@107">Patch Set #7, Line 107:</a> <code style="font-family:monospace,monospace">      osmo_talloc_asprintf(gcr, s, "Node 0x%x, CallRefID 0x%s", gcr->node, osmo_hexdump_nospc(gcr->cr, 5));</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">(maybe we can move _osmo_hexdump() to public API as osmo_hexdump_buf()?)</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/#/c/12492/7/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/12492/7/tests/gsm0808/gsm0808_test.c@746">Patch Set #7, Line 746:</a> <code style="font-family:monospace,monospace"> printf("\t%s\n", osmo_gcr_dump(lcls_out->gcr));</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">should dealloc the strings.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Some of our unit tests fail from the address sanitizer noticing non-deallocated buffers.<br>Ah, in this case probably it gets cleaned from the lcls_out deallocation...</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.osmocom.org/12492">change 12492</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/12492"/><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: Ic3609224c8f3282d667e75f68bc20327e36eb9e6 </div>
<div style="display:none"> Gerrit-Change-Number: 12492 </div>
<div style="display:none"> Gerrit-PatchSet: 7 </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-Comment-Date: Wed, 09 Jan 2019 16:55:42 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-HasLabels: Yes </div>