<p>Neels Hofmeyr <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/12269">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  dexter: Looks good to me, but someone else must approve
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">drop/replace very weird logging in mgcp_client.c<br><br>mgcp_do_write() is the final stage of writing data towards the MGCP server<br>(MGW). In that function, drop an unconditional iteration and copy of the MGCP<br>message to a static string buffer for no apparent reason besides debug logging.<br><br>Instead, use osmo_escape_str() with a limited length, which can just be an<br>inline format argument in the LOGP() statement. This way, the string mangling<br>is simpler and only gets run when DMGCP is actually on debug log level.<br><br>Change-Id: Id6877ed7fd7dbe009b2ece8792d5160d040c1aaa<br>---<br>M src/libosmo-mgcp-client/mgcp_client.c<br>1 file changed, 5 insertions(+), 16 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c</span><br><span>index 2a8cc15..fc9c5d3 100644</span><br><span>--- a/src/libosmo-mgcp-client/mgcp_client.c</span><br><span>+++ b/src/libosmo-mgcp-client/mgcp_client.c</span><br><span>@@ -735,26 +735,15 @@</span><br><span> static int mgcp_do_write(struct osmo_fd *fd, struct msgb *msg)</span><br><span> {</span><br><span>        int ret;</span><br><span style="color: hsl(0, 100%, 40%);">-        static char strbuf[4096];</span><br><span style="color: hsl(0, 100%, 40%);">-       unsigned int l = msg->len < sizeof(strbuf) ? msg->len : sizeof(strbuf);</span><br><span style="color: hsl(0, 100%, 40%);">-        unsigned int i;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-     osmo_strlcpy(strbuf, (const char*)msg->data, l);</span><br><span style="color: hsl(0, 100%, 40%);">-     for (i = 0; i < sizeof(strbuf); i++) {</span><br><span style="color: hsl(0, 100%, 40%);">-               if (strbuf[i] == '\n' || strbuf[i] == '\r') {</span><br><span style="color: hsl(0, 100%, 40%);">-                   strbuf[i] = '\0';</span><br><span style="color: hsl(0, 100%, 40%);">-                       break;</span><br><span style="color: hsl(0, 100%, 40%);">-          }</span><br><span style="color: hsl(0, 100%, 40%);">-       }</span><br><span style="color: hsl(0, 100%, 40%);">-       DEBUGP(DLMGCP, "Tx MGCP msg to MGCP GW: '%s'\n", strbuf);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     LOGP(DLMGCP, LOGL_DEBUG, "Sending msg to MGCP GW size: %u\n", msg->len);</span><br><span style="color: hsl(120, 100%, 40%);">+ LOGP(DLMGCP, LOGL_DEBUG, "Sending msg to MGCP GW size: len=%u '%s'...\n",</span><br><span style="color: hsl(120, 100%, 40%);">+        msg->len, osmo_escape_str((const char*)msg->data, OSMO_MIN(42, msg->len)));</span><br><span> </span><br><span>        ret = write(fd->fd, msg->data, msg->len);</span><br><span>   if (ret != msg->len)</span><br><span style="color: hsl(0, 100%, 40%);">-         LOGP(DLMGCP, LOGL_ERROR, "Failed to forward message to MGCP"</span><br><span style="color: hsl(0, 100%, 40%);">-               " GW: %s\n", strerror(errno));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+         LOGP(DLMGCP, LOGL_ERROR, "Failed to Tx MGCP: %d='%s'; msg: len=%u '%s'...\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                    errno, strerror(errno),</span><br><span style="color: hsl(120, 100%, 40%);">+               msg->len, osmo_escape_str((const char*)msg->data, OSMO_MIN(42, msg->len)));</span><br><span>    return ret;</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12269">change 12269</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/12269"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-mgw </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Id6877ed7fd7dbe009b2ece8792d5160d040c1aaa </div>
<div style="display:none"> Gerrit-Change-Number: 12269 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </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-Reviewer: Pau Espin Pedrol <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: dexter <pmaier@sysmocom.de> </div>