Skip to content
  • Trevor Wu's avatar
    GENIO: ASoC: mediatek: mt6359: fix coverity for uninitialized variable · 84a58089
    Trevor Wu authored and Pablo Sun's avatar Pablo Sun committed
    
    
    Coverity reports uninitialized variable problem like below.
    Initialize the variable to fix the issue.
    
    353     static int mt6359_put_volsw(struct snd_kcontrol *kcontrol,
    354                     struct snd_ctl_elem_value *ucontrol)
    355     {
    356         struct snd_soc_component *component =
    357                 snd_soc_kcontrol_component(kcontrol);
    358         struct mt6359_priv *priv =
                        snd_soc_component_get_drvdata(component);
    359         struct soc_mixer_control *mc =
    360                 (struct soc_mixer_control *)kcontrol->private_value;
    (1) Event var_decl: Declaring variable "reg" without initializer.
    Also see events:    [uninit_use]
    361         unsigned int reg;
    362         int index = ucontrol->value.integer.value[0];
    363         int ret;
    364
    365         ret = snd_soc_put_volsw(kcontrol, ucontrol);
    (2) Event cond_false:   Condition "ret < 0", taking false branch.
    366         if (ret < 0)
    (3) Event if_end:   End of if statement.
    367             return ret;
    368
    (4) Event switch:   Switch case value "9740".
    369         switch (mc->reg) {
    (5) Event switch_case:  Reached case "9740".
    370         case MT6359_ZCD_CON2:
    371             regmap_read(priv->regmap, MT6359_ZCD_CON2, &reg);
    (6) Event uninit_use:   Using uninitialized value "reg".
    372             priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTL] =
    373                 (reg >> RG_AUDHPLGAIN_SFT) & RG_AUDHPLGAIN_MASK;
    374             priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTR] =
    375                 (reg >> RG_AUDHPRGAIN_SFT) & RG_AUDHPRGAIN_MASK;
    376             break;
    
    Change-Id: I33b61cac65458d3d126cc405f73bedaaa4253ae3
    Signed-off-by: default avatarTrevor Wu <trevor.wu@mediatek.com>
    84a58089