ASoC: rt-sdw-common: Enhance switch case to prevent uninitialized variable
Subsystems (3)
PATCH 1/1 ASoC: rt-sdw-common: Enhance switch case to prevent uninitialized variable
If det_mode is not 0, 3 or 5 then function will return jack_type with an uninitialzed value.
Enhance switch case to prevent uninitialized variable issue.
Signed-off-by Jack Yu <[email protected]>
--- sound/soc/codecs/rt-sdw-common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
sound/soc/codecs/rt-sdw-common.c +2 -3
@@ -150,15 +150,14 @@ int rt_sdca_headset_detect(struct regmap *map, unsigned int entity_id) goto io_error;switch (det_mode) { -case 0x00 : - jack_type =0 ; -break ;case 0x03 : jack_type =SND_JACK_HEADPHONE ;break ;case 0x05 : jack_type =SND_JACK_HEADSET ;break ; +default : + jack_type =0 ; }/* write selected_mode */
Signature · 1 line
2.34.1
Mark Brown
maintainersound/soc/codecs/rt-sdw-common.c int rt_sdca_headset_detect(struct regmap *map, unsigned int entity_id) · line 161
Quoted 6 lines · Jack Yu
sound/soc/codecs/rt-sdw-common.c +2
-0case 0x05 : jack_type =SND_JACK_HEADSET ;break ; +default : + jack_type =0 ; }
Even though it's a bit redundant you should still have a break; here for the kernel coding style, missing it might upset some linters.