From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Yanteng Si <siyanteng@loongson.cn>
Cc: peterz@infradead.org, mingo@redhat.com,
linux-perf-users@vger.kernel.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com,
Sun Haiyong <sunhaiyong@loongson.cn>
Subject: Re: [PATCH] tools/perf: Fix compiler error when using gcc-14.
Date: Tue, 30 Jan 2024 10:56:56 -0300 [thread overview]
Message-ID: <ZbkAKA8g4Z_XlMNh@kernel.org> (raw)
In-Reply-To: <20240106094129.3337057-1-siyanteng@loongson.cn>
Em Sat, Jan 06, 2024 at 05:41:29PM +0800, Yanteng Si escreveu:
> From: Sun Haiyong <sunhaiyong@loongson.cn>
>
> the definition of calloc is as follows:
> void *calloc(size_t nmemb, size_t size);
> number of members is in the first parameter and the size is in the second
> parameter.
>
> fixed error message on the gcc 14 20240102:
> error: 'calloc' sizes specified with 'sizeof' in the earlier argument and
> not in the later argument [-Werror=calloc-transposed-args]
Just fyi I merged this into perf-tools.
- Arnaldo
> Signed-off-by: Sun Haiyong <sunhaiyong@loongson.cn>
> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> ---
> tools/perf/builtin-record.c | 4 ++--
> tools/perf/util/hist.c | 4 ++--
> tools/perf/util/metricgroup.c | 2 +-
> tools/perf/util/synthetic-events.c | 4 ++--
> 4 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 91e6828c38cc..86c910125172 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -4080,8 +4080,8 @@ int cmd_record(int argc, const char **argv)
> }
>
> if (rec->switch_output.num_files) {
> - rec->switch_output.filenames = calloc(sizeof(char *),
> - rec->switch_output.num_files);
> + rec->switch_output.filenames = calloc(rec->switch_output.num_files,
> + sizeof(char *));
> if (!rec->switch_output.filenames) {
> err = -EINVAL;
> goto out_opts;
> diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
> index 0888b7163b7c..fa359180ebf8 100644
> --- a/tools/perf/util/hist.c
> +++ b/tools/perf/util/hist.c
> @@ -491,8 +491,8 @@ static int hist_entry__init(struct hist_entry *he,
> }
>
> if (symbol_conf.res_sample) {
> - he->res_samples = calloc(sizeof(struct res_sample),
> - symbol_conf.res_sample);
> + he->res_samples = calloc(symbol_conf.res_sample,
> + sizeof(struct res_sample));
> if (!he->res_samples)
> goto err_srcline;
> }
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index ca3e0404f187..966cca5a3e88 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -286,7 +286,7 @@ static int setup_metric_events(const char *pmu, struct hashmap *ids,
> *out_metric_events = NULL;
> ids_size = hashmap__size(ids);
>
> - metric_events = calloc(sizeof(void *), ids_size + 1);
> + metric_events = calloc(ids_size + 1, sizeof(void *));
> if (!metric_events)
> return -ENOMEM;
>
> diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
> index 3712186353fb..2a0289c14959 100644
> --- a/tools/perf/util/synthetic-events.c
> +++ b/tools/perf/util/synthetic-events.c
> @@ -1055,11 +1055,11 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
> if (thread_nr > n)
> thread_nr = n;
>
> - synthesize_threads = calloc(sizeof(pthread_t), thread_nr);
> + synthesize_threads = calloc(thread_nr, sizeof(pthread_t));
> if (synthesize_threads == NULL)
> goto free_dirent;
>
> - args = calloc(sizeof(*args), thread_nr);
> + args = calloc(thread_nr, sizeof(*args));
> if (args == NULL)
> goto free_threads;
>
> --
> 2.31.4
>
--
- Arnaldo
prev parent reply other threads:[~2024-01-30 13:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-06 9:41 [PATCH] tools/perf: Fix compiler error when using gcc-14 Yanteng Si
2024-01-08 22:09 ` Namhyung Kim
2024-01-30 13:56 ` Arnaldo Carvalho de Melo [this message]
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=ZbkAKA8g4Z_XlMNh@kernel.org \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=siyanteng@loongson.cn \
--cc=sunhaiyong@loongson.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.