Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6951397rwr; Wed, 10 May 2023 01:29:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7O9o4S2lqrLchk+oNEn/dJ5mENDMZUEl6DvwKQgg1Y4+6ad7GWTBqX6FskOBv/ZiUXs4Qy X-Received: by 2002:a05:6a20:4328:b0:101:1d1d:4396 with SMTP id h40-20020a056a20432800b001011d1d4396mr7721920pzk.2.1683707390757; Wed, 10 May 2023 01:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683707390; cv=none; d=google.com; s=arc-20160816; b=MiFXUl2+pWklejiiDu2xON5bfKEXVMpn92w7VbdV6ed4YBtiw7IwRB666yVhv5Y4LO RRsyv1W/PM9Ix9cawHMtbXE0zWuaWvltAOioqyozc/69Ne8bOkaAJeyBRDGCG3wTWNfR zILEOImfgna3nSL0u7vwRfCBpPB/BuTx4wVbsYFuFJfOVln1uhYsebKsCyc7udtimmpC BxrAEMM0NyxvBxmCAxTectYD1u61bAt3Cz1o+T4Uex1DtYFathmgOwt3YDD8imui/mnX 9DFnNAtIt5wNLXJruytgiYk99a/Qqs6r84w/kbhsJsfD6iKah6v/luS35y9384e/gRA5 uLEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject; bh=QG3Th//a6rVpsM5IBZDuAwLnaKxkCTtYrTX9yFtplPU=; b=hVOUn9clxuetMOT3Bi+T9f9MJAA5hCuheCeQb28fKl3sw5cWqtg0D47YbVSHgS2B5G zNdWdkCajWNaYzErP0/6HcxkITSOEw43grzxhW9swAM38tQDdEXut3sjcV4YHrrIPIvZ Gj1wPFqoy4Fz71GSUAbsbDMXMUEqbv81e+NQju8x1riVIfHnGwhIpaAdUzmwcWmgahN/ lYCWQidjs98jTeGQz1jVXLdtBCSzRTKM2bOrs8qajKre0uUmZf9wY9TLfhcbFQK8fCSY zOeGh1x91AbwgNA4VR4icI0nADJhxvVuuCts9hdK2nKJyZpP1jJkAuv+gRd6BAEtMdYL EEWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f15-20020a17090ac28f00b002477fad79d5si16645655pjt.63.2023.05.10.01.29.38; Wed, 10 May 2023 01:29:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236481AbjEJIJu (ORCPT + 99 others); Wed, 10 May 2023 04:09:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236532AbjEJIJn (ORCPT ); Wed, 10 May 2023 04:09:43 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1000630D8; Wed, 10 May 2023 01:09:41 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QGSKh5skLzLpYR; Wed, 10 May 2023 16:06:48 +0800 (CST) Received: from [10.67.111.205] (10.67.111.205) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 10 May 2023 16:09:38 +0800 Subject: Re: [PATCH 1/4] perf trace-event-info: Add tracepoint_id_to_name() helper To: Adrian Hunter , , , , , , , , , , , , References: <20230419122912.73746-1-yangjihong1@huawei.com> <20230419122912.73746-2-yangjihong1@huawei.com> <07770bac-cbeb-170e-b3c1-d0276d4ffef3@intel.com> From: Yang Jihong Message-ID: <6d03b9cc-31c8-37c3-3e82-504be8712dee@huawei.com> Date: Wed, 10 May 2023 16:09:37 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <07770bac-cbeb-170e-b3c1-d0276d4ffef3@intel.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.111.205] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On 2023/5/10 15:48, Adrian Hunter wrote: > On 19/04/23 15:29, Yang Jihong wrote: >> Add tracepoint_id_to_name() helper to search for the trace events directory >> by given event id and return the corresponding tracepoint. >> >> Signed-off-by: Yang Jihong >> --- >> tools/perf/util/trace-event-info.c | 13 +++++++++++++ >> tools/perf/util/trace-event.h | 6 ++++++ >> 2 files changed, 19 insertions(+) >> >> diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c >> index c24b3a15e319..79907caaf0ca 100644 >> --- a/tools/perf/util/trace-event-info.c >> +++ b/tools/perf/util/trace-event-info.c >> @@ -466,6 +466,19 @@ static struct tracepoint_path *tracepoint_id_to_path(u64 config) >> return NULL; >> } >> >> +char *tracepoint_id_to_name(u64 config) >> +{ >> + char buf[MAX_EVENT_LENGTH]; >> + struct tracepoint_path *path = NULL; > > Initializer should be tracepoint_id_to_path(config) i.e. > OK, will fix in next version. > struct tracepoint_path *path = tracepoint_id_to_path(config); > >> + >> + path = tracepoint_id_to_path(config); >> + if (path == NULL) >> + return NULL; >> + >> + snprintf(buf, sizeof(buf), "%s:%s", path->system, path->name); > > asprintf() can be used then buf and strdup() are not needed. > OK, will fix in next version. Thanks for correcting. Thanks, Yang