[PATCH v2 2/7] perf: Use perf_pmu__open_file() and perf_pmu__scan_file()

Leo Yan leo.yan at linaro.org
Thu Dec 22 19:59:51 PST 2022


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



More information about the linux-arm-kernel mailing list