All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][alsa-lib] topology: fix sign-compare warning introduced to set_link_hw_config() and tplg_add_link_object()
@ 2016-11-29 15:41 Takashi Sakamoto
  2016-12-17  0:40 ` Takashi Sakamoto
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Sakamoto @ 2016-11-29 15:41 UTC (permalink / raw)
  To: tiwai, perex; +Cc: alsa-devel, mengdong.lin

Some functions recently introduced to this library include comparison
between variables with different types, then compiler generates
below warnings.

pcm.c: In function ‘set_link_hw_config’:
pcm.c:1179:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < cfg->tx_channels; i++)
                ^
pcm.c:1183:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < cfg->rx_channels; i++)
                ^
pcm.c: In function ‘tplg_add_link_object’:
pcm.c:1223:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < link->num_streams; i++)
                ^
pcm.c:1231:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < link->num_hw_configs; i++)

This commit suppresses them.

Fixes: 6b4d775b9752 ("topology: Parse HW configurations of physical DAI links defined by C API")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 src/topology/pcm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index 8f8a703..1de8655 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -1147,7 +1147,7 @@ int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
 static int set_link_hw_config(struct snd_soc_tplg_hw_config *cfg,
 			struct snd_tplg_hw_config_template *tpl)
 {
-	int i;
+	unsigned int i;
 
 	cfg->size = sizeof(*cfg);
 	cfg->id = tpl->id;
@@ -1190,7 +1190,7 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
 	struct snd_tplg_link_template *link_tpl = t->link;
 	struct snd_soc_tplg_link_config *link, *_link;
 	struct tplg_elem *elem;
-	int i;
+	unsigned int i;
 
 	if (t->type != SND_TPLG_TYPE_LINK && t->type != SND_TPLG_TYPE_BE
 	    && t->type != SND_TPLG_TYPE_CC)
-- 
2.9.3

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH][alsa-lib] topology: fix sign-compare warning introduced to set_link_hw_config() and tplg_add_link_object()
  2016-11-29 15:41 [PATCH][alsa-lib] topology: fix sign-compare warning introduced to set_link_hw_config() and tplg_add_link_object() Takashi Sakamoto
@ 2016-12-17  0:40 ` Takashi Sakamoto
  2016-12-27 10:39   ` Mengdong Lin
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Sakamoto @ 2016-12-17  0:40 UTC (permalink / raw)
  To: tiwai, perex; +Cc: alsa-devel, mengdong.lin

Ping to Mengdong Lin. I wish this patch would be included to next
release of this library.

On 2016年11月30日 00:41, Takashi Sakamoto wrote:
> Some functions recently introduced to this library include comparison
> between variables with different types, then compiler generates
> below warnings.
> 
> pcm.c: In function ‘set_link_hw_config’:
> pcm.c:1179:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>   for (i = 0; i < cfg->tx_channels; i++)
>                 ^
> pcm.c:1183:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>   for (i = 0; i < cfg->rx_channels; i++)
>                 ^
> pcm.c: In function ‘tplg_add_link_object’:
> pcm.c:1223:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>   for (i = 0; i < link->num_streams; i++)
>                 ^
> pcm.c:1231:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>   for (i = 0; i < link->num_hw_configs; i++)
> 
> This commit suppresses them.
> 
> Fixes: 6b4d775b9752 ("topology: Parse HW configurations of physical DAI links defined by C API")
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> ---
>  src/topology/pcm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/topology/pcm.c b/src/topology/pcm.c
> index 8f8a703..1de8655 100644
> --- a/src/topology/pcm.c
> +++ b/src/topology/pcm.c
> @@ -1147,7 +1147,7 @@ int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
>  static int set_link_hw_config(struct snd_soc_tplg_hw_config *cfg,
>  			struct snd_tplg_hw_config_template *tpl)
>  {
> -	int i;
> +	unsigned int i;
>  
>  	cfg->size = sizeof(*cfg);
>  	cfg->id = tpl->id;
> @@ -1190,7 +1190,7 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
>  	struct snd_tplg_link_template *link_tpl = t->link;
>  	struct snd_soc_tplg_link_config *link, *_link;
>  	struct tplg_elem *elem;
> -	int i;
> +	unsigned int i;
>  
>  	if (t->type != SND_TPLG_TYPE_LINK && t->type != SND_TPLG_TYPE_BE
>  	    && t->type != SND_TPLG_TYPE_CC)
> 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][alsa-lib] topology: fix sign-compare warning introduced to set_link_hw_config() and tplg_add_link_object()
  2016-12-17  0:40 ` Takashi Sakamoto
@ 2016-12-27 10:39   ` Mengdong Lin
  2017-01-02 14:20     ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Mengdong Lin @ 2016-12-27 10:39 UTC (permalink / raw)
  To: Takashi Sakamoto, tiwai, perex; +Cc: alsa-devel



On 12/17/2016 08:40 AM, Takashi Sakamoto wrote:
> Ping to Mengdong Lin. I wish this patch would be included to next
> release of this library.

Sorry for the late reply and thanks for the fix. The patches looks good 
to me.

Thanks
Mengdong

>
> On 2016年11月30日 00:41, Takashi Sakamoto wrote:
>> Some functions recently introduced to this library include comparison
>> between variables with different types, then compiler generates
>> below warnings.
>>
>> pcm.c: In function ‘set_link_hw_config’:
>> pcm.c:1179:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>>    for (i = 0; i < cfg->tx_channels; i++)
>>                  ^
>> pcm.c:1183:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>>    for (i = 0; i < cfg->rx_channels; i++)
>>                  ^
>> pcm.c: In function ‘tplg_add_link_object’:
>> pcm.c:1223:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>>    for (i = 0; i < link->num_streams; i++)
>>                  ^
>> pcm.c:1231:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>>    for (i = 0; i < link->num_hw_configs; i++)
>>
>> This commit suppresses them.
>>
>> Fixes: 6b4d775b9752 ("topology: Parse HW configurations of physical DAI links defined by C API")
>> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
>> ---
>>   src/topology/pcm.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/topology/pcm.c b/src/topology/pcm.c
>> index 8f8a703..1de8655 100644
>> --- a/src/topology/pcm.c
>> +++ b/src/topology/pcm.c
>> @@ -1147,7 +1147,7 @@ int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
>>   static int set_link_hw_config(struct snd_soc_tplg_hw_config *cfg,
>>   			struct snd_tplg_hw_config_template *tpl)
>>   {
>> -	int i;
>> +	unsigned int i;
>>
>>   	cfg->size = sizeof(*cfg);
>>   	cfg->id = tpl->id;
>> @@ -1190,7 +1190,7 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
>>   	struct snd_tplg_link_template *link_tpl = t->link;
>>   	struct snd_soc_tplg_link_config *link, *_link;
>>   	struct tplg_elem *elem;
>> -	int i;
>> +	unsigned int i;
>>
>>   	if (t->type != SND_TPLG_TYPE_LINK && t->type != SND_TPLG_TYPE_BE
>>   	    && t->type != SND_TPLG_TYPE_CC)
>>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][alsa-lib] topology: fix sign-compare warning introduced to set_link_hw_config() and tplg_add_link_object()
  2016-12-27 10:39   ` Mengdong Lin
@ 2017-01-02 14:20     ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2017-01-02 14:20 UTC (permalink / raw)
  To: Mengdong Lin; +Cc: alsa-devel, Takashi Sakamoto

On Tue, 27 Dec 2016 11:39:17 +0100,
Mengdong Lin wrote:
> 
> 
> 
> On 12/17/2016 08:40 AM, Takashi Sakamoto wrote:
> > Ping to Mengdong Lin. I wish this patch would be included to next
> > release of this library.
> 
> Sorry for the late reply and thanks for the fix. The patches looks
> good to me.

As already mentioned, using unsigned int for a generic loop variable
like "i" is no good idea.  It may confuse if the same variable is used
mistakenly in another place of the same function.

And, we can ignore many of sign-compare compile warnings in general.
The -Wall warning about this sign comparison was once suppressed in
the past in gcc side because it was useless in most cases and rather
driving people in the wrong direction.


Takashi

> 
> Thanks
> Mengdong
> 
> >
> > On 2016年11月30日 00:41, Takashi Sakamoto wrote:
> >> Some functions recently introduced to this library include comparison
> >> between variables with different types, then compiler generates
> >> below warnings.
> >>
> >> pcm.c: In function ‘set_link_hw_config’:
> >> pcm.c:1179:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
> >>    for (i = 0; i < cfg->tx_channels; i++)
> >>                  ^
> >> pcm.c:1183:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
> >>    for (i = 0; i < cfg->rx_channels; i++)
> >>                  ^
> >> pcm.c: In function ‘tplg_add_link_object’:
> >> pcm.c:1223:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
> >>    for (i = 0; i < link->num_streams; i++)
> >>                  ^
> >> pcm.c:1231:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
> >>    for (i = 0; i < link->num_hw_configs; i++)
> >>
> >> This commit suppresses them.
> >>
> >> Fixes: 6b4d775b9752 ("topology: Parse HW configurations of physical DAI links defined by C API")
> >> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> >> ---
> >>   src/topology/pcm.c | 4 ++--
> >>   1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/src/topology/pcm.c b/src/topology/pcm.c
> >> index 8f8a703..1de8655 100644
> >> --- a/src/topology/pcm.c
> >> +++ b/src/topology/pcm.c
> >> @@ -1147,7 +1147,7 @@ int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
> >>   static int set_link_hw_config(struct snd_soc_tplg_hw_config *cfg,
> >>   			struct snd_tplg_hw_config_template *tpl)
> >>   {
> >> -	int i;
> >> +	unsigned int i;
> >>
> >>   	cfg->size = sizeof(*cfg);
> >>   	cfg->id = tpl->id;
> >> @@ -1190,7 +1190,7 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
> >>   	struct snd_tplg_link_template *link_tpl = t->link;
> >>   	struct snd_soc_tplg_link_config *link, *_link;
> >>   	struct tplg_elem *elem;
> >> -	int i;
> >> +	unsigned int i;
> >>
> >>   	if (t->type != SND_TPLG_TYPE_LINK && t->type != SND_TPLG_TYPE_BE
> >>   	    && t->type != SND_TPLG_TYPE_CC)
> >>
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> >
> 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-01-02 14:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-29 15:41 [PATCH][alsa-lib] topology: fix sign-compare warning introduced to set_link_hw_config() and tplg_add_link_object() Takashi Sakamoto
2016-12-17  0:40 ` Takashi Sakamoto
2016-12-27 10:39   ` Mengdong Lin
2017-01-02 14:20     ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.