From patchwork Tue Mar 13 12:04:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 131460 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp651516ljb; Tue, 13 Mar 2018 05:12:36 -0700 (PDT) X-Google-Smtp-Source: AG47ELuq/WMnt6h8IjGZIL77RghBtf1aVVyeJuhIvVVhApxsQsAlt1T7OQYwzP1kH6/FRg6yr+Bs X-Received: by 2002:a17:902:1c5:: with SMTP id b63-v6mr346016plb.311.1520943156201; Tue, 13 Mar 2018 05:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520943156; cv=none; d=google.com; s=arc-20160816; b=ZIK8bfURk8kgmvOQDLwRmVrfTqCSpehMBqW0Nj/7lJUGlfd5XTj33EtODFTjdp6me1 OhMfZCntmgvAeVSggamP5V2USwrLnmv6c5MpF5j+lOdh6mqEM66inh2CHPoeSB279LfN rVLSag++OanKUC3qTwRIOz56KQhsW/AqPVck5OOQQIKu+sHK/pR+jiXDCQ0aRM6P3lCv Sj0GIgYn3/8Yygqf+wUTrgjwW0GIPTvcT1GJifT/WKSIXBlQARxu97n1Q7lnd8B05KH6 jFJNiEuDh2SQwBNEoh0fhFxyG1tyRqlg1Fwum57vO4wSadqNxcuswXFiinxlRpCYN8P+ NCzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:arc-authentication-results; bh=1DuhYB5rou/GYFAvv9B0rpxFrtAVBAT5X6w9+sxUQc4=; b=qe5nyom95tvfpksruzGSrwQWkFP1vNqJI1w1wRvSbUZLT5CwB1WGUz3Pw39vU0qVBZ 1s9//xLdi8kVGD9uUla1lIRsc2Hp41v0lqZDyMN38Jg6BklbiLi1O4NoGZdDNlnko/E3 DUmcf1SgS0z48JW5Q4TXOZOryRFI5LAv909PGIAqev6yqaAs24iwImjjaw+pHKHJIVUv hb53ADOlRUDs8hy2+mGrcaCbNeIPeJ2xXImGWcBtTjflSFZXcA56eWLUUB92Obk7ArlQ 57lI49PP9AHfULnJyyTHN9+6fRJiSw8UTY5y8PRbnuoLd6SuIZf0ULZ/nhniVi4lIrPP fvdg== 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 k66si42010pfa.415.2018.03.13.05.12.35; Tue, 13 Mar 2018 05:12:36 -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 S933249AbeCMMGG (ORCPT + 28 others); Tue, 13 Mar 2018 08:06:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:54776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933198AbeCMMGE (ORCPT ); Tue, 13 Mar 2018 08:06:04 -0400 Received: from jouet.infradead.org (unknown [177.79.83.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A52DE21783; Tue, 13 Mar 2018 12:05:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A52DE21783 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, John Garry , Alexander Shishkin , Andi Kleen , Ganapatrao Kulkarni , Namhyung Kim , Peter Zijlstra , Shaokun Zhang , Will Deacon , William Cohen , linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com, Arnaldo Carvalho de Melo Subject: [PATCH 12/31] perf vendor events: Fix error code in json_events() Date: Tue, 13 Mar 2018 09:04:49 -0300 Message-Id: <20180313120508.29327-13-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313120508.29327-1-acme@kernel.org> References: <20180313120508.29327-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Garry 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 Cc: Alexander Shishkin Cc: Andi Kleen Cc: Ganapatrao Kulkarni Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Shaokun Zhang Cc: Will Deacon Cc: William Cohen Cc: linux-arm-kernel@lists.infradead.org Cc: linuxarm@huawei.com Link: http://lkml.kernel.org/r/1520506716-197429-3-git-send-email-john.garry@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/pmu-events/jevents.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.14.3 diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index 9e0a21e74a67..edff989fbcea 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;