[alsa-devel] [PATCH][alsa-lib] topology: fix sign-compare warning introduced to set_link_hw_config() and tplg_add_link_object()

Takashi Sakamoto o-takashi at sakamocchi.jp
Sat Dec 17 01:40:57 CET 2016


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 at 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)
> 


More information about the Alsa-devel mailing list