Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1887899rdb; Mon, 8 Jan 2024 13:47:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGENAtkl0j2MPZWYXvkqbFQNTnJO42rwsbsg4p8L9SA2QKb5cBOmI8/cACFwCZ9sBW4I9S X-Received: by 2002:a17:90a:854b:b0:285:8a2a:173f with SMTP id a11-20020a17090a854b00b002858a2a173fmr1453871pjw.0.1704750478735; Mon, 08 Jan 2024 13:47:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704750478; cv=none; d=google.com; s=arc-20160816; b=bew82juEYYru0zV00MNeY/WZwq8wAe7lCWL03qGPtcOGONczjvLzdHRJ+7mDI218zH t+gtoWojsphheH96t896PcktnjIMrbwgeYPMvFaMFnjt9kMy0E94H9P9HmNxgESHTIQ7 FbmbLiR+qNil1TLwmbLepPmzHE8XXu3Su54OdVYDXtOOylkcPb3RYrjDGHVOUdi7G4wE YvrEsUzpOgV+6bpzikDDparnIgi5HcgPYM0oeBXpwF+qo36uwdg1iwyEGPVHwyKVdHhH /o8InzV5zhxWJsoA4PpisEV3CqF53vi113qvaHUkY+tsDadSg3d9g/IzsfNf8HE2Yi1J A7PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-filter; bh=Kj6+QzNwkDHsrznrwFSPMTSSLEkn1Iq05bk+KRJ9TOA=; fh=urpwA9qFkHTMgj2GGwgW1EOwrKQ3iojgE0lW0ov8vP0=; b=SSsT/xZ2vBe0L/QxRCynHQ3PtJA7C+bEwhlUyxPfePcU8XTNd2UMoQGJix/yQ6Z40S 2VlhV1s8Ti6bpbErSBaDduY7Da1Cg1rxEq/8nq9v3BjihGPYveLtdl8XIpQEsFC96pYB UmDNOZhVfFn1gMGnxgFBLyUte6CpaznINPWze9H54pl8StGhLTVdOdyiaPMVA6ta2tuk qkISgvYLssp2oWWYtZ6nS5WKNKWS+k7039qb+0cZizCof3nQZy9YjLrgZoj6KjXy0+oA 5Z0w3XtOlrp5mvUJHf9rPVZH2u1JJWNyTjRwSVfnFoe0GKLxNSHd+QTaK18cTUE5+cwh TGlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=map9tqWE; spf=pass (google.com: domain of linux-kernel+bounces-20135-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20135-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bf20-20020a17090b0b1400b0028c05d2a976si6198033pjb.120.2024.01.08.13.47.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 13:47:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20135-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; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=map9tqWE; spf=pass (google.com: domain of linux-kernel+bounces-20135-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20135-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com 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 658FA284D0C for ; Mon, 8 Jan 2024 21:47:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A415F56462; Mon, 8 Jan 2024 21:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="map9tqWE" X-Original-To: linux-kernel@vger.kernel.org Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96C6E5644F; Mon, 8 Jan 2024 21:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from CPC-beaub-VBQ1L. (unknown [4.155.48.124]) by linux.microsoft.com (Postfix) with ESMTPSA id 1BC1520B3CC1; Mon, 8 Jan 2024 13:47:49 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1BC1520B3CC1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1704750469; bh=Kj6+QzNwkDHsrznrwFSPMTSSLEkn1Iq05bk+KRJ9TOA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=map9tqWEDTTjoa0HZzvLuz4qkRBHCRe3n9aLhLjYzBq8h0VwLliAMDttvbw+zepAS lzKtfqZaJs2b4QCG8POdEQrOGpzpFzFJD5NPmjVf2rjzUBUyw+KRn1S92sciVKa8dm b7Nvih4/KTxewJUzEfjie+h4a8gH5u5CgF5l9SpE= Date: Mon, 8 Jan 2024 21:47:44 +0000 From: Beau Belgrave To: Steven Rostedt Cc: LKML , Linux Trace Kernel , Masami Hiramatsu , Mathieu Desnoyers Subject: Re: [PATCH] tracing user_events: Simplify user_event_parse_field() parsing Message-ID: <20240108214744.GA100-beaub@linux.microsoft.com> References: <20240108133723.031cf322@gandalf.local.home> 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-Disposition: inline In-Reply-To: <20240108133723.031cf322@gandalf.local.home> On Mon, Jan 08, 2024 at 01:37:23PM -0500, Steven Rostedt wrote: > 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; > + } This now triggers a checkpatch error: ERROR: do not use assignment in if condition #1184: FILE: kernel/trace/trace_events_user.c:1184: + if (!(len = str_has_prefix(field, "__data_loc unsigned ")) && I personally prefer to keep these files fully checkpatch clean. However, I did test these changes under the self-tests and it passed. Do they bug you that much? :) Thanks, -Beau > > - goto parse; > skip_next: > type = field; > field = strpbrk(field + len, " "); > -- > 2.43.0