ALSA: usb-audio: initialize variables that could ignore errors
PATCH 1/1 ALSA: usb-audio: initialize variables that could ignore errors
From: Tom Rix <[email protected]>
clang static analysis reports this representative issue mixer.c:1548:35: warning: Assigned value is garbage or undefined
ucontrol->value.integer.value[0] = val;
^ ~~~The filter_error() macro allows errors to be ignored. If errors can be ignored, initialize variables so garbage will not be used.
Fixes 48cc42973509 ("ALSA: usb-audio: Filter error from connector kctl ops, too")
Signed-off-by Tom Rix <[email protected]>
--- sound/usb/mixer.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/usb/mixer.c +4 -0
@@ -1527,6 +1527,10 @@ static int get_connector_value(struct usb_mixer_elem_info *cval,usb_audio_err (chip,"cannot get connectors status: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n" ,UAC_GET_CUR , validx, idx, cval->val_type); + +if (val) + *val =0 ; +return filter_error (cval, ret); }
Signature · 1 line
2.26.3
Takashi Iwai
AppliedQuoted 8 lines · On Wed, 26 Jan 2022 19:21:42 +0100, [email protected] wrote:
From: Tom Rix <[email protected]>
clang static analysis reports this representative issue mixer.c:1548:35: warning: Assigned value is garbage or undefined
ucontrol->value.integer.value[0] = val; ^ ~~~
Quoted 6 lines
The
filter_error()macro allows errors to be ignored. If errors can be ignored, initialize variables so garbage will not be used.Fixes 48cc42973509 ("ALSA: usb-audio: Filter error from connector kctl ops, too")Signed-off-by Tom Rix <[email protected]>
Thanks, applied.
Takashi