All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] tracing: Clean up find_event_field() assignment-in-if and type truncation
@ 2026-12-04 16:36 EisenWalds
  2026-12-04 16:36 ` [PATCH 2/2] tracing: Fix sanitize_field_type() overlapping strcpy() and word boundary check EisenWalds
  2026-12-04 18:15 ` [PATCH 1/2] tracing: Clean up find_event_field() assignment-in-if and type truncation Steven Rostedt
  0 siblings, 2 replies; 5+ messages in thread
From: EisenWalds @ 2026-12-04 16:36 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu
  Cc: linux-trace-kernel, linux-kernel, EisenWalds

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-04 18:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 16:36 [PATCH 1/2] tracing: Clean up find_event_field() assignment-in-if and type truncation EisenWalds
2026-12-04 16:36 ` [PATCH 2/2] tracing: Fix sanitize_field_type() overlapping strcpy() and word boundary check EisenWalds
2026-12-04 16:55   ` sashiko-bot
2026-12-04 18:21   ` Steven Rostedt
2026-12-04 18:15 ` [PATCH 1/2] tracing: Clean up find_event_field() assignment-in-if and type truncation Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.