Skip to content

Commit b2094a1

Browse files
groeckholyangel
authored andcommitted
kernfs: Replace strncpy with memcpy
commit 166126c upstream. gcc 8.1.0 complains: fs/kernfs/symlink.c:91:3: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length fs/kernfs/symlink.c: In function 'kernfs_iop_get_link': fs/kernfs/symlink.c:88:14: note: length computed here Using strncpy() is indeed less than perfect since the length of data to be copied has already been determined with strlen(). Replace strncpy() with memcpy() to address the warning and optimize the code a little. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent dfcaac1 commit b2094a1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/kernfs/symlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static int kernfs_get_target_path(struct kernfs_node *parent,
8888
int slen = strlen(kn->name);
8989

9090
len -= slen;
91-
strncpy(s + len, kn->name, slen);
91+
memcpy(s + len, kn->name, slen);
9292
if (len)
9393
s[--len] = '/';
9494

0 commit comments

Comments
 (0)