Re: [PATCH] ASoC: mediatek: mt2701: fix snprintf bounds
From: Rosen Penev <hidden>
Date: 2026-05-19 21:57:43
Also in:
linux-mediatek, linux-sound, lkml
From: Rosen Penev <hidden>
Date: 2026-05-19 21:57:43
Also in:
linux-mediatek, linux-sound, lkml
On Tue, May 19, 2026 at 1:33 AM Mark Brown [off-list ref] wrote:
On Mon, May 18, 2026 at 06:04:40PM -0700, Rosen Penev wrote:quoted
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.quoted
+ 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.
how so? MT2701_BASE_CLK_NUM would increase.