ASoC: core: No need to use strncmp()
PATCH 1/1 ASoC: core: No need to use strncmp()
--- sound/soc/soc-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/soc-core.c +2 -2
@@ -2309,7 +2309,7 @@ struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,return NULL ;list_for_each_entry (kctl, &card->controls, list) -if (!strncmp (kctl->id.name, name,sizeof (kctl->id.name))) +if (!strcmp (kctl->id.name, name))return kctl;return NULL ; }
@@ -3056,7 +3056,7 @@ int snd_soc_limit_volume(struct snd_soc_codec *codec,return -EINVAL ;list_for_each_entry (kctl, &card->controls, list) { -if (!strncmp (kctl->id.name, name,sizeof (kctl->id.name))) { +if (!strcmp (kctl->id.name, name)) { found =1 ;break ; }
Signature · 1 line
1.8.3.4
Mark Brown
maintainerQuoted 1 line · Dimitris Papastamos
Signed-off-by Dimitris Papastamos <[email protected]>
Why?
Quoted 4 lines · Mark Brown
Quoted 1 line · Dimitris Papastamos
Signed-off-by Dimitris Papastamos <[email protected]>Why?
Hm, strncmp() suggests that we might not care about the entire string. Although trivial, I thought strcmp() is clearer in this context.
Mark Brown
maintainerQuoted 8 lines · Dimitris Papastamos
Quoted 4 lines · Mark Brown
Quoted 1 line · Dimitris Papastamos
Signed-off-by Dimitris Papastamos <[email protected]>Why?
Hm,
strncmp()suggests that we might not care about the entire string. Although trivial, I thoughtstrcmp()is clearer in this context.
One of the reasons we use strncmp() here is to avoid going beyond the end of the fixed size buffer.
Quoted 5 lines · Mark Brown
Quoted 3 lines · Dimitris Papastamos
Quoted 2 lines · Mark Brown
Quoted 1 line · Dimitris Papastamos
Signed-off-by Dimitris Papastamos <[email protected]>
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Why?
Hm,
strncmp()suggests that we might not care about the entire string. Although trivial, I thoughtstrcmp()is clearer in this context.One of the reasons we use
strncmp()here is to avoid going beyond the end of the fixed size buffer.
Right, surely though the kcontrol names are always null terminated? In any case, looks more safe to strncmp().
Mark Brown
maintainerQuoted 7 lines · Dimitris Papastamos
Quoted 2 lines · Mark Brown
One of the reasons we use
strncmp()here is to avoid going beyond the end of the fixed size buffer.Right, surely though the kcontrol names are always null terminated? In any case, looks more safe to
strncmp().
They probably should be but it's easy to get it wrong and hit exactly the array size.