From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andrew Morton <akpm@linux-foundation.org>,
kasan-dev@googlegroups.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Alexander Potapenko <glider@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Dmitry Vyukov <dvyukov@google.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 1/1] kasan: Replace strreplace() with strchrnul()
Date: Wed, 28 Jun 2023 18:33:42 +0300 [thread overview]
Message-ID: <20230628153342.53406-1-andriy.shevchenko@linux.intel.com> (raw)
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
next reply other threads:[~2023-06-28 15:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-28 15:33 Andy Shevchenko [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230628153342.53406-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ryabinin.a.a@gmail.com \
--cc=vincenzo.frascino@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox