<p>Harald Welte has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/11329">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">libusb_util.c: Avoid gcc warning about strncpy()<br><br>What we're doing is actually legal: We copy the full size of the<br>destination array, and then overwrite the last byte with NUL.  However,<br>gcc isn't smart enough to see that:<br><br>libusb_util.c:162:5: warning: ‘strncpy’ specified bound 20 equals destination size [-Wstringop-truncation]<br>     strncpy(out[out_idx].path, path, sizeof(out[out_idx].path));<br>     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>Let's copy one byte less to make it happy.<br><br>Change-Id: I30ddacdc73e5245c7c38b92d1e94e39b13fae7d3<br>---<br>M host/libusb_util.c<br>1 file changed, 1 insertion(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/29/11329/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/host/libusb_util.c b/host/libusb_util.c</span><br><span>index cb435e2..45e3f50 100644</span><br><span>--- a/host/libusb_util.c</span><br><span>+++ b/host/libusb_util.c</span><br><span>@@ -159,7 +159,7 @@</span><br><span>                           out[out_idx].vendor = dev_desc.idVendor;</span><br><span>                             out[out_idx].product = dev_desc.idProduct;</span><br><span>                           out[out_idx].addr = addr;</span><br><span style="color: hsl(0, 100%, 40%);">-                               strncpy(out[out_idx].path, path, sizeof(out[out_idx].path));</span><br><span style="color: hsl(120, 100%, 40%);">+                          strncpy(out[out_idx].path, path, sizeof(out[out_idx].path)-1);</span><br><span>                               out[out_idx].path[sizeof(out[out_idx].path)-1] = '\0';</span><br><span>                               out[out_idx].configuration = conf_desc->bConfigurationValue;</span><br><span>                              out[out_idx].interface = if_desc->bInterfaceNumber;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/11329">change 11329</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/11329"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: simtrace2 </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I30ddacdc73e5245c7c38b92d1e94e39b13fae7d3 </div>
<div style="display:none"> Gerrit-Change-Number: 11329 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Harald Welte <laforge@gnumonks.org> </div>