Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1691684rdb; Mon, 8 Jan 2024 07:21:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3BjhlSEGCgSX+ngXlXZzpeyc7WhEEVSlqYtkbXSTtlw9YrW9345yUIQQXYtA8NISmescP X-Received: by 2002:a17:90a:d785:b0:28c:9b9:2c52 with SMTP id z5-20020a17090ad78500b0028c09b92c52mr1141907pju.73.1704727269844; Mon, 08 Jan 2024 07:21:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704727269; cv=none; d=google.com; s=arc-20160816; b=qLEDj9+PeyA9TmYpMTaaTVHNxmeu3qORjeDbzmC5CQUvF/gJM1VqYZ1vWealTxMhbn SXAKR6OPLSlF4qzLyrc3j2oJd9v1O0MQ4EZCm4ibCEKx4l+C/KUYR95VK8eMCoNNPKVe 2mRpCSMMQDo6FXRNImt7tfjxH7dUXS7jVrzQ4gf3x1j4kvwfrbA0dH/3iHvuxFZCn/6y W4ndErTZkO4r6mYMSI7hxVsRaDavtH+OjKQXGIf1otcI8DnVd8WG4Tw75WlNwtgZD3QA pkHk4x5Y5G9y44IVYDXK59x1Ezu8QpNmW9vzTKAmCEzzLBTwlDP2nBC6hAI9RtZxJrU8 XzjA== 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:references:in-reply-to:message-id :subject:cc:to:from:date; bh=W8mo2QVWAgJLRL7znuVovu/tncZ1wwjUl8X9Q5ZtHFI=; fh=S3jYvSa+oZe3kXCZw56f0nUHYujZOnJu8nConO4avKQ=; b=NAcI1cmu5KF3F/AiUswjnN6l80yTgUwHJ7t0VykKrYV/hlOaduVFmKwFkoFsibMvgf m2ARtdBuJwAfapsBpuXCO9ytD4citjyhcboeDDYO0QNbiGGJNtjrmP6YthFvxTwoL+mC FAUihVgS2xvEei4hnva+TWi1ujkBfdM94Ie19aTxgArLtCVA2gq+8ERqyzyXGVFt09pE M4cxxZlzZ07Siajxi0ANFU9NTxS6J1+QCus0V9VKtUxlOfxiO+Ag0FViA6jehbkh/zJt JrOnGrHxlSlMNtwZRjHlSR0O41mg0wUEOGQccUUkYbJjOWwUMUo1kF51XayZvLM8i5VG Fz4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19755-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id hi9-20020a17090b30c900b0028c0bd5a278si5774078pjb.163.2024.01.08.07.21.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 07:21:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19755-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 77C0F283230 for ; Mon, 8 Jan 2024 15:21:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 274525026C; Mon, 8 Jan 2024 15:20:21 +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 AC8015103A; Mon, 8 Jan 2024 15:20:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1797C43391; Mon, 8 Jan 2024 15:20:19 +0000 (UTC) Date: Mon, 8 Jan 2024 10:21:15 -0500 From: Steven Rostedt To: Andy Shevchenko Cc: LKML , Linux Trace Kernel , Masami Hiramatsu , Mathieu Desnoyers , Andy Shevchenko , Tom Zanussi Subject: Re: [PATCH] tracing histograms: Simplify parse_actions() function Message-ID: <20240108102115.43464fd6@gandalf.local.home> In-Reply-To: References: <20240107203258.37e26d2b@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=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 8 Jan 2024 10:32:14 +0200 Andy Shevchenko wrote: > On Mon, Jan 8, 2024 at 3:31=E2=80=AFAM Steven Rostedt wrote: > > > > From: "Steven Rostedt (Google)" > > > > The parse_actions() function uses 'len =3D str_has_prefix()' to test wh= ich > > action is in the string being parsed. But then it goes and repeats the > > logic for each different action. This logic can be simplified and > > duplicate code can be removed as 'len' contains the length of the found > > prefix which should be used for all actions. =20 >=20 > > Link: https://lore.kernel.org/all/20240107112044.6702cb66@gandalf.local= .home/ > > > > Signed-off-by: Steven Rostedt (Google) =20 >=20 > If you want Link to be formally a tag, you should drop the following > blank line. The link is for humans not for parsers. >=20 >=20 > > + if ((len =3D str_has_prefix(str, "onmatch("))) > > + hid =3D HANDLER_ONMATCH; > > + else if ((len =3D str_has_prefix(str, "onmax("))) > > + hid =3D HANDLER_ONMAX; > > + else if ((len =3D str_has_prefix(str, "onchange("))) > > + hid =3D HANDLER_ONCHANGE; =20 >=20 > The repeating check for ( might be moved out as well after this like >=20 > if (str[len] !=3D '(') { > // not sure if you need data to be assigned here as well > ret =3D -EINVAL; > ... > } >=20 Not sure how that makes it any better. It adds more code. I could start with checking the "on" before checking for "match", "max" and "change", but that just makes it more complex. -- Steve