From: Leo Yan <leo.yan@arm.com>
To: Ian Rogers <irogers@google.com>
Cc: "Yury Norov" <yury.norov@gmail.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Arnaldo Carvalho de Melo" <acme@kernel.org>,
"Namhyung Kim" <namhyung@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Jiri Olsa" <jolsa@kernel.org>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"Kan Liang" <kan.liang@linux.intel.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Darren Hart" <dvhart@infradead.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"André Almeida" <andrealmeid@igalia.com>,
"John Garry" <john.g.garry@oracle.com>,
"Will Deacon" <will@kernel.org>,
"James Clark" <james.clark@linaro.org>,
"Mike Leach" <mike.leach@linaro.org>,
"Leo Yan" <leo.yan@linux.dev>,
"Yicong Yang" <yangyicong@hisilicon.com>,
"Jonathan Cameron" <jonathan.cameron@huawei.com>,
"Nathan Chancellor" <nathan@kernel.org>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
"Josh Poimboeuf" <jpoimboe@kernel.org>,
"Al Viro" <viro@zeniv.linux.org.uk>,
"Kyle Meyer" <kyle.meyer@hpe.com>,
"Ben Gainey" <ben.gainey@arm.com>,
"Athira Rajeev" <atrajeev@linux.vnet.ibm.com>,
"Kajol Jain" <kjain@linux.ibm.com>,
"Aditya Gupta" <adityag@linux.ibm.com>,
"Eder Zulian" <ezulian@redhat.com>,
"Dapeng Mi" <dapeng1.mi@linux.intel.com>,
"Kuan-Wei Chiu" <visitorckw@gmail.com>,
"He Zhe" <zhe.he@windriver.com>,
"Dirk Gouders" <dirk@gouders.net>,
"Brian Geffon" <bgeffon@google.com>,
"Ravi Bangoria" <ravi.bangoria@amd.com>,
"Howard Chu" <howardchu95@gmail.com>,
"Charlie Jenkins" <charlie@rivosinc.com>,
"Colin Ian King" <colin.i.king@gmail.com>,
"Dominique Martinet" <asmadeus@codewreck.org>,
"Jann Horn" <jannh@google.com>,
"Masahiro Yamada" <masahiroy@kernel.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Yang Jihong" <yangjihong@bytedance.com>,
"Dmitry Vyukov" <dvyukov@google.com>,
"Andi Kleen" <ak@linux.intel.com>,
"Graham Woodward" <graham.woodward@arm.com>,
"Ilkka Koskinen" <ilkka@os.amperecomputing.com>,
"Anshuman Khandual" <anshuman.khandual@arm.com>,
"Zhongqiu Han" <quic_zhonhan@quicinc.com>,
"Hao Ge" <gehao@kylinos.cn>,
"Tengda Wu" <wutengda@huaweicloud.com>,
"Gabriele Monaco" <gmonaco@redhat.com>,
"Chun-Tse Shao" <ctshao@google.com>,
"Casey Chen" <cachen@purestorage.com>,
"Dr. David Alan Gilbert" <linux@treblig.org>,
"Li Huafei" <lihuafei1@huawei.com>,
"Steinar H. Gunderson" <sesse@google.com>,
"Levi Yun" <yeoreum.yun@arm.com>,
"Weilin Wang" <weilin.wang@intel.com>,
"Thomas Falcon" <thomas.falcon@intel.com>,
"Thomas Richter" <tmricht@linux.ibm.com>,
"Andrew Kreimer" <algonell@gmail.com>,
"Krzysztof Łopatowski" <krzysztof.m.lopatowski@gmail.com>,
"Christophe Leroy" <christophe.leroy@csgroup.eu>,
"Jean-Philippe Romain" <jean-philippe.romain@foss.st.com>,
"Junhao He" <hejunhao3@huawei.com>,
"Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
"Xu Yang" <xu.yang_2@nxp.com>,
"Steve Clevenger" <scclevenger@os.amperecomputing.com>,
"Zixian Cai" <fzczx123@gmail.com>,
"Stephen Brennan" <stephen.s.brennan@oracle.com>,
"Yujie Liu" <yujie.liu@intel.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev
Subject: Re: [PATCH v1 09/48] perf tests: Silence -Wshorten-64-to-32 warnings
Date: Wed, 2 Apr 2025 15:35:41 +0100 [thread overview]
Message-ID: <20250402143541.GM115840@e132581.arm.com> (raw)
In-Reply-To: <20250401182347.3422199-10-irogers@google.com>
On Tue, Apr 01, 2025 at 11:23:07AM -0700, Ian Rogers wrote:
[...]
> @@ -478,13 +478,14 @@ static int __cmd_test(struct test_suite **suites, int argc, const char *argv[],
> int err = 0;
>
> for (struct test_suite **t = suites; *t; t++) {
> - int i, len = strlen(test_description(*t, -1));
> + int i;
> + int len = (int)strlen(test_description(*t, -1));
Thanks for huge polish.
Just a concern from me. Throughout this patch, the methodology is not
consistent. Some changes update variable types which is fine for me.
But the case above it simply cast size_t to int. Should we update the
variable type as 'size_t' at here?
> if (width < len)
> width = len;
>
> test_suite__for_each_test_case(*t, i) {
> - len = strlen(test_description(*t, i));
> + len = (int)strlen(test_description(*t, i));
> if (width < len)
> width = len;
> num_tests += runs_per_test;
> diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
> index cf6edbe697b2..0c31d5ff77e2 100644
> --- a/tools/perf/tests/code-reading.c
> +++ b/tools/perf/tests/code-reading.c
> @@ -188,7 +188,7 @@ static int objdump_version(void)
> char *line = NULL;
> const char *fmt;
> FILE *f;
> - int ret;
> + ssize_t ret;
>
> int version_tmp, version_num = 0;
> char *version = 0, *token;
> @@ -295,7 +295,7 @@ static int read_via_objdump(const char *filename, u64 addr, void *buf,
> if (len) {
> pr_debug("objdump read too few bytes: %zd\n", len);
> if (!ret)
> - ret = len;
> + ret = (int)len;
A proper change is to update the function type to:
size_t read_via_objdump(...)
[...]
> diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
> index db004d26fcb0..2762794827ce 100644
> --- a/tools/perf/tests/pmu-events.c
> +++ b/tools/perf/tests/pmu-events.c
> @@ -609,7 +609,7 @@ static int __test_uncore_pmu_event_aliases(struct perf_pmu_test_pmu *test_pmu)
> pmu_add_sys_aliases(pmu);
>
> /* Count how many aliases we generated */
> - alias_count = perf_pmu__num_events(pmu);
> + alias_count = (int)perf_pmu__num_events(pmu);
Could we change the variable 'alias_count' to size_t type?
Or in another way, we need to update perf_pmu__num_events() with
returning int type.
My understanding is rather than using cast, we should polish code for
using consistent type for both variables and return values.
> /* Count how many aliases we expect from the known table */
> for (table = &test_pmu->aliases[0]; *table; table++)
> diff --git a/tools/perf/tests/sigtrap.c b/tools/perf/tests/sigtrap.c
> index a67c756f90b8..b7d7735f8a72 100644
> --- a/tools/perf/tests/sigtrap.c
> +++ b/tools/perf/tests/sigtrap.c
> @@ -154,13 +154,13 @@ sigtrap_handler(int signum __maybe_unused, siginfo_t *info, void *ucontext __may
> {
> if (!__atomic_fetch_add(&ctx.signal_count, 1, __ATOMIC_RELAXED))
> ctx.first_siginfo = *info;
> - __atomic_fetch_sub(&ctx.tids_want_signal, syscall(SYS_gettid), __ATOMIC_RELAXED);
> + __atomic_fetch_sub(&ctx.tids_want_signal, (pid_t)syscall(SYS_gettid), __ATOMIC_RELAXED);
> }
>
> static void *test_thread(void *arg)
> {
> pthread_barrier_t *barrier = (pthread_barrier_t *)arg;
> - pid_t tid = syscall(SYS_gettid);
> + pid_t tid = (pid_t)syscall(SYS_gettid);
> int i;
>
> pthread_barrier_wait(barrier);
> diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
> index 8df3f9d9ffd2..1f0f8321ae40 100644
> --- a/tools/perf/tests/switch-tracking.c
> +++ b/tools/perf/tests/switch-tracking.c
> @@ -140,8 +140,8 @@ static int process_sample_event(struct evlist *evlist,
>
> evsel = evlist__id2evsel(evlist, sample.id);
> if (evsel == switch_tracking->switch_evsel) {
> - next_tid = evsel__intval(evsel, &sample, "next_pid");
> - prev_tid = evsel__intval(evsel, &sample, "prev_pid");
> + next_tid = (int)evsel__intval(evsel, &sample, "next_pid");
> + prev_tid = (int)evsel__intval(evsel, &sample, "prev_pid");
Change 'prev_tid' and 'next_tid' to pid_t type?
Thanks,
Leo
> cpu = sample.cpu;
> pr_debug3("sched_switch: cpu: %d prev_tid %d next_tid %d\n",
> cpu, prev_tid, next_tid);
> @@ -262,9 +262,10 @@ static int compar(const void *a, const void *b)
> {
> const struct event_node *nodea = a;
> const struct event_node *nodeb = b;
> - s64 cmp = nodea->event_time - nodeb->event_time;
>
> - return cmp;
> + if (nodea->event_time == nodeb->event_time)
> + return 0;
> + return nodea->event_time < nodeb->event_time ? -1 : 1;
> }
>
> static int process_events(struct evlist *evlist,
> @@ -398,7 +399,7 @@ static int test__switch_tracking(struct test_suite *test __maybe_unused, int sub
>
> switch_evsel = evlist__add_sched_switch(evlist, true);
> if (IS_ERR(switch_evsel)) {
> - err = PTR_ERR(switch_evsel);
> + err = (int)PTR_ERR(switch_evsel);
> pr_debug("Failed to create event %s\n", sched_switch);
> goto out_err;
> }
> diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
> index 74cdbd2ce9d0..fbdb463e965d 100644
> --- a/tools/perf/tests/vmlinux-kallsyms.c
> +++ b/tools/perf/tests/vmlinux-kallsyms.c
> @@ -82,7 +82,7 @@ static bool is_ignored_symbol(const char *name, char type)
> return true;
>
> for (p = ignored_suffixes; *p; p++) {
> - int l = strlen(name) - strlen(*p);
> + ssize_t l = strlen(name) - strlen(*p);
>
> if (l >= 0 && !strcmp(name + l, *p))
> return true;
> @@ -313,7 +313,7 @@ static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused
> * _really_ have a problem.
> */
> s64 skew = mem_end - UM(pair->end);
> - if (llabs(skew) >= page_size)
> + if (llabs(skew) >= (s64)page_size)
> pr_debug("WARN: %#" PRIx64 ": diff end addr for %s v: %#" PRIx64 " k: %#" PRIx64 "\n",
> mem_start, sym->name, mem_end,
> UM(pair->end));
> diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
> index 6c178985e37f..d5dd17eb5c05 100644
> --- a/tools/perf/tests/wp.c
> +++ b/tools/perf/tests/wp.c
> @@ -31,10 +31,10 @@ volatile u8 data2[3];
> #ifndef __s390x__
> static int wp_read(int fd, long long *count, int size)
> {
> - int ret = read(fd, count, size);
> + ssize_t ret = read(fd, count, size);
>
> if (ret != size) {
> - pr_debug("failed to read: %d\n", ret);
> + pr_debug("failed to read: %zd\n", ret);
> return -1;
> }
> return 0;
> --
> 2.49.0.504.g3bcea36a83-goog
>
>
next prev parent reply other threads:[~2025-04-02 14:35 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 18:22 [PATCH v1 00/48] Perf build support for -Wshorten-64-to-32 Ian Rogers
2025-04-01 18:22 ` [PATCH v1 01/48] perf build: Avoid building libbpf/bpftool with LIBBPF_DYNAMIC Ian Rogers
2025-04-01 18:23 ` [PATCH v1 02/48] tools headers: Silence -Wshorten-64-to-32 warnings Ian Rogers
2025-04-03 14:08 ` Yury Norov
2025-04-03 14:26 ` Yury Norov
2025-04-03 14:52 ` Ian Rogers
2025-04-03 15:23 ` Yury Norov
2025-04-03 15:45 ` Ian Rogers
2025-04-03 18:12 ` Ian Rogers
2025-04-03 18:18 ` Yury Norov
2025-04-03 18:25 ` Ian Rogers
2025-04-01 18:23 ` [PATCH v1 03/48] arm64: cputype: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 04/48] x86/insn: " Ian Rogers
2025-04-02 11:10 ` Eder Zulian
2025-04-01 18:23 ` [PATCH v1 05/48] tools lib: " Ian Rogers
2025-04-03 14:19 ` Yury Norov
2025-04-01 18:23 ` [PATCH v1 06/48] libperf: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 07/48] tools subcmd: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 08/48] perf bench: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 09/48] perf tests: " Ian Rogers
2025-04-02 14:35 ` Leo Yan [this message]
2025-04-02 15:42 ` Ian Rogers
2025-04-02 16:38 ` Leo Yan
2025-04-02 16:53 ` Ian Rogers
2025-04-03 4:53 ` Namhyung Kim
2025-04-03 15:20 ` Ian Rogers
2025-04-28 11:10 ` Leo Yan
2025-04-28 16:29 ` Ian Rogers
2025-04-29 9:53 ` Leo Yan
2025-04-02 22:01 ` David Laight
2025-04-02 22:32 ` Ian Rogers
2025-04-01 18:23 ` [PATCH v1 10/48] perf arch x86: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 11/48] perf arm-spe: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 12/48] perf trace: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 13/48] perf trace-event: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 14/48] perf jvmti: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 15/48] perf pmu: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 16/48] perf annotate powerpc: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 17/48] perf s390: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 18/48] perf cs-etm: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 19/48] perf stat: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 20/48] perf dlfilter: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 21/48] perf demangle: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 22/48] perf ui: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 23/48] perf annotate: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 24/48] perf report: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 25/48] perf help: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 26/48] perf hisi-ptt: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 27/48] perf probe: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 28/48] perf kwork: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 29/48] perf buildid: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 30/48] perf lock: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 31/48] perf mem: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 32/48] perf script: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 33/48] perf evlist: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 34/48] perf bpf_counter: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 35/48] perf ftrace: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 36/48] perf record: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 37/48] perf inject: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 38/48] perf sched: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 39/48] perf timechart: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 40/48] perf list: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 41/48] perf kvm: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 42/48] perf diff: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 43/48] perf daemon: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 44/48] perf zlib: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 45/48] perf symbol: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 46/48] perf util: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 47/48] perf hashmap: " Ian Rogers
2025-04-01 18:23 ` [PATCH v1 48/48] perf: " Ian Rogers
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=20250402143541.GM115840@e132581.arm.com \
--to=leo.yan@arm.com \
--cc=acme@kernel.org \
--cc=adityag@linux.ibm.com \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=algonell@gmail.com \
--cc=andrealmeid@igalia.com \
--cc=anshuman.khandual@arm.com \
--cc=arnd@arndb.de \
--cc=asmadeus@codewreck.org \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=ben.gainey@arm.com \
--cc=bgeffon@google.com \
--cc=cachen@purestorage.com \
--cc=charlie@rivosinc.com \
--cc=christophe.leroy@csgroup.eu \
--cc=colin.i.king@gmail.com \
--cc=ctshao@google.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=dave@stgolabs.net \
--cc=dirk@gouders.net \
--cc=dvhart@infradead.org \
--cc=dvyukov@google.com \
--cc=ezulian@redhat.com \
--cc=fzczx123@gmail.com \
--cc=gehao@kylinos.cn \
--cc=gmonaco@redhat.com \
--cc=graham.woodward@arm.com \
--cc=hejunhao3@huawei.com \
--cc=howardchu95@gmail.com \
--cc=ilkka@os.amperecomputing.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jannh@google.com \
--cc=jean-philippe.romain@foss.st.com \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=jonathan.cameron@huawei.com \
--cc=jpoimboe@kernel.org \
--cc=justinstitt@google.com \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=krzysztof.m.lopatowski@gmail.com \
--cc=kyle.meyer@hpe.com \
--cc=leo.yan@linux.dev \
--cc=lihuafei1@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=linux@treblig.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=masahiroy@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=namhyung@kernel.org \
--cc=nathan@kernel.org \
--cc=peterz@infradead.org \
--cc=quic_zhonhan@quicinc.com \
--cc=ravi.bangoria@amd.com \
--cc=scclevenger@os.amperecomputing.com \
--cc=sesse@google.com \
--cc=stephen.s.brennan@oracle.com \
--cc=tglx@linutronix.de \
--cc=thomas.falcon@intel.com \
--cc=tmricht@linux.ibm.com \
--cc=viro@zeniv.linux.org.uk \
--cc=visitorckw@gmail.com \
--cc=weilin.wang@intel.com \
--cc=will@kernel.org \
--cc=wutengda@huaweicloud.com \
--cc=xu.yang_2@nxp.com \
--cc=yangjihong@bytedance.com \
--cc=yangyicong@hisilicon.com \
--cc=yeoreum.yun@arm.com \
--cc=yujie.liu@intel.com \
--cc=yury.norov@gmail.com \
--cc=zhe.he@windriver.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