Received: by 10.223.185.116 with SMTP id b49csp6170215wrg; Thu, 8 Mar 2018 03:03:54 -0800 (PST) X-Google-Smtp-Source: AG47ELt4Sj8Fg2js++NL16XhJ1Yz2wOVzh78LxFeju/78f3MRPQSrgkNTEO23XqDogFttvGDhFqA X-Received: by 10.99.173.71 with SMTP id y7mr20588022pgo.432.1520507034320; Thu, 08 Mar 2018 03:03:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520507034; cv=none; d=google.com; s=arc-20160816; b=nY8Ngl57YwZzypKMiYjIXq/RwWlfN/uggQj4OlxWzod0W7Nr4NZpJjIx6VcTQFToWo U0LA734WW990W/krBdXOJSBt40t2nV+0hJVOcn1wx3aXo14zXlBy4l9MJvkRG0ugVa95 weoFr/Ya3cuBfoppFs7UhGHTbXVRi37A/AB30hiZz23zI0uFI2TRO2GPtjQO+syvKRYS AmRytwbcMJG1EFeg7ZhTz4JaVJgGcVEJLK8FphrG+3P2Xq7SZxWfkCdpuZ2c2fdYk9z1 vEY/mfrTOW0nwBxeQWBSognD2yKPrBD2rv3aMEAo2VCC+4N27uveuUROqyKdLgQ2pjcu iYUw== 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=oMcC8rdNJOodxPEpZb0fpfmCzeSDFaSaJlzAxGUbFyY=; b=PG4p7853Pu4snCxT4/Rby2cP2UzS8lr0GUrp/iORozoIBI9Qzkk6mr+JZB+XqOtP6n 4GbdHZltVG20JlosMXYxttQhsR+mM3wdpqX84eJ0fT3STfilDMgC3zsjLbax4KBEgBl6 JDWCAS8ViOHXCTXvFjQNHqEk0WACOwjlB4bZ/Um331w6GoNUbwMu+5+cFiGA1o7pEHVf kpIUgVO8fT0nUCbQvx3FXs08xbb04/BVjkAb5FCypVAtNLYPRaIfCvYyxBFEthOHDwIb aLe0fDUgQxYtJqfH2rbphsJjUBsIEUHu1w6Bcc0LArVbcVGo5BjdvCt4ANhdeYpe/dg2 5C+w== 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 k30si12900037pgn.319.2018.03.08.03.03.39; Thu, 08 Mar 2018 03:03:54 -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 S1755795AbeCHK7p (ORCPT + 99 others); Thu, 8 Mar 2018 05:59:45 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:6181 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754981AbeCHK7o (ORCPT ); Thu, 8 Mar 2018 05:59:44 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id EABA257CC4861; Thu, 8 Mar 2018 18:59:30 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Thu, 8 Mar 2018 18:59:24 +0800 From: John Garry To: , , , , , , , , , CC: , , , , "John Garry" Subject: [PATCH v3 02/11] perf vendor events: fix error code in json_events() Date: Thu, 8 Mar 2018 18:58:27 +0800 Message-ID: <1520506716-197429-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520506716-197429-1-git-send-email-john.garry@huawei.com> References: <1520506716-197429-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain 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 Acked-by: Jiri Olsa --- tools/perf/pmu-events/jevents.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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; -- 1.9.1