From: Veronika Molnarova <vmolnaro@redhat.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
Ian Rogers <irogers@google.com>,
James Clark <james.clark@arm.com>, Jiri Olsa <jolsa@kernel.org>,
Kan Liang <kan.liang@linux.intel.com>,
Michael Petlan <mpetlan@redhat.com>,
Namhyung Kim <namhyung@kernel.org>,
Radostin Stoyanov <rstoyano@redhat.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] perf tests pmu: Initialize all fields of test_pmu variable
Date: Mon, 12 Aug 2024 16:05:28 +0200 [thread overview]
Message-ID: <e26941f9-f86c-4f2e-b812-20c49fb2c0d3@redhat.com> (raw)
In-Reply-To: <ZroIIXkmErNGZjQO@x1>
On 8/12/24 15:03, Arnaldo Carvalho de Melo wrote:
> Instead of explicitely initializing just the .name and .alias_name,
> use struct member named initialization of just the non-null -name field,
> the compiler will initialize all the other non-explicitely initialized
> fields to NULL.
>
> This makes the code more robust, avoiding the error recently fixed when
> the .alias_name was used and contained a random value.
>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Ian Rogers <irogers@google.com>
> Cc: James Clark <james.clark@arm.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Kan Liang <kan.liang@linux.intel.com>
> Cc: Michael Petlan <mpetlan@redhat.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Radostin Stoyanov <rstoyano@redhat.com>
> Cc: Veronika Molnarova <vmolnaro@redhat.com>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
> tools/perf/tests/pmu.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c
> index a4730b5dc0d9259d..be18506f6a242546 100644
> --- a/tools/perf/tests/pmu.c
> +++ b/tools/perf/tests/pmu.c
> @@ -458,10 +458,10 @@ static int test__name_cmp(struct test_suite *test __maybe_unused, int subtest __
> */
> static int test__pmu_match(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
> {
> - struct perf_pmu test_pmu;
> - test_pmu.alias_name = NULL;
> + struct perf_pmu test_pmu = {
> + .name = "pmuname",
> + };
>
> - test_pmu.name = "pmuname";
> TEST_ASSERT_EQUAL("Exact match", perf_pmu__match(&test_pmu, "pmuname"), true);
> TEST_ASSERT_EQUAL("Longer token", perf_pmu__match(&test_pmu, "longertoken"), false);
> TEST_ASSERT_EQUAL("Shorter token", perf_pmu__match(&test_pmu, "pmu"), false);
Reviewed-by: Veronika Molnarova <vmolnaro@redhat.com>
Thanks for the rework,
Veronika
next prev parent reply other threads:[~2024-08-12 14:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-12 13:03 Arnaldo Carvalho de Melo
2024-08-12 14:05 ` Veronika Molnarova [this message]
2024-08-29 20:17 ` Ian Rogers
2024-08-29 21:09 ` Arnaldo Carvalho de Melo
2024-08-30 3:49 ` Namhyung Kim
2024-08-30 13:37 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e26941f9-f86c-4f2e-b812-20c49fb2c0d3@redhat.com \
--to=vmolnaro@redhat.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@arm.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpetlan@redhat.com \
--cc=namhyung@kernel.org \
--cc=rstoyano@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®