Skip to content

Commit

Permalink
test_hexdump: use memcpy instead of strncpy
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
torvalds committed Nov 30, 2018
1 parent 1ec6357 commit b1286ed
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 b1286ed

Please sign in to comment.