Re: [PATCH] staging: greybus: avoid snprintf truncation in audio topology

From: Dan Carpenter

Date: Wed Sep 23 2026 - 04:05:32 EST


On Wed, Sep 23, 2026 at 04:34:05AM +0200, Eduard Zateev wrote:
> Building with W=1 reports format truncation warnings when prefixing
> the Greybus device id to widget and control names.
>
> The destination buffers are NAME_SIZE bytes, while the copied topology
> names may already take most of that space. Split the operation into
> writing the prefix first and then copying the remaining name into the
> space left in the destination buffer.
>
> This avoids the -Wformat-truncation warnings while preserving bounded
> string handling.
>
> Signed-off-by: Eduard Zateev <hackerowskiy@xxxxxxxxx>
> ---

I hate the -Wformat-truncation warning. It doesn't really matter for
the kernel. Dmesg output has always been really grotty and especially
when you actually need it because of a crash then that's when it's
the most jumbled. Truncating the last couple bytes is not going to
make a crash noticably more difficult to solve.

The fix is to get rid of -Wformat-truncation for kernel builds.

This patch silences the warning but doesn't fix anything and makes
the code less readable.

regards,
dan carpenter