* [PATCH] ASoC: core: No need to use strncmp()
@ 2013-07-31 8:44 Dimitris Papastamos
2013-07-31 9:07 ` Mark Brown
0 siblings, 1 reply; 6+ messages in thread
From: Dimitris Papastamos @ 2013-07-31 8:44 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, patches
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
---
sound/soc/soc-core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d68a486..9f60894 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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;
}
--
1.8.3.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] ASoC: core: No need to use strncmp()
2013-07-31 8:44 [PATCH] ASoC: core: No need to use strncmp() Dimitris Papastamos
@ 2013-07-31 9:07 ` Mark Brown
2013-07-31 9:48 ` Dimitris Papastamos
0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2013-07-31 9:07 UTC (permalink / raw)
To: Dimitris Papastamos; +Cc: alsa-devel, patches
[-- Attachment #1.1: Type: text/plain, Size: 145 bytes --]
On Wed, Jul 31, 2013 at 09:44:13AM +0100, Dimitris Papastamos wrote:
> Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Why?
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: core: No need to use strncmp()
2013-07-31 9:07 ` Mark Brown
@ 2013-07-31 9:48 ` Dimitris Papastamos
2013-07-31 11:01 ` Mark Brown
0 siblings, 1 reply; 6+ messages in thread
From: Dimitris Papastamos @ 2013-07-31 9:48 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, patches
On Wed, Jul 31, 2013 at 10:07:26AM +0100, Mark Brown wrote:
> On Wed, Jul 31, 2013 at 09:44:13AM +0100, Dimitris Papastamos wrote:
> > Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
>
> Why?
Hm, strncmp() suggests that we might not care about the entire string.
Although trivial, I thought strcmp() is clearer in this context.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: core: No need to use strncmp()
2013-07-31 9:48 ` Dimitris Papastamos
@ 2013-07-31 11:01 ` Mark Brown
2013-07-31 11:59 ` Dimitris Papastamos
0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2013-07-31 11:01 UTC (permalink / raw)
To: Dimitris Papastamos; +Cc: alsa-devel, patches
[-- Attachment #1.1: Type: text/plain, Size: 530 bytes --]
On Wed, Jul 31, 2013 at 10:48:14AM +0100, Dimitris Papastamos wrote:
> On Wed, Jul 31, 2013 at 10:07:26AM +0100, Mark Brown wrote:
> > On Wed, Jul 31, 2013 at 09:44:13AM +0100, Dimitris Papastamos wrote:
> > > Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
> > Why?
> Hm, strncmp() suggests that we might not care about the entire string.
> Although trivial, I thought strcmp() 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.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: core: No need to use strncmp()
2013-07-31 11:01 ` Mark Brown
@ 2013-07-31 11:59 ` Dimitris Papastamos
2013-07-31 13:23 ` Mark Brown
0 siblings, 1 reply; 6+ messages in thread
From: Dimitris Papastamos @ 2013-07-31 11:59 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, patches
On Wed, Jul 31, 2013 at 12:01:47PM +0100, Mark Brown wrote:
> On Wed, Jul 31, 2013 at 10:48:14AM +0100, Dimitris Papastamos wrote:
> > On Wed, Jul 31, 2013 at 10:07:26AM +0100, Mark Brown wrote:
> > > On Wed, Jul 31, 2013 at 09:44:13AM +0100, Dimitris Papastamos wrote:
> > > > Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
>
> > > Why?
>
> > Hm, strncmp() suggests that we might not care about the entire string.
> > Although trivial, I thought strcmp() 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().
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: core: No need to use strncmp()
2013-07-31 11:59 ` Dimitris Papastamos
@ 2013-07-31 13:23 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2013-07-31 13:23 UTC (permalink / raw)
To: Dimitris Papastamos; +Cc: alsa-devel, patches
[-- Attachment #1.1: Type: text/plain, Size: 443 bytes --]
On Wed, Jul 31, 2013 at 12:59:29PM +0100, Dimitris Papastamos wrote:
> On Wed, Jul 31, 2013 at 12:01:47PM +0100, Mark Brown wrote:
> > 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.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-07-31 13:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-31 8:44 [PATCH] ASoC: core: No need to use strncmp() Dimitris Papastamos
2013-07-31 9:07 ` Mark Brown
2013-07-31 9:48 ` Dimitris Papastamos
2013-07-31 11:01 ` Mark Brown
2013-07-31 11:59 ` Dimitris Papastamos
2013-07-31 13:23 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).