[bug report] ASoC: mediatek: mt8186: support adda in platform driver

Dan Carpenter dan.carpenter at oracle.com
Mon Jul 25 09:25:23 CEST 2022


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


More information about the Alsa-devel mailing list