[PATCH v1 26/48] perf hisi-ptt: Silence -Wshorten-64-to-32 warnings
From: Ian Rogers
Date: Tue Apr 01 2025 - 14:31:23 EST
The clang warning -Wshorten-64-to-32 can be useful to catch
inadvertent truncation. In some instances this truncation can lead to
changing the sign of a result, for example, truncation to return an
int to fit a sort routine. Silence the warning by making the implicit
truncation explicit.
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/hisi-ptt.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/hisi-ptt.c b/tools/perf/util/hisi-ptt.c
index e4cc4785f744..978f5781c990 100644
--- a/tools/perf/util/hisi-ptt.c
+++ b/tools/perf/util/hisi-ptt.c
@@ -59,7 +59,7 @@ static void hisi_ptt_dump(struct hisi_ptt *ptt __maybe_unused,
len);
while (len > 0) {
- pkt_len = hisi_ptt_pkt_desc(buf, pos, type);
+ pkt_len = hisi_ptt_pkt_desc(buf, (int)pos, type);
if (!pkt_len)
color_fprintf(stdout, color, " Bad packet!\n");
@@ -91,10 +91,10 @@ static int hisi_ptt_process_auxtrace_event(struct perf_session *session,
struct hisi_ptt *ptt = container_of(session->auxtrace, struct hisi_ptt,
auxtrace);
int fd = perf_data__fd(session->data);
- int size = event->auxtrace.size;
+ u64 size = event->auxtrace.size;
void *data = malloc(size);
off_t data_offset;
- int err;
+ ssize_t err;
if (!data)
return -errno;
@@ -174,7 +174,7 @@ int hisi_ptt_process_auxtrace_info(union perf_event *event,
ptt->session = session;
ptt->machine = &session->machines.host; /* No kvm support */
ptt->auxtrace_type = auxtrace_info->type;
- ptt->pmu_type = auxtrace_info->priv[0];
+ ptt->pmu_type = (unsigned int)auxtrace_info->priv[0];
ptt->auxtrace.process_event = hisi_ptt_process_event;
ptt->auxtrace.process_auxtrace_event = hisi_ptt_process_auxtrace_event;
--
2.49.0.504.g3bcea36a83-goog