<p>neels <strong>uploaded patch set #3</strong> to this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/15957">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">utils.h: add OSMO_NAME_C_IMPL() macro<br><br>Provide a common implementation for foo_name_c() functions that base on<br>foo_name_buf() functions.<br><br>  char *foo_name_c(void *ctx, example_t arg)<br>  {<br>          OSMO_NAME_C_IMPL(ctx, 64, "ERROR", foo_name_buf, arg)<br>  }<br><br>Rationale: the most efficient way of composing strings that have optional parts<br>or require loops for composition is by writing to a ready char[], and this in<br>turn is easiest done by using OSMO_STRBUF_* API. Using such a basic name string<br>implementation which typically returns a length, I often want a more convenient<br>version that returns a char*, which can just be inlined in a "%s" string format<br>-- crucially: skipping string composition when inlined in a LOGP(). This common<br>implementation allows saving code dup, only the function signature is needed.<br><br>Why not include the function signature in the macro? The two sets of varargs<br>(1: signature args, 2: function call args) are hard to do. Also, having an<br>explicit signature is good for readability and code grepping / ctags.<br><br>Upcoming uses: in libosmocore in the mslookup (D-GSM) implementation<br>(osmo_mslookup_result_name_c()), and in osmo_msc's codec negotiation<br>implementation (sdp_audio_codecs_name_c(), sdp_msg_name_c(), ...).<br>I54b6c0810f181259da307078977d9ef3d90458c9 (libosmocore)<br>If3ce23cd5bab15e2ab4c52ef3e4c75979dffe931 (osmo-msc)<br><br>Change-Id: Ida5ba8d9640ea641aafef0236800f6d489d3d322<br>---<br>M include/osmocom/core/utils.h<br>M tests/utils/utils_test.c<br>M tests/utils/utils_test.ok<br>3 files changed, 158 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/57/15957/3</pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/15957">change 15957</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/c/libosmocore/+/15957"/><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-Change-Id: Ida5ba8d9640ea641aafef0236800f6d489d3d322 </div>
<div style="display:none"> Gerrit-Change-Number: 15957 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-MessageType: newpatchset </div>