BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v2] bpf: Use isdigit() in bpf_bprintf_prepare()
@ 2026-12-04 21:30 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-12-04 21:30 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Kumar Kartikeya Dwivedi, Martin KaFai Lau,
	Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis,
	Ihor Solodrai
  Cc: Thorsten Blum, bpf

Use isdigit() to skip the width digits and drop the extra if check since
the preceding loop already skips leading zeroes.

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
Changes in v2:
- Drop the redundant if check (Alexei)
- v1: https://lore.kernel.org/r/20261121005306.942603-2-blum@kernel.org/

 kernel/bpf/helpers.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index cebf9d8dfe36..a7a507482e6f 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -926,11 +926,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);

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-04 21:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 21:30 [PATCH bpf-next v2] bpf: Use isdigit() in bpf_bprintf_prepare() Thorsten Blum

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