Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22465751rwd; Fri, 30 Jun 2023 08:19:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlG1U2uxr54Ug6iZFDpUn8iH8a8OZHtm11nPxWOwc7rY+gPpuBdjd30eJFpGBVdL29+m91YG X-Received: by 2002:a17:90a:190f:b0:263:7089:52ec with SMTP id 15-20020a17090a190f00b00263708952ecmr2152421pjg.43.1688138379666; Fri, 30 Jun 2023 08:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688138379; cv=none; d=google.com; s=arc-20160816; b=gsX9f7Xw2UaTaKDTN4FPb6Ed2aKts6FzMtNGp7Jo6G+po2G3tk4LpQtY5HqhenpLZ+ B8ttrrL05wxUM1uPjTu2c5XRwiLsp3l1cTJnbzTJLOHR449LRVly3wCkjN9dKNSeutti Or14ZiaRqFeshERaIUJ4+jGN77UL7StaEyD8xQBAEy4pwS9JVPDdkMJn1dv5rDt9tRqe 4D4XmlfC63xIx1xnMhhEQJ3aIVlXMkUdWhmPDjlujLlxWdQcGaafxCB751ET6/UDbEaD 1gw4u/EPSMTa822k/ORzjzNyFwyw4V9R560S9BP3bHonwGMgUDJz5XyEni3yxL+eDUKq ZgNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=aw9avx0m53SPC30989wgboQS41fm+M9rVBtayN1Wox4=; fh=i9qfMZBi9iT1C3/e2SWuZfR/t36EF2yKoT8rpABYBmc=; b=ZvlzcDNxkZ3pX/Vud8xAUIb0ltomOSzwfndgyTjHC5ADLtwvRwmTBvJeWtRn+kbURX skx0zpC+44tdQPNYUnJaZ9k+hb344gaM9pBCy3ZsX4YcPsrNl2XWX9dtkYhvsIi1HV1q KzxAo4AcNi2XksDUVn8XLtp6Xfr7TLahfBMkUYCNIvpPSeIRKXYBbhOeEMJ8nzYMILoN kohf1Afid5mHlqqdyi3x3zWrbiaqb7vmUAX56Bc1duSm2oBBhHM6Qr/pgFhj0hkNfnSU 5XZOlBmggblyweDEvCyR4eLqIfoXHh3BzeyPEqV/WMeuuiEyGl9N89KQuns3ljS+gnue ZEpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Jcg2Bpzw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a634744000000b0054fe6b9502esi13113839pgk.687.2023.06.30.08.19.26; Fri, 30 Jun 2023 08:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Jcg2Bpzw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229522AbjF3POg (ORCPT + 99 others); Fri, 30 Jun 2023 11:14:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230235AbjF3POe (ORCPT ); Fri, 30 Jun 2023 11:14:34 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A048B1FCB for ; Fri, 30 Jun 2023 08:14:33 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-40345bf4875so128271cf.0 for ; Fri, 30 Jun 2023 08:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688138073; x=1690730073; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=aw9avx0m53SPC30989wgboQS41fm+M9rVBtayN1Wox4=; b=Jcg2Bpzw/EGo9HfiWvoTEB48KERlG4HJYuqzVxspDXav7xPLhiRKbn0SYpjZsewSyK lEkdy+63MvzVzEeGYjlP27CoD34+iYvOXrfu9o5fhn+2XlcVahkHj+paQ814jFUUI/1a wlBfkcEAHPbVvGSNHvC0tkswjJHYXLI+mHAv1ZdBR7XV9wZlhTyEZsT3+ufWN+abJTQI NNUmN2sFIqToNxwi9N2ekz+1pwBIABNouB6PMHKMHpD+nMah0n6N9NSIYmDCWwPT54PJ WNSJ7GwBiDtBt1bGQqCdSOa313WUIG/tj+NrLRiyF0BXCt5/3mVpOYVL6lcPiWT29mIM s8ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688138073; x=1690730073; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aw9avx0m53SPC30989wgboQS41fm+M9rVBtayN1Wox4=; b=PuGGQzPG48JSwJEBIJopj2jbcz0NLLhvAMxsTXrpfQDubE1CyeA9S+JTTL1BT/PVoo 1a4WHHpAx+mWuwWo9pMY7n3jhJrLchGTKlcpyo3lRg079piHHpxxnxALwf7kUuPqbAor 7pl+lRaed3qcgO3NikpHLKFju5MbSdXa+SVEIHccx4pe4EXWD3wkst6lctz9W7joboEW DzhmA0prF/fut1YfzNByJDyUqcFRBk6n/8n1MfUi08f4B9FbFEfIf5dOo/mKse2I/vHI ek47aP+9QD60dz2LZU/YbvnfKXMWW3yIV89I20p/zPGLfF+unXDZ8JrbgkBrtsBoSxt5 00nQ== X-Gm-Message-State: AC+VfDzwN7HRqQ4NVdnfBDnExngxOxcDhtx6Vd22Qwub0lAbMFUqqbcC jVwtdoFxdvbBnpm6o5Hntw40C3kEcl2ETmZcxLth0A== X-Received: by 2002:a05:622a:1756:b0:3f9:a770:7279 with SMTP id l22-20020a05622a175600b003f9a7707279mr787518qtk.9.1688138072603; Fri, 30 Jun 2023 08:14:32 -0700 (PDT) MIME-Version: 1.0 References: <20230627181030.95608-1-irogers@google.com> <20230627181030.95608-14-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Fri, 30 Jun 2023 08:14:21 -0700 Message-ID: Subject: Re: [PATCH v2 13/13] perf parse-events: Remove ABORT_ON To: Namhyung Kim Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Athira Rajeev , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 29, 2023 at 2:49=E2=80=AFPM Namhyung Kim = wrote: > > On Tue, Jun 27, 2023 at 11:11=E2=80=AFAM Ian Rogers = wrote: > > > > Prefer informative messages rather than none with ABORT_ON. Document > > one failure mode and add an error message for another. > > > > Signed-off-by: Ian Rogers > > --- > > tools/perf/util/parse-events.y | 22 ++++++++++++++-------- > > 1 file changed, 14 insertions(+), 8 deletions(-) > > > > diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-eve= nts.y > > index 844646752462..454577f7aff6 100644 > > --- a/tools/perf/util/parse-events.y > > +++ b/tools/perf/util/parse-events.y > > @@ -22,12 +22,6 @@ > > > > void parse_events_error(YYLTYPE *loc, void *parse_state, void *scanner= , char const *msg); > > > > -#define ABORT_ON(val) \ > > -do { \ > > - if (val) \ > > - YYABORT; \ > > -} while (0) > > - > > #define PE_ABORT(val) \ > > do { \ > > if (val =3D=3D -ENOMEM) \ > > @@ -618,7 +612,9 @@ PE_RAW opt_event_config > > YYNOMEM; > > errno =3D 0; > > num =3D strtoull($1 + 1, NULL, 16); > > - ABORT_ON(errno); > > + /* Given the lexer will only give [a-fA-F0-9]+ a failure here s= hould be impossible. */ > > + if (errno) > > + YYABORT; > > free($1); > > err =3D parse_events_add_numeric(_parse_state, list, PERF_TYPE_= RAW, num, $2, > > /*wildcard=3D*/false); > > @@ -978,7 +974,17 @@ PE_VALUE PE_ARRAY_RANGE PE_VALUE > > { > > struct parse_events_array array; > > > > - ABORT_ON($3 < $1); > > + if ($3 < $1) { > > + struct parse_events_state *parse_state =3D _parse_state= ; > > + struct parse_events_error *error =3D parse_state->error= ; > > + char *err_str; > > + > > + if (asprintf(&err_str, "Expected '%ld' to be less-than = '%ld'", $3, $1) < 0) > > Isn't it to be "greater-than or equal" ? I think the order is right. From the man page: When successful, these functions return the number of bytes print= ed, just like sprintf(3). If memory allocation wasn't possible, or s= ome other error occurs, these functions will return -1, and the contents= of strp are undefined. So here we need to catch -1 and ensure strp (&err_str) is NULL before passing it to parse_events_error__handle. Thanks, Ian > Thanks, > Namhyung > > > > + err_str =3D NULL; > > + > > + parse_events_error__handle(error, @1.first_column, err_= str, NULL); > > + YYABORT; > > + } > > array.nr_ranges =3D 1; > > array.ranges =3D malloc(sizeof(array.ranges[0])); > > if (!array.ranges) > > -- > > 2.41.0.162.gfafddb0af9-goog > >