ALSA: usb-audio: scarlett_gen2: Fix another -Wformat-truncation warning
PATCH 1/1 ALSA: usb-audio: scarlett_gen2: Fix another -Wformat-truncation warning
The recent enablement of -Wformat-truncation leads to a false-positive warning for mixer_scarlett_gen2.c.
For suppressing the warning, replace snprintf() with scnprintf(). As stated in the above, truncation doesn't matter.
--- sound/usb/mixer_scarlett_gen2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/mixer_scarlett_gen2.c +2 -2
@@ -3195,8 +3195,8 @@ static int scarlett2_add_line_in_ctls(struct usb_mixer_interface *mixer)/* Add input phantom controls */ if (info->inputs_per_phantom ==1 ) {for (i =0 ; i < info->phantom_count; i++) { -snprintf (s,sizeof (s), fmt, i +1 , -"Phantom Power" ,"Switch" ); +scnprintf (s,sizeof (s), fmt, i +1 , +"Phantom Power" ,"Switch" ); err =scarlett2_add_new_ctl ( mixer, &scarlett2_phantom_ctl, i,1 , s, &private->phantom_ctls[i]);
Signature · 1 line
2.42.0
Quoted 9 lines · Peter Ujfalusi
The recent enablement of -Wformat-truncation leads to a false-positive warning for
mixer_scarlett_gen2.c.For suppressing the warning, replace
snprintf()withscnprintf(). As stated in the above, truncation doesn't matter.Fixes 78bd8f5126f8 ("ALSA: usb-audio: scarlett_gen2: Fix -Wformat-truncation warning")Signed-off-by Peter Ujfalusi <[email protected]>
While I applied it now, I wonder why this didn't show up with my local test. Which compiler are you using?
thanks,
Takashi
Quoted 6 lines · Takashi Iwai
Quoted 4 lines · Peter Ujfalusi
The recent enablement of -Wformat-truncation leads to a false-positive warning for
mixer_scarlett_gen2.c.
Quoted 8 lines
Quoted 5 lines
For suppressing the warning, replace
snprintf()withscnprintf(). As stated in the above, truncation doesn't matter.Fixes 78bd8f5126f8 ("ALSA: usb-audio: scarlett_gen2: Fix -Wformat-truncation warning")Signed-off-by Peter Ujfalusi <[email protected]>While I applied it now, I wonder why this didn't show up with my local test.
I wondered about the same thing...
Quoted 1 line
Which compiler are you using?
$ gcc --version gcc (GCC) 13.2.1 20230801
Signature · 1 line
Péter
Quoted 19 lines · Péter Ujfalusi
Quoted 6 lines · Takashi Iwai
Quoted 4 lines · Peter Ujfalusi
The recent enablement of -Wformat-truncation leads to a false-positive warning for
mixer_scarlett_gen2.c.Quoted 8 lines
Quoted 5 lines
For suppressing the warning, replace
snprintf()withscnprintf(). As stated in the above, truncation doesn't matter.Fixes 78bd8f5126f8 ("ALSA: usb-audio: scarlett_gen2: Fix -Wformat-truncation warning")Signed-off-by Peter Ujfalusi <[email protected]>While I applied it now, I wonder why this didn't show up with my local test.
Quoted 6 lines
I wondered about the same thing...
Quoted 1 line
Which compiler are you using?
$ gcc --version gcc (GCC) 13.2.1 20230801
Ah mine is still gcc12, and this might be.
Takashi