Re: [PATCH] ASoC: mediatek: mt2701: fix snprintf bounds

From: Mark Brown

Date: Tue May 19 2026 - 04:44:33 EST


On Mon, May 18, 2026 at 06:04:40PM -0700, Rosen Penev wrote:
> For whatever reason, GCC is unable to figure out that i2s_num is a
> single digit number, with MT2701_BASE_CLK_NUM being the maximum value it
> represents. Add a min() call to help it out and fix W=1 errors regarding
> snprintf bounds.

> + i2s_num = min(MT2701_BASE_CLK_NUM, afe_priv->soc->i2s_num);
> /* Get I2S related clocks */
> - for (i = 0; i < afe_priv->soc->i2s_num; i++) {
> + for (i = 0; i < i2s_num; i++) {

This makes the code rather obscure and will start silently failing if we
ever get more than 9 clocks, we should at least put a build time assert
or a warn on in there.

Attachment: signature.asc
Description: PGP signature