Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1803877rdb; Mon, 8 Jan 2024 10:40:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSO9v6ZwfuU9GC4eE5LbSlHfkuDjJDCASayK4EG8vXXTQaRnkAMbLWgcHNYb3xniulAVmp X-Received: by 2002:a17:90b:1a8b:b0:286:a502:dfe2 with SMTP id ng11-20020a17090b1a8b00b00286a502dfe2mr2222961pjb.52.1704739203948; Mon, 08 Jan 2024 10:40:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704739203; cv=none; d=google.com; s=arc-20160816; b=scqY8mzHCeFrAEueU6n6HPZQScR0TLjGKCLOS/l0xRKcfoxX8cHh1x4awjtWX5ZNIc utPfDyx8LfK0ik2w3UdON7D4cGz2fIVYkBLcUPvuR7eo7f7KaTT4bHTIsK/FG+lXllDi RbTGTSSmyoU95FAMekx/aNg9Z0Ai9bUZFIBT5qn8+6bWvd5e90BUL+iqSVnZ+7LXpHwl gZ5Al3GolrpuszFutWBUm9PxW1HN8tRuvLcNn6P7ytbWZU11fcXvHppkB6Ur0nqa4Bqb VHVJDtZIY30pXY292nICpKIlekCWwBLKCmRawZ+iXk4y9UBcRzYMTafpZvXFOU0wv/lZ zYXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date; bh=0ViM98u0uI8DD0ARgSicNBx3H7lmOqiCCLEWWLeqvAk=; fh=W3aoboXP8sYXfdZvUloezSJg46+XTkJTtmiwT3y299g=; b=YdktZ7BWqFW+/MA4hwnQK5ax2KBk88LcSuDk5q2SAguI4CGSG7W5s8GZ8zKteVqxC6 0faHXzTQIhuOMP9bq5VdqQRYZZkSQqPyqHA1gRlfJFAYvTAQePXwTXeGUNa9RTbv37ry KyolZJGAJNlvqQu9OQlTJthmFY+Ar7uSZLIl7NTjALPWyTL0pBCkfXr0eDKNol32+lwu rrmxssF71ZaTBB9TgcGOt5uNv/NAvdDMaguUWo1vpSVFJ3G1VasYlRY4kwlPa12jh+B5 x8qRZMrzbyt1OKMhsI4MIyjSIzZrV+CoXg/Cq9/JTTPVsAGrFn02bfra1O702ve0LHi1 AXPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19976-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19976-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t10-20020a17090abc4a00b0028d3e4024fdsi3668517pjv.25.2024.01.08.10.40.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 10:40:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19976-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19976-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19976-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A617BB23502 for ; Mon, 8 Jan 2024 18:38:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C83EE54FB5; Mon, 8 Jan 2024 18:36:28 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FBA854FA9; Mon, 8 Jan 2024 18:36:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A13CC433C9; Mon, 8 Jan 2024 18:36:27 +0000 (UTC) Date: Mon, 8 Jan 2024 13:37:23 -0500 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Masami Hiramatsu , Mathieu Desnoyers , Beau Belgrave Subject: [PATCH] tracing user_events: Simplify user_event_parse_field() parsing Message-ID: <20240108133723.031cf322@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit From: "Steven Rostedt (Google)" 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) --- 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