public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>,
	Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Beau Belgrave <beaub@linux.microsoft.com>
Subject: [PATCH] tracing user_events: Simplify user_event_parse_field() parsing
Date: Mon, 8 Jan 2024 13:37:23 -0500	[thread overview]
Message-ID: <20240108133723.031cf322@gandalf.local.home> (raw)

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Instead of having a bunch of if statements with:

       len = str_has_prefix(field, "__data_loc unsigned ");
       if (len)
               goto skip_next;

       len = str_has_prefix(field, "__data_loc ");
       if (len)
               goto skip_next;

       len = str_has_prefix(field, "__rel_loc unsigned ");
       if (len)
               goto skip_next;

       len = str_has_prefix(field, "__rel_loc ");
       if (len)
               goto skip_next;

	goto parse;

 skip_next:

Consolidate it into a negative check and jump to parse if all the
str_has_prefix() calls fail. If one succeeds, it will just continue with
len equal to the proper string:

       if (!(len = str_has_prefix(field, "__data_loc unsigned ")) &&
           !(len = str_has_prefix(field, "__data_loc ")) &&
           !(len = str_has_prefix(field, "__rel_loc unsigned ")) &&
           !(len = str_has_prefix(field, "__rel_loc "))) {
               goto parse;
       }

 skip_next:

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_user.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index 9365ce407426..ce0c5f1ded48 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -1175,23 +1175,13 @@ static int user_event_parse_field(char *field, struct user_event *user,
 		goto skip_next;
 	}
 
-	len = str_has_prefix(field, "__data_loc unsigned ");
-	if (len)
-		goto skip_next;
-
-	len = str_has_prefix(field, "__data_loc ");
-	if (len)
-		goto skip_next;
-
-	len = str_has_prefix(field, "__rel_loc unsigned ");
-	if (len)
-		goto skip_next;
-
-	len = str_has_prefix(field, "__rel_loc ");
-	if (len)
-		goto skip_next;
+	if (!(len = str_has_prefix(field, "__data_loc unsigned ")) &&
+	    !(len = str_has_prefix(field, "__data_loc ")) &&
+	    !(len = str_has_prefix(field, "__rel_loc unsigned ")) &&
+	    !(len = str_has_prefix(field, "__rel_loc "))) {
+		goto parse;
+	}
 
-	goto parse;
 skip_next:
 	type = field;
 	field = strpbrk(field + len, " ");
-- 
2.43.0


             reply	other threads:[~2024-01-08 18:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-08 18:37 Steven Rostedt [this message]
2024-01-08 21:47 ` [PATCH] tracing user_events: Simplify user_event_parse_field() parsing Beau Belgrave
2024-01-08 22:13   ` Steven Rostedt
2024-01-08 22:22     ` 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=20240108133723.031cf322@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=beaub@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.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