From: Linus Torvalds Date: Fri, 30 Nov 2018 20:13:15 +0000 (-0800) Subject: test_hexdump: use memcpy instead of strncpy X-Git-Tag: Ubuntu-4.15.0-56.62~299 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=3bdf2ddcccf447bfdde6299b12e55b26fbd99d1e;hp=779e035d1808b721215e2e90657685f172e05245;p=mirror_ubuntu-bionic-kernel.git test_hexdump: use memcpy instead of strncpy BugLink: https://bugs.launchpad.net/bugs/1837161 commit b1286ed7158e9b62787508066283ab0b8850b518 upstream. New versions of gcc reasonably warn about the odd pattern of strncpy(p, q, strlen(q)); which really doesn't make sense: the strncpy() ends up being just a slow and odd way to write memcpy() in this case. Apparently there was a patch for this floating around earlier, but it got lost. Acked-again-by: Andy Shevchenko Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Signed-off-by: Andrea Righi Signed-off-by: Khalid Elmously --- diff --git a/lib/test_hexdump.c b/lib/test_hexdump.c index 3f415d8101f3..1c3c513add77 100644 --- a/lib/test_hexdump.c +++ b/lib/test_hexdump.c @@ -81,7 +81,7 @@ static void __init test_hexdump_prepare_test(size_t len, int rowsize, const char *q = *result++; size_t amount = strlen(q); - strncpy(p, q, amount); + memcpy(p, q, amount); p += amount; *p++ = ' ';