On Mon, 2018-07-23 at 15:29 -0600, Jason Gunthorpe wrote: +AD4- On Wed, Jul 18, 2018 at 09:03:29AM -0700, Bart Van Assche wrote: +AD4- +AD4- This patch avoids that the following compiler warning is reported when +AD4- +AD4- building with gcc 8 and W+AD0-1: +AD4- +AD4- +AD4- +AD4- drivers/infiniband/hw/usnic/usnic+AF8-fwd.c:95:2: warning: 'strncpy' output may be truncated copying 16 bytes from a string of length 20 +AFs--Wstringop-truncation+AF0- +AD4- +AD4- strncpy(ufdev-+AD4-name, netdev+AF8-name(ufdev-+AD4-netdev), +AD4- +AD4- +AF4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+- +AD4- +AD4- sizeof(ufdev-+AD4-name) - 1)+ADs- +AD4- +AD4- +AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+AH4AfgB+- +AD4- +AD4- +AD4- +AD4- Signed-off-by: Bart Van Assche +ADw-bart.vanassche+AEA-wdc.com+AD4- +AD4- +AD4- Cc: Christian Benvenuti +ADw-benve+AEA-cisco.com+AD4- +AD4- +AD4- Cc: Dave Goodell +ADw-dgoodell+AEA-cisco.com+AD4- +AD4- +AD4- --- +AD4- +AD4- drivers/infiniband/hw/usnic/usnic+AF8-fwd.c +AHw- 3 +--- +AD4- +AD4- 1 file changed, 1 insertion(+-), 2 deletions(-) +AD4- +AD4- I think this is a bug in netdev+AF8-name, it shouldn't return a constant +AD4- string longer than IFNAMSIZ. I think that netdev+AF8-name() was intended to be used for logging instead of to copying the result into an IFNAMSIZ array. See also commit 571ba4230381 (+ACI-netdevice.h: Add netdev+AF8-printk helpers like dev+AF8-printk+ACI-). How about something like the patch below? diff --git a/drivers/infiniband/hw/usnic/usnic+AF8-fwd.c b/drivers/infiniband/hw/usnic/usnic+AF8-fwd.c index 995a26b65156..e1a832775d2b 100644 --- a/drivers/infiniband/hw/usnic/usnic+AF8-fwd.c +-+-+- b/drivers/infiniband/hw/usnic/usnic+AF8-fwd.c +AEAAQA- -92,8 +-92,7 +AEAAQA- struct usnic+AF8-fwd+AF8-dev +ACo-usnic+AF8-fwd+AF8-dev+AF8-alloc(struct pci+AF8-dev +ACo-pdev) ufdev-+AD4-pdev +AD0- pdev+ADs- ufdev-+AD4-netdev +AD0- pci+AF8-get+AF8-drvdata(pdev)+ADs- spin+AF8-lock+AF8-init(+ACY-ufdev-+AD4-lock)+ADs- - strncpy(ufdev-+AD4-name, netdev+AF8-name(ufdev-+AD4-netdev), - sizeof(ufdev-+AD4-name) - 1)+ADs- +- strlcpy(ufdev-+AD4-name, ufdev-+AD4-netdev-+AD4-name, sizeof(ufdev-+AD4-name))+ADs- return ufdev+ADs- +AH0- Thanks, Bart. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html