summaryrefslogtreecommitdiff
path: root/kernel/kcsan/debugfs.c
diff options
context:
space:
mode:
authorMarco Elver <elver@google.com>2020-07-31 10:17:20 +0200
committerPaul E. McKenney <paulmck@kernel.org>2020-08-24 15:10:22 -0700
commita4e74fa5f0d3e2a11f2d0deb522681d219a81426 (patch)
tree896f5a73f46186634b58584b25787c4ac804ac01 /kernel/kcsan/debugfs.c
parent69b2c81bc894606670204f0ae08f406dbcce836d (diff)
kcsan: Simplify constant string handling
Simplify checking prefixes and length calculation of constant strings. For the former, the kernel provides str_has_prefix(), and the latter we should just use strlen("..") because GCC and Clang have optimizations that optimize these into constants. No functional change intended. Signed-off-by: Marco Elver <elver@google.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'kernel/kcsan/debugfs.c')
-rw-r--r--kernel/kcsan/debugfs.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/kcsan/debugfs.c b/kernel/kcsan/debugfs.c
index 3a9566addeff..116bdd8f050c 100644
--- a/kernel/kcsan/debugfs.c
+++ b/kernel/kcsan/debugfs.c
@@ -300,16 +300,16 @@ debugfs_write(struct file *file, const char __user *buf, size_t count, loff_t *o
WRITE_ONCE(kcsan_enabled, true);
} else if (!strcmp(arg, "off")) {
WRITE_ONCE(kcsan_enabled, false);
- } else if (!strncmp(arg, "microbench=", sizeof("microbench=") - 1)) {
+ } else if (str_has_prefix(arg, "microbench=")) {
unsigned long iters;
- if (kstrtoul(&arg[sizeof("microbench=") - 1], 0, &iters))
+ if (kstrtoul(&arg[strlen("microbench=")], 0, &iters))
return -EINVAL;
microbenchmark(iters);
- } else if (!strncmp(arg, "test=", sizeof("test=") - 1)) {
+ } else if (str_has_prefix(arg, "test=")) {
unsigned long iters;
- if (kstrtoul(&arg[sizeof("test=") - 1], 0, &iters))
+ if (kstrtoul(&arg[strlen("test=")], 0, &iters))
return -EINVAL;
test_thread(iters);
} else if (!strcmp(arg, "whitelist")) {