summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSun Haiyong <sunhaiyong@loongson.cn>2024-01-06 17:41:29 +0800
committerJaehoon Chung <jh80.chung@samsung.com>2024-11-12 13:03:20 +0900
commit2c0d503b64d9f07f5a2cb8a0028a7f4be33e4894 (patch)
tree368e8f36d9bb9dbe78bad075eb80d6da35b91bf6
parent2d35eb0381ea1ddfafcb7bbaada8ca715519a891 (diff)
downloadlinux-rpi-2c0d503b64d9f07f5a2cb8a0028a7f4be33e4894.tar.gz
linux-rpi-2c0d503b64d9f07f5a2cb8a0028a7f4be33e4894.tar.bz2
linux-rpi-2c0d503b64d9f07f5a2cb8a0028a7f4be33e4894.zip
perf tools: Fix calloc() arguments to address error introduced in gcc-14
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. Fix error messages on gcc 14 20240102: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] Committer notes: I noticed this on fedora 40 and rawhide. Signed-off-by: Sun Haiyong <sunhaiyong@loongson.cn> Acked-by: Namhyung Kim <namhyung@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20240106094129.3337057-1-siyanteng@loongson.cn Signed-off-by: Yanteng Si <siyanteng@loongson.cn> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> [sw0312.kim: cherry-pick the mainline commit 7bbe8f0071df to resolve gcc-14 warning] Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> Change-Id: I504783bde6c91fec425b8d955557f28cef97f950
-rw-r--r--tools/perf/builtin-record.c4
-rw-r--r--tools/perf/util/hist.c4
-rw-r--r--tools/perf/util/metricgroup.c2
-rw-r--r--tools/perf/util/synthetic-events.c4
4 files changed, 7 insertions, 7 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index b94ae33a343c..9796bcee271b 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -4036,8 +4036,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 aa450cc2648a..ef0f7aefc4b1 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 bb5faaa25d51..df1595b69528 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 a0579c7d7b9e..7577e63515df 100644
--- a/tools/perf/util/synthetic-events.c
+++ b/tools/perf/util/synthetic-events.c
@@ -1039,11 +1039,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;