[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260115163650.118910-19-wander@redhat.com>
Date: Thu, 15 Jan 2026 13:32:01 -0300
From: Wander Lairson Costa <wander@...hat.com>
To: Steven Rostedt <rostedt@...dmis.org>,
Tomas Glozar <tglozar@...hat.com>,
Wander Lairson Costa <wander@...hat.com>,
Crystal Wood <crwood@...hat.com>,
Ivan Pravdin <ipravdin.official@...il.com>,
Costa Shulyupin <costa.shul@...hat.com>,
John Kacur <jkacur@...hat.com>,
Tiezhu Yang <yangtiezhu@...ngson.cn>,
Daniel Wagner <dwagner@...e.de>,
Daniel Bristot de Oliveira <bristot@...nel.org>,
linux-trace-kernel@...r.kernel.org (open list:Real-time Linux Analysis (RTLA) tools),
linux-kernel@...r.kernel.org (open list:Real-time Linux Analysis (RTLA) tools),
bpf@...r.kernel.org (open list:BPF [MISC]:Keyword:(?:\b|_)bpf(?:\b|_))
Subject: [PATCH v3 18/18] rtla/utils: Fix loop condition in PID validation
The procfs_is_workload_pid() function iterates through a directory
entry name to validate if it represents a process ID. The loop
condition checks if the pointer t_name is non-NULL, but since
incrementing a pointer never makes it NULL, this condition is always
true within the loop's context. Although the inner isdigit() check
catches the NUL terminator and breaks out of the loop, the condition
is semantically misleading and not idiomatic for C string processing.
Correct the loop condition from checking the pointer (t_name) to
checking the character it points to (*t_name). This ensures the loop
terminates when the NUL terminator is reached, aligning with standard
C string iteration practices. While the original code functioned
correctly due to the existing character validation, this change
improves code clarity and maintainability.
Signed-off-by: Wander Lairson Costa <wander@...hat.com>
---
tools/tracing/rtla/src/utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c
index 1ea9980d8ecd3..3d47f3ed52dee 100644
--- a/tools/tracing/rtla/src/utils.c
+++ b/tools/tracing/rtla/src/utils.c
@@ -296,7 +296,7 @@ static int procfs_is_workload_pid(const char *comm_prefix, struct dirent *proc_e
return 0;
/* check if the string is a pid */
- for (t_name = proc_entry->d_name; t_name; t_name++) {
+ for (t_name = proc_entry->d_name; *t_name; t_name++) {
if (!isdigit(*t_name))
break;
}
--
2.52.0
Powered by blists - more mailing lists