Skip to content

Commit

Permalink
test_hexdump: use memcpy instead of strncpy
Browse files Browse the repository at this point in the history
commit b1286ed 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>
  • Loading branch information
torvalds authored and gregkh committed Dec 8, 2018
1 parent 724ff9c commit f2d12a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/test_hexdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,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++ = ' ';
Expand Down

0 comments on commit f2d12a0

Please sign in to comment.