linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] kasan: Replace strreplace() with strchrnul()
@ 2023-06-28 15:33 Andy Shevchenko
  2023-06-28 15:39 ` Alexander Potapenko
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Andy Shevchenko @ 2023-06-28 15:33 UTC (permalink / raw)
  To: Andrew Morton, kasan-dev, linux-mm, linux-kernel
  Cc: Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov,
	Dmitry Vyukov, Vincenzo Frascino, Andy Shevchenko

We don't need to traverse over the entire string and replace
occurrences of a character with '\0'. The first match will
suffice. Hence, replace strreplace() with strchrnul().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 mm/kasan/report_generic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/kasan/report_generic.c b/mm/kasan/report_generic.c
index 51a1e8a8877f..63a34eac4a8c 100644
--- a/mm/kasan/report_generic.c
+++ b/mm/kasan/report_generic.c
@@ -264,6 +264,7 @@ static void print_decoded_frame_descr(const char *frame_descr)
 	while (num_objects--) {
 		unsigned long offset;
 		unsigned long size;
+		char *p;
 
 		/* access offset */
 		if (!tokenize_frame_descr(&frame_descr, token, sizeof(token),
@@ -282,7 +283,7 @@ static void print_decoded_frame_descr(const char *frame_descr)
 			return;
 
 		/* Strip line number; without filename it's not very helpful. */
-		strreplace(token, ':', '\0');
+		p[strchrnul(token, ':') - token] = '\0';
 
 		/* Finally, print object information. */
 		pr_err(" [%lu, %lu) '%s'", offset, offset + size, token);
-- 
2.40.0.1.gaa8946217a0b



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-07-19  5:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-28 15:33 [PATCH v1 1/1] kasan: Replace strreplace() with strchrnul() Andy Shevchenko
2023-06-28 15:39 ` Alexander Potapenko
2023-06-29  9:22   ` Andy Shevchenko
2023-06-29 14:32 ` David Laight
2023-06-29 14:41   ` 'Andy Shevchenko'
2023-07-03 10:50 ` Andy Shevchenko
2023-07-19  5:36 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox