Skip to contentSkip to conversation

ASoC: mediatek: mt8186: support adda in platform driver

bug report Dan Carpenter 2 participants 2 messages Jul 25, 2022

lore
Share & tools
lore
#0 lore raw

Hello Jiaxin Yu,

The patch b65c466220b3: "ASoC: mediatek: mt8186: support adda in platform driver" from May 23, 2022, leads to the following Smatch static checker warning:

	sound/soc/mediatek/mt8186/mt8186-dai-adda.c:78 get_adda_priv_by_name()
	warn: strncmp() with weird length: 17 vs 7

sound/soc/mediatek/mt8186/mt8186-dai-adda.c

    72 static struct mtk_afe_adda_priv *get_adda_priv_by_name(struct mtk_base_afe *afe,
    73                                                        const char *name)
    74 {
    75         struct mt8186_afe_private *afe_priv = afe->platform_priv;
    76         int dai_id;
    77
--> 78         if (strncmp(name, "aud_dac_hires_clk", 7) == 0 ||
    79             strncmp(name, "aud_adc_hires_clk", 7) == 0)

7 is weird. It would be more readable to say it as:

	if (strncmp(name, "aud_dac", 7) == 0 ||
	    strncmp(name, "aud_adc", 7) == 0)

    80                 dai_id = MT8186_DAI_ADDA;
    81         else
    82                 return NULL;
    83
    84         return afe_priv->dai_priv[dai_id];
    85 }

regards,
dan carpenter

#1 lore raw
Quoted 23 lines · Dan Carpenter

Hello Jiaxin Yu,

The patch b65c466220b3: "ASoC: mediatek: mt8186: support adda in platform driver" from May 23, 2022, leads to the following Smatch static checker warning:

	sound/soc/mediatek/mt8186/mt8186-dai-adda.c:78

get_adda_priv_by_name()
warn: strncmp() with weird length: 17 vs 7

sound/soc/mediatek/mt8186/mt8186-dai-adda.c
72 static struct mtk_afe_adda_priv *get_adda_priv_by_name(struct
mtk_base_afe *afe,
73 const
char *name)
74 {
75 struct mt8186_afe_private *afe_priv = afe-

Quoted 1 line

platform_priv;

    76         int dai_id;
    77
--> 78         if (strncmp(name, "aud_dac_hires_clk", 7) == 0 ||
    79             strncmp(name, "aud_adc_hires_clk", 7) == 0)
Quoted 5 lines

7 is weird. It would be more readable to say it as:

	if (strncmp(name, "aud_dac", 7) == 0 ||
	    strncmp(name, "aud_adc", 7) == 0)

Yes, I will fix it soon.

Thanks,
Jiaxin.Yu

Quoted 9 lines
    80                 dai_id = MT8186_DAI_ADDA;
    81         else
    82                 return NULL;
    83
    84         return afe_priv->dai_priv[dai_id];
    85 }

regards,
dan carpenter