From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Thorsten Blum" <blum@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>
Cc: <bpf@vger.kernel.org>
Subject: Re: [PATCH] bpf: Use isdigit() in bpf_bprintf_prepare()
Date: Tue, 01 Dec 2026 05:19:23 +0000 [thread overview]
Message-ID: <DN955F4UGP18.1O0VV0HJGRUQ7@gmail.com> (raw)
In-Reply-To: <20261121005306.942603-2-blum@kernel.org>
On Fri, Nov 20, 2026 at 04:53 PM Thorsten Blum <blum@kernel.org> wrote:
> if (fmt[i] >= '1' && fmt[i] <= '9') {
> i++;
> - while (fmt[i] >= '0' && fmt[i] <= '9')
> + while (isdigit(fmt[i]))
> i++;
> }
The '1'..'9' check stays open-coded.
The loop in front of it skips every '0', so fmt[i] is not '0' here.
One isdigit() loop covers both. No need for the 'if'.
helpers.o builds with it, the snprintf test was not run:
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 937a0d7..6bf36a4 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -928,11 +928,8 @@ int bpf_bprintf_prepare(const char *fmt, u32 fmt_size, const u64 *raw_args,
while (fmt[i] == '0' || fmt[i] == '+' || fmt[i] == '-' ||
fmt[i] == ' ')
i++;
- if (fmt[i] >= '1' && fmt[i] <= '9') {
+ while (isdigit(fmt[i]))
i++;
- while (fmt[i] >= '0' && fmt[i] <= '9')
- i++;
- }
if (fmt[i] == 'p') {
sizeof_cur_arg = sizeof(long);
Pls tag the respin as [PATCH bpf-next v2].
pw-bot: cr
prev parent reply other threads:[~2026-12-01 5:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 0:53 [PATCH] bpf: Use isdigit() in bpf_bprintf_prepare() Thorsten Blum
2026-12-01 5:19 ` Alexei Starovoitov [this message]
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=DN955F4UGP18.1O0VV0HJGRUQ7@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=blum@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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