]> git.baikalelectronics.ru Git - kernel.git/commit
HID: uhid: use strlcpy() instead of strncpy()
authorXiongfeng Wang <xiongfeng.wang@linaro.org>
Tue, 9 Jan 2018 12:23:32 +0000 (20:23 +0800)
committerJiri Kosina <jkosina@suse.cz>
Fri, 16 Feb 2018 12:36:50 +0000 (13:36 +0100)
commit304eed91e8426d067d60dc81baa0aa6fd3ee72eb
tree5d3e78c6dd76eae8c5ed14e9f8716ea56a37ebbc
parent91555d76eb09285b66b7a951f2e8462f6d479db8
HID: uhid: use strlcpy() instead of strncpy()

gcc-8 reports

drivers/hid/uhid.c: In function 'uhid_dev_create2':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' output may
be truncated copying 127 bytes from a string of length 127
[-Wstringop-truncation]

The compiler require that the input param 'len' of strncpy() should be
greater than the length of the src string, so that '\0' is copied as
well. We can just use strlcpy() to avoid this warning.

Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/uhid.c