Re: inux-6.17/tools/perf/util/lzma.c:123: Strange return value ?

From: Ian Rogers

Date: Tue Sep 30 2025 - 09:34:41 EST


On Tue, Sep 30, 2025 at 3:19 AM David Binderman <dcb314@xxxxxxxxxxx> wrote:
>
> Hello there,
>
> Static analyser cppcheck says:
>
> linux-6.17/tools/perf/util/lzma.c:123:3: style: Non-boolean value returned from function returning bool [returnNonBoolInBooleanFunction]
>
> Source code is
>
> bool lzma_is_compressed(const char *input)
> {
> int fd = open(input, O_RDONLY);
> const uint8_t magic[6] = { 0xFD, '7', 'z', 'X', 'Z', 0x00 };
> char buf[6] = { 0 };
> ssize_t rc;
>
> if (fd < 0)
> return -1;
>
> Suggest return either true or false.
>
> Also, there is a duplicate of this problem at file linux-6.17/tools/perf/util/zlib.c
> line 91.

Thanks, a fix was already committed to the next branch:
https://lore.kernel.org/lkml/20250822162506.316844-3-ysk@xxxxxxxxxxx/
and the fixes tags should mean it isn't long before it is backported
to the stable branches.

Ian

> Regards
>
> David Binderman
>
>