Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F10EC6FA90 for ; Fri, 23 Sep 2022 13:27:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbiIWN1m (ORCPT ); Fri, 23 Sep 2022 09:27:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230110AbiIWN1g (ORCPT ); Fri, 23 Sep 2022 09:27:36 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 689C113BCC9 for ; Fri, 23 Sep 2022 06:27:35 -0700 (PDT) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MYtDx6lnxzHpk8; Fri, 23 Sep 2022 21:25:21 +0800 (CST) Received: from kwepemm600008.china.huawei.com (7.193.23.88) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 23 Sep 2022 21:27:33 +0800 Received: from huawei.com (10.175.100.227) by kwepemm600008.china.huawei.com (7.193.23.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 23 Sep 2022 21:27:32 +0800 From: Shang XiaoJing To: , , , , , , , CC: , , , , Subject: [PATCH v2 4/7] perf report: Fix error return code in cmd_report() Date: Fri, 23 Sep 2022 22:01:40 +0800 Message-ID: <20220923140143.21552-5-shangxiaojing@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220923140143.21552-1-shangxiaojing@huawei.com> References: <20220923140143.21552-1-shangxiaojing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.100.227] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600008.china.huawei.com (7.193.23.88) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org As many check functions have not assigned to the error code, reset the error return code in cmd_report as -EINVAL before a series of checks. Set the error code as -EINVAL when symbol__init() failed. Signed-off-by: Shang XiaoJing --- changes in v2: - adjust commit msg. - change the position of resetting the error code from "end of the evswitch__init()" to "start of a series of checks". --- tools/perf/builtin-report.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 8361890176c2..3775e5d0384c 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -1508,6 +1508,7 @@ int cmd_report(int argc, const char **argv) sort_order = "srcline,symbol,dso"; } + ret = -EINVAL; if (report.mem_mode) { if (sort__mode == SORT_MODE__BRANCH) { pr_err("branch and mem mode incompatible\n"); @@ -1644,8 +1645,10 @@ int cmd_report(int argc, const char **argv) annotation_config__init(&report.annotation_opts); } - if (symbol__init(&session->header.env) < 0) + if (symbol__init(&session->header.env) < 0) { + ret = -EINVAL; goto error; + } if (report.time_str) { ret = perf_time__parse_for_ranges(report.time_str, session, -- 2.17.1