aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_string.c
diff options
context:
space:
mode:
authorPeter Rosin <[email protected]>2019-07-16 23:27:18 +0000
committerLinus Torvalds <[email protected]>2019-07-17 02:23:22 +0000
commit33d6e0ff68af74be0c846c8e042e84a9a1a0561e (patch)
tree8479d93b260826a01e85a9669e7ec88fa7b5fb36 /lib/test_string.c
parentlib/string.c: allow searching for NUL with strnchr (diff)
downloadkernel-33d6e0ff68af74be0c846c8e042e84a9a1a0561e.tar.gz
kernel-33d6e0ff68af74be0c846c8e042e84a9a1a0561e.zip
lib/test_string.c: avoid masking memset16/32/64 failures
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: 03270c13c5ff ("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]>
Diffstat (limited to 'lib/test_string.c')
-rw-r--r--lib/test_string.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/test_string.c b/lib/test_string.c
index bf8def01ed20..b5117ae59693 100644
--- a/lib/test_string.c
+++ b/lib/test_string.c
@@ -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;
}
@@ -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;
}
@@ -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;
}