Linux Trace Kernel
 help / color / mirror / Atom feed
From: EisenWalds <aerovynqueque@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>
Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
	EisenWalds <aerovynqueque@gmail.com>
Subject: [PATCH 1/2] tracing: Clean up find_event_field() assignment-in-if and type truncation
Date: Fri,  4 Dec 2026 23:36:29 +0700	[thread overview]
Message-ID: <20261204163630.17660-1-aerovynqueque@gmail.com> (raw)

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


             reply	other threads:[~2026-12-04 16:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 16:36 EisenWalds [this message]
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

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=20261204163630.17660-1-aerovynqueque@gmail.com \
    --to=aerovynqueque@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /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