Skip to contentSkip to conversation

ASoC: sdw_utils: TI amp utility for tac5xx2 family

bug report Dan Carpenter 1 participant 1 message May 11 Sound

lore
Share & tools
lore
#0 lore raw

Hello Niranjan H Y,

Commit e812de61e9a0 ("ASoC: sdw_utils: TI amp utility for tac5xx2 family") from May 5, 2026 (linux-next), leads to the following Smatch static checker warning:

	sound/soc/sdw_utils/soc_sdw_ti_amp.c:114 asoc_sdw_ti_add_tac5xx2_routes()
	warn: why check scnprintf return value?

sound/soc/sdw_utils/soc_sdw_ti_amp.c

    102 static int asoc_sdw_ti_add_tac5xx2_routes(struct snd_soc_dapm_context *dapm,
    103                                           const char *name_prefix)
    104 {
    105         struct snd_soc_dapm_route routes[2];
    106         char left_widget[TAC5XX2_WIDGET_NAME_MAX];
    107         char right_widget[TAC5XX2_WIDGET_NAME_MAX];
    108         int ret;
    109 
    110         if (strlen(name_prefix) > (TAC5XX2_WIDGET_NAME_MAX - 7))
    111                 return -ENAMETOOLONG;
    112 
    113         ret = scnprintf(left_widget, sizeof(left_widget), "%s SPK_L", name_prefix);
--> 114         if (ret <= 0)
    115                 return -EINVAL;
                ^^^^^^^^^^^^^^^^^^^^^^^

scnprintf() returns the number of bytes it was able to fit into TAC5XX2_WIDGET_NAME_MAX, not counting the NUL character. It never returns negatives and it's not going to return zero either.

This is just dead code.

    116 
    117         ret = scnprintf(right_widget, sizeof(right_widget), "%s SPK_R", name_prefix);
    118         if (ret <= 0)
    119                 return -EINVAL;
                ^^^^^^^^^^^^^^^^^^^^^^^

Same.

    120 
    121         routes[0] = (struct snd_soc_dapm_route){"Left Spk", NULL, left_widget};
    122         routes[1] = (struct snd_soc_dapm_route){"Right Spk", NULL, right_widget};
    123 
    124         return snd_soc_dapm_add_routes(dapm, routes, ARRAY_SIZE(routes));
    125 }

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter