]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
mm/kfence: use str_write_read() helper in get_access_type()
authorThorsten Blum <thorsten.blum@linux.dev>
Wed, 15 Jan 2025 15:55:12 +0000 (16:55 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 26 Jan 2025 04:22:45 +0000 (20:22 -0800)
Remove hard-coded strings by using the str_write_read() helper function.

Link: https://lkml.kernel.org/r/20250115155511.954535-2-thorsten.blum@linux.dev
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Suggested-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Marco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/kfence/kfence_test.c
mm/kfence/report.c

index f65fb182466d5f3dbde608cb623fe572d339cdd0..00034e37bc9ff43900ff964eb8a7eaeeb551b7a7 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 #include <linux/tracepoint.h>
 #include <trace/events/printk.h>
 
@@ -88,7 +89,7 @@ struct expect_report {
 
 static const char *get_access_type(const struct expect_report *r)
 {
-       return r->is_write ? "write" : "read";
+       return str_write_read(r->is_write);
 }
 
 /* Check observed report matches information in @r. */
index 6370c5207d1a77aa5f010e1e630244df3971904e..10e6802a2edffcd4b79016ce2ed2afb745ae3491 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/sprintf.h>
 #include <linux/stacktrace.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 #include <linux/sched/clock.h>
 #include <trace/events/error_report.h>
 
@@ -184,7 +185,7 @@ static void print_diff_canary(unsigned long address, size_t bytes_to_show,
 
 static const char *get_access_type(bool is_write)
 {
-       return is_write ? "write" : "read";
+       return str_write_read(is_write);
 }
 
 void kfence_report_error(unsigned long address, bool is_write, struct pt_regs *regs,