]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
test_hexdump: use memcpy instead of strncpy
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 30 Nov 2018 20:13:15 +0000 (12:13 -0800)
committerSultan Alsawaf <sultan.alsawaf@canonical.com>
Wed, 24 Jul 2019 15:45:00 +0000 (09:45 -0600)
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 <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
lib/test_hexdump.c

index 3f415d8101f3209f16ba66143ee1b31b56d4b0b1..1c3c513add77f74ab9837f9d4f406833497512e3 100644 (file)
@@ -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++ = ' ';