Skip to contentSkip to conversation

perf tools: Fix bool return value in gzip_is_compressed()

PATCH In review Miaoqian Lin 4 participants 6 messages Aug 28, 2025 – Oct 14, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tools: Fix bool return value in gzip_is_compressed()

gzip_is_compressed() returns -1 on error but is declared as bool. And -1 gets converted to true, which could be misleading. Return false instead to match the declared type.

Fixes 88c74dc76a30 ("perf tools: Add gzip_is_compressed function")
---
 tools/perf/util/zlib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/zlib.c +1 -1
index 78d2297c1b67..1f7c06523059 100644
@@ -88,7 +88,7 @@ bool gzip_is_compressed(const char *input)
 	ssize_t rc;
 
 	if (fd < 0)
-		return -1;
+		return false;
 
 	rc = read(fd, buf, sizeof(buf));
 	close(fd);
Signature · 1 line
2.39.5 (Apple Git-154)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Miaoqian Lin

gzip_is_compressed() returns -1 on error but is declared as bool. And -1 gets converted to true, which could be misleading. Return false instead to match the declared type.

Fixes 88c74dc76a30 ("perf tools: Add gzip_is_compressed function")
---
 tools/perf/util/zlib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/zlib.c +0 -0
index 78d2297c1b67..1f7c06523059 100644

tools/perf/util/zlib.c bool gzip_is_compressed(const char *input) · line 94

Quoted 8 lines
tools/perf/util/zlib.c +1 -1
@@ -88,7 +88,7 @@ bool gzip_is_compressed(const char *input)
 	ssize_t rc;
 
 	if (fd < 0)
-		return -1;
+		return false;
 
 	rc = read(fd, buf, sizeof(buf));
 	close(fd);
maintainer
#2 lore raw

Hello,

Quoted 20 lines · Dapeng
Quoted 18 lines · Miaoqian Lin

gzip_is_compressed() returns -1 on error but is declared as bool. And -1 gets converted to true, which could be misleading. Return false instead to match the declared type.

Fixes 88c74dc76a30 ("perf tools: Add gzip_is_compressed function")
---
 tools/perf/util/zlib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/zlib.c +0 -0
index 78d2297c1b67..1f7c06523059 100644
@@ -88,7 +88,7 @@ bool gzip_is_compressed(const char *input)
 	ssize_t rc;
 
Quoted 8 lines

tools/perf/util/zlib.c bool gzip_is_compressed(const char *input) · line 94

Quoted 6 lines
tools/perf/util/zlib.c +1 -1
 	if (fd < 0)
-		return -1;
+		return false;
 
 	rc = read(fd, buf, sizeof(buf));
 	close(fd);

We have 43fa1141e2c1af79 ("perf util: Fix compression checks returning -1 as bool").

Thanks,
Namhyung

#3 lore raw
Quoted 26 lines · Namhyung Kim

Hello,

Quoted 23 lines · Dapeng
Quoted 22 lines · Miaoqian Lin

gzip_is_compressed() returns -1 on error but is declared as bool. And -1 gets converted to true, which could be misleading. Return false instead to match the declared type.

Fixes 88c74dc76a30 ("perf tools: Add gzip_is_compressed function")
---
 tools/perf/util/zlib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/zlib.c +1 -1
index 78d2297c1b67..1f7c06523059 100644
@@ -88,7 +88,7 @@ bool gzip_is_compressed(const char *input)
 	ssize_t rc;
 
 	if (fd < 0)
-		return -1;
+		return false;
 
Quoted 5 lines
Quoted 3 lines

tools/perf/util/zlib.c bool gzip_is_compressed(const char *input) · line 94

Quoted 2 lines
tools/perf/util/zlib.c +0 -0
 	rc = read(fd, buf, sizeof(buf));
 	close(fd);

We have 43fa1141e2c1af79 ("perf util: Fix compression checks returning -1 as bool").

Good to know this has been fixed. Thanks. :)

Quoted 4 lines

Thanks,
Namhyung

#5 lore raw
Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 7 lines · Dapeng

tools/perf/util/zlib.c bool gzip_is_compressed(const char *input) · line 89

Quoted 5 lines

+++ b/tools/perf/util/zlib.c

tools/perf/util/zlib.c +1 -1
@@ -88,7 +88,7 @@ bool gzip_is_compressed(const char *input)
 	if (fd < 0)
-		return -1;
+		return false;

Sorry for the noise, I merged this already, it is already in 6.18-rc1 :-\

- Arnaldo