Re: [PATCH] ALSA: aoa: size the codec reference property name buffer
From: Takashi Iwai
Date: Mon Nov 16 2026 - 06:32:00 EST
On Fri, 13 Nov 2026 11:30:06 +0100,
Aibing Chen wrote:
>
> check_codec() builds the device tree property name
> "platform-<codec>-codec-ref" in a 32 byte buffer with snprintf().
> A codec name may be up to MAX_CODEC_NAME_LEN - 1 (31) characters and
> the surrounding text adds 19 characters, so the full name can be 50
> characters plus the terminator. Codec names longer than 12 characters
> are silently truncated, of_get_property() then looks up a property name
> that does not exist, and check_codec() fails the codec with "required
> property ... not present".
>
> All codecs in the tree use shorter names today, but the buffer should
> match the documented maximum. Size it from MAX_CODEC_NAME_LEN, which
> is already available through "../aoa.h".
>
> Compiling with W=1 before this change reports:
>
> sound/aoa/fabrics/layout.c:780:36: warning: '%s' directive output may be truncated writing up to 31 bytes into a region of size 23 [-Wformat-truncation=]
>
> Signed-off-by: Aibing Chen <chenaibing@xxxxxxxxxxxxxxxxxxxx>
Is the string really truncated unexpectedly?
Otherwise it's just an incorrect compiler warning, and extending the
size doesn't make sense.
thanks,
Takashi