Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp697746ybg; Thu, 19 Mar 2020 07:13:03 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtlZq9VUcLWKnUl/JZ6Zec5RZh5XQcji2qZkGjg7/2dDQR8fCLrXjkdWVSGi6XqXmU5AZHv X-Received: by 2002:a9d:6a91:: with SMTP id l17mr2520464otq.29.1584627182915; Thu, 19 Mar 2020 07:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584627182; cv=none; d=google.com; s=arc-20160816; b=B7tByYwmhDQ3i/jdIndEsenwJzMWnDD6toDftdGukh7gU599iMPJYYgVfiRNV+hcVW W5CZ9IzPVa4HRgZUBT1qmmEKcc7Trfv+ofH1SZ+FlFAKfTDq8SDUER2dRrcRYCeZyZg1 JJ4Y2xFwGTXkey7bjU6g5ZX5fPqd4nhN7tB66JA2SvEOsGKXPBTRgqJ74FAXaP09RiY4 k6KXvL25PoARFpSktGywG32AGvl6BU49QdxHpZuTeD11FUbFtLF373gtxQeqEYLRmH4y iyWD3h+vsGC4VWzHA3rgN2MGoQbZ+3Q8np83yZwDu+o5XNKeFEukwT67bz6+XvcDqWpR NKHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=Shu4ZlS8X1N3bxCaYP4SIegOec6WIOyVrkvcpNibKGY=; b=O5tq1h4/ORw53MQ73ra5zzW3QRIwYcYhJbU3hjuVBXbQwJhMDQKopB0N6mPMCxz6Yt gj2833NnujMtnCMsTF9N/h3rWpVfz0THrOl+kV37bDCJQ742YpKg5PaUyB3w+iznhkbZ SMhQQ7yvswFdL6eKG7+1s5gTTyibh+ND+d/HVhBEDFVq/RtHA/ArKVknuNaRyhaxj8/A OljWk0zV0Q2vARO50tkx0H7MPuqfZNH2ZM5grY/fpTBJlHkzVU+QAynMcSAcVxrSHjNh 6BRgcbD2aB9WpkH17x593Q+yfVStJyXC2nDZrbqS0ALzBw6MEWEMlgZoi83sqoHrLwL/ 4hxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si1102391oif.164.2020.03.19.07.12.17; Thu, 19 Mar 2020 07:13:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728076AbgCSOLa (ORCPT + 99 others); Thu, 19 Mar 2020 10:11:30 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:32889 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728051AbgCSOLV (ORCPT ); Thu, 19 Mar 2020 10:11:21 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jEvsz-0002EC-FO; Thu, 19 Mar 2020 15:11:01 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id F128A1C22A7; Thu, 19 Mar 2020 15:10:50 +0100 (CET) Date: Thu, 19 Mar 2020 14:10:50 -0000 From: "tip-bot2 for Jiri Olsa" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf expr: Straighten expr__parse()/expr__find_other() interface Cc: Jiri Olsa , Andi Kleen , Alexander Shishkin , John Garry , Kajol Jain , Michael Petlan , Namhyung Kim , Peter Zijlstra , Ravi Bangoria , Arnaldo Carvalho de Melo , x86 , LKML In-Reply-To: <20200228093616.67125-5-jolsa@kernel.org> References: <20200228093616.67125-5-jolsa@kernel.org> MIME-Version: 1.0 Message-ID: <158462705069.28353.9906239911903408424.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: 0f9b1e124bb29719eb1572db74b7893bd616f938 Gitweb: https://git.kernel.org/tip/0f9b1e124bb29719eb1572db74b7893bd616f938 Author: Jiri Olsa AuthorDate: Fri, 28 Feb 2020 10:36:15 +01:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Mon, 09 Mar 2020 21:43:24 -03:00 perf expr: Straighten expr__parse()/expr__find_other() interface Now that we have a flex parser we don't need to update the parsed string pointer, so the interface can just be passed the pointer to the expression instead of a pointer to pointer. Signed-off-by: Jiri Olsa Reviewed-by: Andi Kleen Cc: Alexander Shishkin Cc: John Garry Cc: Kajol Jain Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Ravi Bangoria Link: http://lore.kernel.org/lkml/20200228093616.67125-5-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/expr.c | 6 +++--- tools/perf/util/expr.c | 8 ++++---- tools/perf/util/expr.h | 4 ++-- tools/perf/util/stat-shadow.c | 4 +--- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c index 87843af..755d73c 100644 --- a/tools/perf/tests/expr.c +++ b/tools/perf/tests/expr.c @@ -10,7 +10,7 @@ static int test(struct parse_ctx *ctx, const char *e, double val2) { double val; - if (expr__parse(&val, ctx, &e)) + if (expr__parse(&val, ctx, e)) TEST_ASSERT_VAL("parse test failed", 0); TEST_ASSERT_VAL("unexpected value", val == val2); return 0; @@ -44,11 +44,11 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused) return ret; p = "FOO/0"; - ret = expr__parse(&val, &ctx, &p); + ret = expr__parse(&val, &ctx, p); TEST_ASSERT_VAL("division by zero", ret == 1); p = "BAR/"; - ret = expr__parse(&val, &ctx, &p); + ret = expr__parse(&val, &ctx, p); TEST_ASSERT_VAL("missing operand", ret == 1); TEST_ASSERT_VAL("find other", diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c index b39fd39..45b2553 100644 --- a/tools/perf/util/expr.c +++ b/tools/perf/util/expr.c @@ -52,9 +52,9 @@ __expr__parse(double *val, struct parse_ctx *ctx, const char *expr, return ret; } -int expr__parse(double *final_val, struct parse_ctx *ctx, const char **pp) +int expr__parse(double *final_val, struct parse_ctx *ctx, const char *expr) { - return __expr__parse(final_val, ctx, *pp, EXPR_PARSE); + return __expr__parse(final_val, ctx, expr, EXPR_PARSE); } static bool @@ -71,14 +71,14 @@ already_seen(const char *val, const char *one, const char **other, return false; } -int expr__find_other(const char *p, const char *one, const char ***other, +int expr__find_other(const char *expr, const char *one, const char ***other, int *num_other) { int err, i = 0, j = 0; struct parse_ctx ctx; expr__ctx_init(&ctx); - err = __expr__parse(NULL, &ctx, p, EXPR_OTHER); + err = __expr__parse(NULL, &ctx, expr, EXPR_OTHER); if (err) return -1; diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h index df0a17d..9377538 100644 --- a/tools/perf/util/expr.h +++ b/tools/perf/util/expr.h @@ -17,8 +17,8 @@ struct parse_ctx { void expr__ctx_init(struct parse_ctx *ctx); void expr__add_id(struct parse_ctx *ctx, const char *id, double val); -int expr__parse(double *final_val, struct parse_ctx *ctx, const char **pp); -int expr__find_other(const char *p, const char *one, const char ***other, +int expr__parse(double *final_val, struct parse_ctx *ctx, const char *expr); +int expr__find_other(const char *expr, const char *one, const char ***other, int *num_other); #endif diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 90d23cc..0fd713d 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -777,9 +777,7 @@ static void generic_metric(struct perf_stat_config *config, } if (!metric_events[i]) { - const char *p = metric_expr; - - if (expr__parse(&ratio, &pctx, &p) == 0) { + if (expr__parse(&ratio, &pctx, metric_expr) == 0) { char *unit; char metric_bf[64];