Skip to content

Commit

Permalink
test_hexdump: use memcpy instead of strncpy
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
torvalds authored and gregkh committed Feb 20, 2019
1 parent 93af75d commit 5ef0ebd
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 @@ -81,7 +81,7 @@ static void __init test_hexdump(size_t len, int rowsize, int groupsize,
const char *q = *result++;
size_t amount = strlen(q);

strncpy(p, q, amount);
memcpy(p, q, amount);
p += amount + 1;
}
if (i)
Expand Down

0 comments on commit 5ef0ebd

Please sign in to comment.