Skip to contentSkip to conversation

perf lzma: Fix return value in lzma_is_compressed()

PATCH In review Miaoqian Lin 2 participants 2 messages Aug 28, 2025 – Oct 11, 2025

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

PATCH 1/1 perf lzma: Fix return value in lzma_is_compressed()

lzma_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 4b57fd44b61b ("perf tools: Add lzma_is_compressed function")
---
 tools/perf/util/lzma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/lzma.c +1 -1
index bbcd2ffcf4bd..c355757ed391 100644
@@ -120,7 +120,7 @@ bool lzma_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

lzma_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 4b57fd44b61b ("perf tools: Add lzma_is_compressed function")
---
 tools/perf/util/lzma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/lzma.c +0 -0
index bbcd2ffcf4bd..c355757ed391 100644

tools/perf/util/lzma.c bool lzma_is_compressed(const char *input) · line 126

Quoted 8 lines
tools/perf/util/lzma.c +1 -1
@@ -120,7 +120,7 @@ bool lzma_is_compressed(const char *input)
 	ssize_t rc;
 
 	if (fd < 0)
-		return -1;
+		return false;
 
 	rc = read(fd, buf, sizeof(buf));
 	close(fd);