Change in osmo-remsim[master]: libusb_util.c: Avoid gcc warning about strncpy()

2018-10-14 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11345 )

Change subject: libusb_util.c: Avoid gcc warning about strncpy()
..

libusb_util.c: Avoid gcc warning about strncpy()

What we're doing is actually legal: We copy the full size of the
destination array, and then overwrite the last byte with NUL.  However,
gcc isn't smart enough to see that:

libusb_util.c:162:5: warning: ‘strncpy’ specified bound 20 equals destination 
size [-Wstringop-truncation]
 strncpy(out[out_idx].path, path, sizeof(out[out_idx].path));
 ^~~
Let's copy one byte less to make it happy.

Change-Id: Iae13f7a4cf89230f308eb0183d993d7c31024907
---
M src/simtrace2/libusb_util.c
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/simtrace2/libusb_util.c b/src/simtrace2/libusb_util.c
index cb435e2..45e3f50 100644
--- a/src/simtrace2/libusb_util.c
+++ b/src/simtrace2/libusb_util.c
@@ -159,7 +159,7 @@
out[out_idx].vendor = dev_desc.idVendor;
out[out_idx].product = dev_desc.idProduct;
out[out_idx].addr = addr;
-   strncpy(out[out_idx].path, path, 
sizeof(out[out_idx].path));
+   strncpy(out[out_idx].path, path, 
sizeof(out[out_idx].path)-1);
out[out_idx].path[sizeof(out[out_idx].path)-1] 
= '\0';
out[out_idx].configuration = 
conf_desc->bConfigurationValue;
out[out_idx].interface = 
if_desc->bInterfaceNumber;

--
To view, visit https://gerrit.osmocom.org/11345
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iae13f7a4cf89230f308eb0183d993d7c31024907
Gerrit-Change-Number: 11345
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in osmo-remsim[master]: libusb_util.c: Avoid gcc warning about strncpy()

2018-10-14 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/11345 )

Change subject: libusb_util.c: Avoid gcc warning about strncpy()
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/11345
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Iae13f7a4cf89230f308eb0183d993d7c31024907
Gerrit-Change-Number: 11345
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Mon, 15 Oct 2018 00:18:40 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-remsim[master]: libusb_util.c: Avoid gcc warning about strncpy()

2018-10-14 Thread Harald Welte
Harald Welte has uploaded this change for review. ( 
https://gerrit.osmocom.org/11345


Change subject: libusb_util.c: Avoid gcc warning about strncpy()
..

libusb_util.c: Avoid gcc warning about strncpy()

What we're doing is actually legal: We copy the full size of the
destination array, and then overwrite the last byte with NUL.  However,
gcc isn't smart enough to see that:

libusb_util.c:162:5: warning: ‘strncpy’ specified bound 20 equals destination 
size [-Wstringop-truncation]
 strncpy(out[out_idx].path, path, sizeof(out[out_idx].path));
 ^~~
Let's copy one byte less to make it happy.

Change-Id: Iae13f7a4cf89230f308eb0183d993d7c31024907
---
M src/simtrace2/libusb_util.c
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/45/11345/1

diff --git a/src/simtrace2/libusb_util.c b/src/simtrace2/libusb_util.c
index cb435e2..45e3f50 100644
--- a/src/simtrace2/libusb_util.c
+++ b/src/simtrace2/libusb_util.c
@@ -159,7 +159,7 @@
out[out_idx].vendor = dev_desc.idVendor;
out[out_idx].product = dev_desc.idProduct;
out[out_idx].addr = addr;
-   strncpy(out[out_idx].path, path, 
sizeof(out[out_idx].path));
+   strncpy(out[out_idx].path, path, 
sizeof(out[out_idx].path)-1);
out[out_idx].path[sizeof(out[out_idx].path)-1] 
= '\0';
out[out_idx].configuration = 
conf_desc->bConfigurationValue;
out[out_idx].interface = 
if_desc->bInterfaceNumber;

--
To view, visit https://gerrit.osmocom.org/11345
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iae13f7a4cf89230f308eb0183d993d7c31024907
Gerrit-Change-Number: 11345
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte