From patchwork Fri Feb 19 22:41:22 2016 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: 62414 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp61576lbl; Fri, 19 Feb 2016 14:45:22 -0800 (PST) X-Received: by 10.98.72.133 with SMTP id q5mr21766379pfi.166.1455921922827; Fri, 19 Feb 2016 14:45:22 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12si19076841pfi.251.2016.02.19.14.45.22; Fri, 19 Feb 2016 14:45:22 -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 S1949763AbcBSWo7 (ORCPT + 30 others); Fri, 19 Feb 2016 17:44:59 -0500 Received: from casper.infradead.org ([85.118.1.10]:37502 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1949522AbcBSWlw (ORCPT ); Fri, 19 Feb 2016 17:41:52 -0500 Received: from [187.65.76.58] (helo=jouet.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.85 #2 (Red Hat Linux)) id 1aWtkB-0005wk-FM; Fri, 19 Feb 2016 22:41:47 +0000 Received: by jouet.infradead.org (Postfix, from userid 1000) id E5027144FDE; Fri, 19 Feb 2016 19:41:38 -0300 (BRT) From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Wang Nan , Adrian Hunter , Alexei Starovoitov , Brendan Gregg , Cody P Schafer , He Kuang , Jeremie Galarneau , Jiri Olsa , Kirill Smelkov , Li Zefan , Masami Hiramatsu , Namhyung Kim , Peter Zijlstra , pi3orama@163.com, stable@vger.kernel.org, #@infradead.org, v4.4+@infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 08/22] perf tools: Fix checking asprintf return value Date: Fri, 19 Feb 2016 19:41:22 -0300 Message-Id: <1455921696-3895-9-git-send-email-acme@kernel.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455921696-3895-1-git-send-email-acme@kernel.org> References: <1455921696-3895-1-git-send-email-acme@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wang Nan According to man pages, asprintf returns -1 when failure. This patch fixes two incorrect return value checker. Signed-off-by: Wang Nan Cc: Adrian Hunter Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Cody P Schafer Cc: He Kuang Cc: Jeremie Galarneau Cc: Jiri Olsa Cc: Kirill Smelkov Cc: Li Zefan Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Zefan Li Cc: pi3orama@163.com Cc: stable@vger.kernel.org # v4.4+ Fixes: ffeb883e5662 ("perf tools: Show proper error message for wrong terms of hw/sw events") Link: http://lkml.kernel.org/r/1455882283-79592-5-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/parse-events.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.5.0 diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index e5583fd4e7bd..72524c755b11 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2110,11 +2110,11 @@ char *parse_events_formats_error_string(char *additional_terms) /* valid terms */ if (additional_terms) { - if (!asprintf(&str, "valid terms: %s,%s", - additional_terms, static_terms)) + if (asprintf(&str, "valid terms: %s,%s", + additional_terms, static_terms) < 0) goto fail; } else { - if (!asprintf(&str, "valid terms: %s", static_terms)) + if (asprintf(&str, "valid terms: %s", static_terms) < 0) goto fail; } return str;