[PATCH 1/2] tracing: Clean up find_event_field() assignment-in-if and type truncation
From: EisenWalds
Date: Fri Dec 04 2026 - 11:36:45 EST
find_event_field() assigns str_has_prefix() to an int and uses the
assignment as an if condition. The int type truncates the size_t
returned by str_has_prefix(), and checkpatch warns about the
assignment-in-if pattern.
Separate the assignment from the condition and use size_t for len.
Also drop the redundant initializer of p, which is immediately
overwritten by the loop.
No functional change.
Signed-off-by: EisenWalds <aerovynqueque@xxxxxxxxx>
---
kernel/trace/trace_events.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 394d7cde1..b5cbdd31c 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -263,12 +263,14 @@ static struct trace_event_fields *find_event_field(const char *fmt,
struct trace_event_call *call)
{
struct trace_event_fields *field = call->class->fields_array;
- const char *p = fmt;
- int len;
+ const char *p;
+ size_t len;
- if (!(len = str_has_prefix(fmt, "REC->")))
+ len = str_has_prefix(fmt, "REC->");
+ if (!len)
return NULL;
fmt += len;
+
for (p = fmt; *p; p++) {
if (!isalnum(*p) && *p != '_')
break;
--
2.56.1