<p style="white-space: pre-wrap; word-wrap: break-word;">Hopefully latest revision clarifies the rest. Don't hesitate to get in touch if that's not the case.</p><p><a href="https://gerrit.osmocom.org/12492">View Change</a></p><p>4 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"> *  \param[in] lcls pointer to the struct to print, used as talloc context to hang the result off.</code></p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><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.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">Sorry to hear that but I don't see how it's related to this case.</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">I'd suggest returning a static string buffer that doesn't need freeing.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">I don't see any practical advantages in that: most of the time talloc will clean it up alongside with lcls automatically.</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">but you avoid leaking strings</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">Where? I don't see any leaks. Could you be more specific?</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">and you can guarantee a non-NULL return arg</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">Why would we want such a guarantee?</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Hence can directly include in printf() args.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">I haven't found any docs explicitly allowing or forbidding printf("%s", NULL); in practice it will just print '(null)'. Are you sure we're not supposed to pass NULL pointer to printf()?</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">  char *s = NULL;</code></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">Seeing this for the first time. […]</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Embedded arch won't have talloc available. It's also not expected to deal with LCLS to begin with.</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">#if (!EMBEDDED)</code></p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><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</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">That seems to be self-contradictory: if smth is leaked it means that it'll never be deallocated. If it's deallocated than it's not leaked.</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));</code></p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Some of our unit tests fail from the address sanitizer noticing non-deallocated buffers.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">Which ones? I thought we have sanitizer enabled by default so it'd cause jenkins failure.</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: 10 </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: Mon, 21 Jan 2019 15:36:15 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-HasLabels: No </div>