tools/perf/util/lzma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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")
Cc: <stable@vger.kernel.org>
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
tools/perf/util/lzma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c
index bbcd2ffcf4bd..c355757ed391 100644
--- a/tools/perf/util/lzma.c
+++ b/tools/perf/util/lzma.c
@@ -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);
--
2.39.5 (Apple Git-154)
On 8/28/2025 6:50 PM, Miaoqian Lin wrote:
> 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")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
> tools/perf/util/lzma.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c
> index bbcd2ffcf4bd..c355757ed391 100644
> --- a/tools/perf/util/lzma.c
> +++ b/tools/perf/util/lzma.c
> @@ -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);
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
© 2016 - 2026 Red Hat, Inc.