Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1725216pxb; Thu, 7 Oct 2021 13:50:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUjqb9kw6LcGAD/akGZOg5Nu/bvXwa4+hAI0O14dmcUNcrCSmYWyyPuw2rlxQ3+M5GvmaT X-Received: by 2002:a17:907:1b02:: with SMTP id mp2mr8377251ejc.196.1633639807632; Thu, 07 Oct 2021 13:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633639807; cv=none; d=google.com; s=arc-20160816; b=e7H+HTYudlIKBgfsMae4LK5E6mWlkT0/U+bs/2T3irRh8B8ud8DgbVcYncqbBrnSdu 06qPqRJwZsaD927Z07FndYFVaJpE/ljXuZp2upemWaYxzvFHIzsknQoW8LcJ5VExSFGA tpCRigXctZ0T31tn+atdTv1fTW0y+lnOvgtZPNGVLWTDBNY8TU8NApHOxKD4pSaANA63 WXacMLZO5MMZ9ZN/bTDrcLeobKx3HietqUiIdvLlByuhZQDu0QmFuCSpAfqNAlORGFTS QVsVneMUXU/G1BuaMjRbSjhfGFXB6wnuRdR4DSDIz/RveFXoVUCoZwVetRny8PLfOzwR gUWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=DKk7gYA97LusEn3hP/5WaAwdmMnNvOjC0L8CB2TRhaQ=; b=093QcdwgKnsKSAbV2Oslb5i1T9USTKjzk5P40LLMYRDJJOsupCsRrm4IVW8Ae/cSN7 oxjaC9qj/CL5ni1vRmcQfqrigkoRY6jrigHSE0GfsVl5Kpx9qEwwywYjQIUt5hy/SOBK 8Xk5iCC8jqVWBsZRJmLAkUtHGKvg2JqgXdjeZuwpeQCB8GmNNWmc0wYxlYUqN5nmblM9 rnEXBX2dXYg5xwJ+q/8J783IFIf5YSxqE81LqjuIZOuP174Gm8EjDgngn8Gm+mneBlss MLmptz/k6n2v6CKgce5nw3gDvjz7DqhEiQGugodqDObGaE8TIHSsK4EvfSoZfWvewm2T 8vbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kEnpQJVS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si451660edj.620.2021.10.07.13.49.43; Thu, 07 Oct 2021 13:50:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kEnpQJVS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242994AbhJGRA1 (ORCPT + 99 others); Thu, 7 Oct 2021 13:00:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243057AbhJGRAM (ORCPT ); Thu, 7 Oct 2021 13:00:12 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE740C061755 for ; Thu, 7 Oct 2021 09:58:00 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id m14-20020a63fd4e000000b00287791fb324so192692pgj.7 for ; Thu, 07 Oct 2021 09:58:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=DKk7gYA97LusEn3hP/5WaAwdmMnNvOjC0L8CB2TRhaQ=; b=kEnpQJVS+QVYLkv0k9EOl9/iPyWj38/UT53Rbedj4smDTSO+jBirKuwgrq2PQ+BJrI bP7LIJVhbgROPmtSiXP118Q6rS4h4kyQ4NQ3ySD97KG3j5bt5eZX0Ybe7/OQVFiYng2Q wSpbXAU+a/iprUk17ZUijnUlllj+dWGWfQfyWaIJIrx/T0JI82vKZHWLtx30wambRS5s 5QuzFnz5p5CEJ9MRUFm5iV2gdMSjF9FAZW01MM87LVx3CiUd+C8Qxmu3nXCzpgeTok45 WJ9LVTirynlDgRFnBSW50yk3ZoXLf52zlI93wVyusOBErNKzVK2SvBfpRVOLM6YMxp2P NKWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=DKk7gYA97LusEn3hP/5WaAwdmMnNvOjC0L8CB2TRhaQ=; b=1FcPrgmcXL4xQNBkxjB1Ds8KPoxIUhdCPyEhPwAX1kRxMyw0jqEQTkkNqwbqpUnuub efV8UJwEyw33UVP9aKcO0f3rVzmQammHRtp2H492qQUD31K6kWrs77xJ5pWz8OKNSYDo /dUjYiURWkpkHQgsOAOyxKJZrxTbaxdXSP80pWbp+jpuEB87Oob5HVuDiZkJiGjpyY7Y WXzhO6vz3tHlcr7j1Sidgnmrq9T6gHPsj+9zWMVo/aq84JnnYk1gBwPwLbxjTeD8hqD7 /ZahzbgOHffo8BvZOH8SFDXl+4VLEJ3+t2f7zRUjaUUnInyvC/ZieZOlqld0JNZ3hXlU p1pg== X-Gm-Message-State: AOAM532dJb10SnX/Tp69LdH9byj1UM7yTIwYKTV2nN7rlJd++SH8u7Y9 /ItkBWR27AkFbPwXBdMF13GjymtLPKEe X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:fe85:5e36:cb6f:76bc]) (user=irogers job=sendgmr) by 2002:a17:90a:4dc6:: with SMTP id r6mr6707646pjl.5.1633625880291; Thu, 07 Oct 2021 09:58:00 -0700 (PDT) Date: Thu, 7 Oct 2021 09:56:39 -0700 In-Reply-To: <20211007165647.3514803-1-irogers@google.com> Message-Id: <20211007165647.3514803-14-irogers@google.com> Mime-Version: 1.0 References: <20211007165647.3514803-1-irogers@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [PATCH 13/21] perf parse-events: Add const to evsel name From: Ian Rogers To: Andi Kleen , Jiri Olsa , Jin Yao , Namhyung Kim , John Garry , Kajol Jain , "Paul A . Clarke" , Arnaldo Carvalho de Melo , Riccardo Mancini , Kan Liang , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Kees Cook , Sami Tolvanen , Nick Desaulniers , Andrew Morton , Jacob Keller , Zhen Lei , ToastC , Joakim Zhang , Felix Fietkau , Jiapeng Chong , Song Liu , Fabian Hemmer , Alexander Antonov , Nicholas Fraser , Adrian Hunter , Denys Zagorui , Wan Jiabing , Thomas Richter , Sumanth Korikkar , Heiko Carstens , Changbin Du , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The evsel name is strdup-ed before assignment and so can be const. A later change will add another similar string. Using const makes it clearer that these are not out arguments. Signed-off-by: Ian Rogers --- tools/perf/util/parse-events-hybrid.c | 15 +++++++++------ tools/perf/util/parse-events-hybrid.h | 6 ++++-- tools/perf/util/parse-events.c | 15 ++++++++------- tools/perf/util/parse-events.h | 7 ++++--- tools/perf/util/pmu.c | 2 +- tools/perf/util/pmu.h | 2 +- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/tools/perf/util/parse-events-hybrid.c b/tools/perf/util/parse-events-hybrid.c index b234d95fb10a..7e44deee1343 100644 --- a/tools/perf/util/parse-events-hybrid.c +++ b/tools/perf/util/parse-events-hybrid.c @@ -38,7 +38,7 @@ static void config_hybrid_attr(struct perf_event_attr *attr, static int create_event_hybrid(__u32 config_type, int *idx, struct list_head *list, - struct perf_event_attr *attr, char *name, + struct perf_event_attr *attr, const char *name, struct list_head *config_terms, struct perf_pmu *pmu) { @@ -70,7 +70,7 @@ static int pmu_cmp(struct parse_events_state *parse_state, static int add_hw_hybrid(struct parse_events_state *parse_state, struct list_head *list, struct perf_event_attr *attr, - char *name, struct list_head *config_terms) + const char *name, struct list_head *config_terms) { struct perf_pmu *pmu; int ret; @@ -94,7 +94,8 @@ static int add_hw_hybrid(struct parse_events_state *parse_state, } static int create_raw_event_hybrid(int *idx, struct list_head *list, - struct perf_event_attr *attr, char *name, + struct perf_event_attr *attr, + const char *name, struct list_head *config_terms, struct perf_pmu *pmu) { @@ -113,7 +114,7 @@ static int create_raw_event_hybrid(int *idx, struct list_head *list, static int add_raw_hybrid(struct parse_events_state *parse_state, struct list_head *list, struct perf_event_attr *attr, - char *name, struct list_head *config_terms) + const char *name, struct list_head *config_terms) { struct perf_pmu *pmu; int ret; @@ -138,7 +139,8 @@ static int add_raw_hybrid(struct parse_events_state *parse_state, int parse_events__add_numeric_hybrid(struct parse_events_state *parse_state, struct list_head *list, struct perf_event_attr *attr, - char *name, struct list_head *config_terms, + const char *name, + struct list_head *config_terms, bool *hybrid) { *hybrid = false; @@ -159,7 +161,8 @@ int parse_events__add_numeric_hybrid(struct parse_events_state *parse_state, } int parse_events__add_cache_hybrid(struct list_head *list, int *idx, - struct perf_event_attr *attr, char *name, + struct perf_event_attr *attr, + const char *name, struct list_head *config_terms, bool *hybrid, struct parse_events_state *parse_state) diff --git a/tools/perf/util/parse-events-hybrid.h b/tools/perf/util/parse-events-hybrid.h index f33bd67aa851..25a4a4f73f3a 100644 --- a/tools/perf/util/parse-events-hybrid.h +++ b/tools/perf/util/parse-events-hybrid.h @@ -11,11 +11,13 @@ int parse_events__add_numeric_hybrid(struct parse_events_state *parse_state, struct list_head *list, struct perf_event_attr *attr, - char *name, struct list_head *config_terms, + const char *name, + struct list_head *config_terms, bool *hybrid); int parse_events__add_cache_hybrid(struct list_head *list, int *idx, - struct perf_event_attr *attr, char *name, + struct perf_event_attr *attr, + const char *name, struct list_head *config_terms, bool *hybrid, struct parse_events_state *parse_state); diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 1acac3e13b32..88f181a985b7 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -337,7 +337,7 @@ static int parse_events__is_name_term(struct parse_events_term *term) return term->type_term == PARSE_EVENTS__TERM_TYPE_NAME; } -static char *get_config_name(struct list_head *head_terms) +static const char *get_config_name(struct list_head *head_terms) { struct parse_events_term *term; @@ -355,7 +355,7 @@ static struct evsel * __add_event(struct list_head *list, int *idx, struct perf_event_attr *attr, bool init_attr, - char *name, struct perf_pmu *pmu, + const char *name, struct perf_pmu *pmu, struct list_head *config_terms, bool auto_merge_stats, const char *cpu_list) { @@ -394,14 +394,14 @@ __add_event(struct list_head *list, int *idx, } struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr, - char *name, struct perf_pmu *pmu) + const char *name, struct perf_pmu *pmu) { return __add_event(NULL, &idx, attr, false, name, pmu, NULL, false, NULL); } static int add_event(struct list_head *list, int *idx, - struct perf_event_attr *attr, char *name, + struct perf_event_attr *attr, const char *name, struct list_head *config_terms) { return __add_event(list, idx, attr, true, name, NULL, config_terms, @@ -464,7 +464,8 @@ int parse_events_add_cache(struct list_head *list, int *idx, { struct perf_event_attr attr; LIST_HEAD(config_terms); - char name[MAX_NAME_LEN], *config_name; + char name[MAX_NAME_LEN]; + const char *config_name; int cache_type = -1, cache_op = -1, cache_result = -1; char *op_result[2] = { op_result1, op_result2 }; int i, n, ret; @@ -2027,7 +2028,7 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add) return 0; } -int parse_events_name(struct list_head *list, char *name) +int parse_events_name(struct list_head *list, const char *name) { struct evsel *evsel; @@ -3344,7 +3345,7 @@ char *parse_events_formats_error_string(char *additional_terms) struct evsel *parse_events__add_event_hybrid(struct list_head *list, int *idx, struct perf_event_attr *attr, - char *name, struct perf_pmu *pmu, + const char *name, struct perf_pmu *pmu, struct list_head *config_terms) { return __add_event(list, idx, attr, true, name, pmu, diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index b32ed3064c49..54d24c24d074 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -162,7 +162,7 @@ void parse_events_terms__purge(struct list_head *terms); void parse_events__clear_array(struct parse_events_array *a); int parse_events__modifier_event(struct list_head *list, char *str, bool add); int parse_events__modifier_group(struct list_head *list, char *event_mod); -int parse_events_name(struct list_head *list, char *name); +int parse_events_name(struct list_head *list, const char *name); int parse_events_add_tracepoint(struct list_head *list, int *idx, const char *sys, const char *event, struct parse_events_error *error, @@ -199,7 +199,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, bool use_alias); struct evsel *parse_events__add_event(int idx, struct perf_event_attr *attr, - char *name, struct perf_pmu *pmu); + const char *name, struct perf_pmu *pmu); int parse_events_multi_pmu_add(struct parse_events_state *parse_state, char *str, @@ -266,7 +266,8 @@ int perf_pmu__test_parse_init(void); struct evsel *parse_events__add_event_hybrid(struct list_head *list, int *idx, struct perf_event_attr *attr, - char *name, struct perf_pmu *pmu, + const char *name, + struct perf_pmu *pmu, struct list_head *config_terms); #endif /* __PERF_PARSE_EVENTS_H */ diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index cdd6c3f6caf1..9b5039bf909a 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1906,7 +1906,7 @@ int perf_pmu__caps_parse(struct perf_pmu *pmu) } void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config, - char *name) + const char *name) { struct perf_pmu_format *format; __u64 masks = 0, bits; diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index cc9f9e001347..f9743eab07b6 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -134,7 +134,7 @@ int perf_pmu__convert_scale(const char *scale, char **end, double *sval); int perf_pmu__caps_parse(struct perf_pmu *pmu); void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config, - char *name); + const char *name); bool perf_pmu__has_hybrid(void); int perf_pmu__match(char *pattern, char *name, char *tok); -- 2.33.0.882.g93a45727a2-goog