[PATCH v1 44/48] perf zlib: Silence -Wshorten-64-to-32 warnings

From: Ian Rogers
Date: Tue Apr 01 2025 - 14:34:21 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/zlib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/zlib.c b/tools/perf/util/zlib.c
index 78d2297c1b67..d30597701fd1 100644
--- a/tools/perf/util/zlib.c
+++ b/tools/perf/util/zlib.c
@@ -44,7 +44,7 @@ int gzip_decompress_to_file(const char *input, int output_fd)
goto out_unmap;

zs.next_in = ptr;
- zs.avail_in = stbuf.st_size;
+ zs.avail_in = (uInt)stbuf.st_size;

do {
zs.next_out = buf;
--
2.49.0.504.g3bcea36a83-goog