]> git.proxmox.com Git - mirror_ubuntu-focal-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)
commit336fd4f5f25157e9e8bd50e898a1bbcd99eaea46
tree5d3e78c6dd76eae8c5ed14e9f8716ea56a37ebbc
parentb9ec7009298ee0e163339484992252d8dff636dc
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