From patchwork Fri Feb 23 16:05:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 129372 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp747552edc; Fri, 23 Feb 2018 07:14:38 -0800 (PST) X-Google-Smtp-Source: AH8x2270vwpftuK6KxwzkZz4WO3pfr2+d/bKUAtcg7lctuwfuPSC2/1MQDprBFR8igz6lKl/qf9f X-Received: by 2002:a17:902:5a1:: with SMTP id f30-v6mr2036599plf.124.1519398878078; Fri, 23 Feb 2018 07:14:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519398878; cv=none; d=google.com; s=arc-20160816; b=PBvP5eY+qPEvCpT+yMC6NMTln19JPWWWcTr3nyjG6IkN30LehBY/nlroMrT6OKUx7S k8LfVzI6HsmFvQ2DY2jHjOLxsNfHyqIIX42Y9sWVOF6CCkZgIyw9309JbatbayPi7htC m6KEzusmaI0nYibeauN0/hnbi7Ne9Z4ZfVX7V5rHC0NG2wu2a8VJpodscyloK4SgvGdH I0mDgVWbA508/Qzd1gwHWVudj4zX2K0Ivco68Hh1JXGAKhtR6zwVvuPXTT0Z7/q5CTXM cqXDQ2amzgviZFuhnRrh0FGeUqgMuApV+ozlBqk8uGhgGcszB55pU7aI5cHf8MsO9U9V LH4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=RdmFWCIV0qjnvw+QUKUTVKtpBwBuptEeOKXdf30MCno=; b=F7gvODhWZGVfWSTTxgsw5pV9NyqrKWxSnZ8c8piC83ClYG93SpszVO1PivSmsdLPue KyOJC1gNrgiYVU+/H1Z5XfSBE8HUg1cgUDGqP1ytx3f8Y+QG9UZc1zHpwsnOHaueVcz5 06/paUnA8CPEuJ776rxgt/4W5I/+PEpjI5yWGf/iei/r4Bf8bEqO5pP+dtAxLi2Hs4Uu MqvRvD9J+xQgx940xgh2fscqsXOozOjdAn5ljE5HIwSfDxP5RLR5+uO5fNIjkDfUI4Pq dNov00hW98Fegrl8Z95YOyQYZvBiFJVJ7fUFigzeXFxrvDLllUfm8yN5jPfTiJLT5aRW so2g== 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 e6-v6si1962814plo.525.2018.02.23.07.14.37; Fri, 23 Feb 2018 07:14:38 -0800 (PST) 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 S1752049AbeBWPOd (ORCPT + 28 others); Fri, 23 Feb 2018 10:14:33 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:39962 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751913AbeBWPO1 (ORCPT ); Fri, 23 Feb 2018 10:14:27 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D873E84174D2B; Fri, 23 Feb 2018 23:14:19 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.361.1; Fri, 23 Feb 2018 23:14:11 +0800 From: John Garry To: , , , , , , , , , CC: , , , , "John Garry" Subject: [PATCH v2 02/11] perf vendor events: fix error code in json_events() Date: Sat, 24 Feb 2018 00:05:23 +0800 Message-ID: <1519401932-205051-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519401932-205051-1-git-send-email-john.garry@huawei.com> References: <1519401932-205051-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When EXPECT macro fails an assertion, the error code is not properly set after the first loop of tokens in function json_events(). This is because err is set to the return value from func function pointer call, which must be 0 to continue to loop, yet it is not reset for for each loop. I assume that this was not the intention, so change the code so err is set appropriately in EXPECT macro itself. In addition to this, the indention in EXPECT macro is tidied. The current indention alludes that the 2 statements following the if statement are in the body, which is not true. Signed-off-by: John Garry --- tools/perf/pmu-events/jevents.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index 9e0a21e..edff989 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -249,9 +249,10 @@ static const char *field_to_perf(struct map *table, char *map, jsmntok_t *val) jsmntok_t *loc = (t); \ if (!(t)->start && (t) > tokens) \ loc = (t) - 1; \ - pr_err("%s:%d: " m ", got %s\n", fn, \ - json_line(map, loc), \ - json_name(t)); \ + pr_err("%s:%d: " m ", got %s\n", fn, \ + json_line(map, loc), \ + json_name(t)); \ + err = -EIO; \ goto out_free; \ } } while (0) @@ -416,7 +417,7 @@ int json_events(const char *fn, char *metric_name, char *metric_group), void *data) { - int err = -EIO; + int err; size_t size; jsmntok_t *tokens, *tok; int i, j, len;