Skip to content

Commit

Permalink
lib/test_string.c: avoid masking memset16/32/64 failures
Browse files Browse the repository at this point in the history
If a memsetXX implementation is completely broken and fails in the first
iteration, when i, j, and k are all zero, the failure is masked as zero
is returned.  Failing in the first iteration is perhaps the most likely
failure, so this makes the tests pretty much useless.  Avoid the
situation by always setting a random unused bit in the result on
failure.

Link: http://lkml.kernel.org/r/[email protected]
Fixes: 03270c1 ("lib/string.c: add testcases for memset16/32/64")
Signed-off-by: Peter Rosin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
peda-r authored and torvalds committed Jul 17, 2019
1 parent b097571 commit 33d6e0f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/test_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static __init int memset16_selftest(void)
fail:
kfree(p);
if (i < 256)
return (i << 24) | (j << 16) | k;
return (i << 24) | (j << 16) | k | 0x8000;
return 0;
}

Expand Down Expand Up @@ -72,7 +72,7 @@ static __init int memset32_selftest(void)
fail:
kfree(p);
if (i < 256)
return (i << 24) | (j << 16) | k;
return (i << 24) | (j << 16) | k | 0x8000;
return 0;
}

Expand Down Expand Up @@ -108,7 +108,7 @@ static __init int memset64_selftest(void)
fail:
kfree(p);
if (i < 256)
return (i << 24) | (j << 16) | k;
return (i << 24) | (j << 16) | k | 0x8000;
return 0;
}

Expand Down

0 comments on commit 33d6e0f

Please sign in to comment.