lkml.org 
[lkml]   [2022]   [Dec]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 2/7] perf: Use perf_pmu__open_file() and perf_pmu__scan_file()
On Fri, Dec 23, 2022 at 11:45:21AM +0800, Leo Yan wrote:

[...]

> > @@ -103,8 +103,9 @@ static int test__perf_evsel__roundtrip_name_test(struct test_suite *test __maybe
> > int subtest __maybe_unused)
> > {
> > int err = 0, ret = 0;
> > + char cpu_atom[] = "cpu_atom";
> >
> > - if (perf_pmu__has_hybrid() && perf_pmu__hybrid_mounted("cpu_atom"))
> > + if (perf_pmu__has_hybrid() && perf_pmu__hybrid_mounted(cpu_atom))
>
> After change the parameter 'name' to non const type in function
> perf_pmu__hybrid_mounted(), at here we still can pass string "cpu_atom"
> without warning, right? If so, we don't need to define a local
> variable 'cpu_atom'.

Correct for above statement, I did experiment and confirmed building
failure after change the parameter to non const type and directly pass
string "cpu_atom":

tests/evsel-roundtrip-name.c: In function ‘test__perf_evsel__roundtrip_name_test’:
tests/evsel-roundtrip-name.c:108:64: error: passing argument 1 of ‘perf_pmu__hybrid_mounted’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
108 | if (perf_pmu__has_hybrid() && perf_pmu__hybrid_mounted("cpu_atom"))
| ^~~~~~~~~~

But I still suggest we can keep const type for the parameter for
perf_pmu__hybrid_mounted(), this is more friendly for its callers
without define local strings.

Thanks,
Leo

\
 
 \ /
  Last update: 2023-03-26 23:18    [W:0.039 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site