<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-sip-connector/+/16220">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">logging from sofia: add missing newline<br><br>Sometimes, logging from sofia lacks the final newline character, messing up log<br>output. First snprintf() to a buffer, add '\n' if necessary and then log.<br><br>Change-Id: Ia26c0b57a0166cf7de87c49471ce6f528a366dd5<br>---<br>M src/sip.c<br>1 file changed, 13 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/sip.c b/src/sip.c</span><br><span>index 2b28b4e..c635542 100644</span><br><span>--- a/src/sip.c</span><br><span>+++ b/src/sip.c</span><br><span>@@ -666,7 +666,19 @@</span><br><span>     * the log handler call-back function, so we have no clue what log level the</span><br><span>          * currently logged message was sent for :(  As a result, we can only use one</span><br><span>         * hard-coded LOGL_NOTICE here */</span><br><span style="color: hsl(0, 100%, 40%);">-       osmo_vlogp(DSIP, LOGL_NOTICE, "", 0, 0, fmt, ap);</span><br><span style="color: hsl(120, 100%, 40%);">+   if (!log_check_level(DSIP, LOGL_NOTICE))</span><br><span style="color: hsl(120, 100%, 40%);">+              return;</span><br><span style="color: hsl(120, 100%, 40%);">+       /* The sofia-sip log line *sometimes* lacks a terminating '\n'. Add it. */</span><br><span style="color: hsl(120, 100%, 40%);">+    char log_line[256];</span><br><span style="color: hsl(120, 100%, 40%);">+   int rc = vsnprintf(log_line, sizeof(log_line), fmt, ap);</span><br><span style="color: hsl(120, 100%, 40%);">+      if (rc > 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+              /* since we're explicitly checking for sizeof(log_line), we can use vsnprintf()'s return value (which,</span><br><span style="color: hsl(120, 100%, 40%);">+                 * alone, would possibly cause writing past the buffer's end). */</span><br><span style="color: hsl(120, 100%, 40%);">+         char *end = log_line + OSMO_MIN(rc, sizeof(log_line) - 2);</span><br><span style="color: hsl(120, 100%, 40%);">+            osmo_strlcpy(end, "\n", 2);</span><br><span style="color: hsl(120, 100%, 40%);">+         LOGP(DSIP, LOGL_NOTICE, "%s", log_line);</span><br><span style="color: hsl(120, 100%, 40%);">+    } else</span><br><span style="color: hsl(120, 100%, 40%);">+                LOGP(DSIP, LOGL_NOTICE, "unknown logging from sip\n");</span><br><span> }</span><br><span> </span><br><span> void sip_agent_init(struct sip_agent *agent, struct app_config *app)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-sip-connector/+/16220">change 16220</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/osmo-sip-connector/+/16220"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-sip-connector </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ia26c0b57a0166cf7de87c49471ce6f528a366dd5 </div>
<div style="display:none"> Gerrit-Change-Number: 16220 </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-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>