Message ID | 20180710183216.25450-1-bart.vanassche@wdc.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Jason Gunthorpe |
Headers | show |
On 7/10/2018 2:32 PM, Bart Van Assche wrote: > Avoid that the following compiler warning is reported when building > with gcc 8: > > drivers/infiniband/hw/hfi1/verbs.c:1896:2: warning: 'strncpy' output may be truncated copying 64 bytes from a string of length 64 [-Wstringop-truncation] > > Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> > --- > drivers/infiniband/hw/hfi1/verbs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c > index 5cef1224fa9c..47aade71acbb 100644 > --- a/drivers/infiniband/hw/hfi1/verbs.c > +++ b/drivers/infiniband/hw/hfi1/verbs.c > @@ -1893,7 +1893,7 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd) > ibdev->process_mad = hfi1_process_mad; > ibdev->get_dev_fw_str = hfi1_get_dev_fw_str; > > - strncpy(ibdev->node_desc, init_utsname()->nodename, > + strlcpy(ibdev->node_desc, init_utsname()->nodename, > sizeof(ibdev->node_desc)); > > /* > Technically the code is OK as is because the string will be short enough but in general this is probably the right thing to do so... Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com> -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Jul 10, 2018 at 11:32:16AM -0700, Bart Van Assche wrote: > Avoid that the following compiler warning is reported when building > with gcc 8: > > drivers/infiniband/hw/hfi1/verbs.c:1896:2: warning: 'strncpy' output may be truncated copying 64 bytes from a string of length 64 [-Wstringop-truncation] > > Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> > Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com> > --- > drivers/infiniband/hw/hfi1/verbs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied to for-next Thanks, Jason -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c index 5cef1224fa9c..47aade71acbb 100644 --- a/drivers/infiniband/hw/hfi1/verbs.c +++ b/drivers/infiniband/hw/hfi1/verbs.c @@ -1893,7 +1893,7 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd) ibdev->process_mad = hfi1_process_mad; ibdev->get_dev_fw_str = hfi1_get_dev_fw_str; - strncpy(ibdev->node_desc, init_utsname()->nodename, + strlcpy(ibdev->node_desc, init_utsname()->nodename, sizeof(ibdev->node_desc)); /*
Avoid that the following compiler warning is reported when building with gcc 8: drivers/infiniband/hw/hfi1/verbs.c:1896:2: warning: 'strncpy' output may be truncated copying 64 bytes from a string of length 64 [-Wstringop-truncation] Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> --- drivers/infiniband/hw/hfi1/verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)