<blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">So, this patch should probably not bother to introduce _buf functions that adhere to the snprintf() signature. It is fine to return a char* and use those with OSMO_STRBUF_PRINTF().</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">I remember now why i wanted a function that is directly usable for OSMO_STRBUF_APPEND(): it allows using the target buffer directly.</p><p style="white-space: pre-wrap; word-wrap: break-word;">If I use OSMO_STRBUF_PRINTF(sb, "%s", osmo_escape_str_buf(buf2, ...)),<br>then I need to define a *second* buffer, and even if the final target buffer is large enough, if the intermediate buffer is too small, that part of the string will be truncated.</p><p style="white-space: pre-wrap; word-wrap: break-word;">If instead I can use</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  OSMO_STRBUF_APPEND(sb, osmo_escape_str_buf2, str, in_len);</pre><p style="white-space: pre-wrap; word-wrap: break-word;">then there is only one buffer involved, and that is the final target buffer that was probably passed in by the user.</p><p style="white-space: pre-wrap; word-wrap: break-word;">So, having a signature returning char* is useful as direct printf() arg,<br>but also having a signature that returns int is useful for using the same buffer with OSMO_STRBUF_APPEND().</p><p style="white-space: pre-wrap; word-wrap: break-word;">options that come to mind:</p><ul><li>add another signature kind that behaves like snprintf(), not *_buf but something named like snprintf(), which works with OSMO_STRBUF_APPEND() directly. maybe osmo_foo_name_snf()</li></ul><ul><li>add another OSMO_STRBUF_xxx() macro that feeds the same sb buffer to *_buf() like signatures. That would have to do a strlen() to figure out how much of the buffer is left afterwards, but it would save the need for a lot of yet more str writing functions.</li></ul><p style="white-space: pre-wrap; word-wrap: break-word;">Going for the latter.</p><p><a href="https://gerrit.osmocom.org/13573">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.osmocom.org/13573">change 13573</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/13573"/><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: Id748b906b0083b1f1887f2be7a53cae705a8a9ae </div>
<div style="display:none"> Gerrit-Change-Number: 13573 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-CC: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Comment-Date: Thu, 11 Apr 2019 04:07:28 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-HasLabels: No </div>