From patchwork Thu Mar 8 10:58:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 130993 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp6332585lja; Thu, 8 Mar 2018 03:02:02 -0800 (PST) X-Google-Smtp-Source: AG47ELvnUBsV2ZoiHHBWki3TcYypARoAFHz5XjXVVOqKbY4Nno8tN0NsZ9biIr3xnS9YtydHmwfD X-Received: by 2002:a17:902:b187:: with SMTP id s7-v6mr23802765plr.448.1520506922422; Thu, 08 Mar 2018 03:02:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520506922; cv=none; d=google.com; s=arc-20160816; b=CiPi8tFS6W3KDUTA4BTCKhTfi2u5OpNhyHUne0yv04xFFEBYn/77xBjV2WW9ONW/wP iuLaDJzdLNLOiD1lljTJPRgaczljX4c0GXGAo4rgLim4ZmsswS4w5nS53sU4nP0gou62 QPk4ge/NxR6Nxh0PCpnjaR1sN3VaqbAELsUWphOsIPTMYsSzPd2td9VZKR2oN/UBtTMI DLTjqIvi4hhR7aZNWhfvbyMJPnkgaXl1FPRN3LPAia13BPzFxgdjP7JnAsuHJGc6Rxah gt94/UuI0c8CVbXcE7sg1aKt/uGAKBbK6g+1Aw27TnN/G6bvL9mkL59nGFBYFA+uTE3F pKTA== 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 s16-v6si14863704plk.550.2018.03.08.03.02.02; Thu, 08 Mar 2018 03:02:02 -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 S1755798AbeCHK7p (ORCPT + 28 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 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(-) -- 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;