From cde9a37c06a09e890d2c4b175bd548ed6f247f93 Mon Sep 17 00:00:00 2001 From: Mengdong Lin Date: Thu, 19 Nov 2015 03:33:05 -0500 Subject: topology: Not compare a for loop iterator with ABI __le32 variables The iterator 'i' in a loop is a usually a integer. But ABI variables use type _le32, which is converted to host unsigned integer. Comparing them can cause gcc warning: comparison between signed and unsigned integer expressions[-Wsign-compare]. Signed-off-by: Mengdong Lin Signed-off-by: Takashi Iwai --- src/topology/ctl.c | 22 +++++++++++----------- src/topology/pcm.c | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/topology') diff --git a/src/topology/ctl.c b/src/topology/ctl.c index 7d8787f3..1c073f7c 100644 --- a/src/topology/ctl.c +++ b/src/topology/ctl.c @@ -676,7 +676,7 @@ int tplg_add_mixer(snd_tplg_t *tplg, struct snd_tplg_mixer_template *mixer, struct snd_soc_tplg_private *priv = mixer->priv; struct snd_soc_tplg_mixer_control *mc; struct tplg_elem *elem; - int ret, i; + int ret, i, num_channels; tplg_dbg(" Control Mixer: %s\n", mixer->hdr.name); @@ -708,9 +708,10 @@ int tplg_add_mixer(snd_tplg_t *tplg, struct snd_tplg_mixer_template *mixer, for (i = 0; i < SND_SOC_TPLG_MAX_CHAN; i++) mc->channel[i].reg = -1; - if (mixer->map) - mc->num_channels = mixer->map->num_channels; - for (i = 0; i < mc->num_channels; i++) { + num_channels = mixer->map ? mixer->map->num_channels : 0; + mc->num_channels = num_channels; + + for (i = 0; i < num_channels; i++) { struct snd_tplg_channel_elem *channel = &mixer->map->channel[i]; mc->channel[i].size = channel->size; @@ -743,7 +744,7 @@ int tplg_add_enum(snd_tplg_t *tplg, struct snd_tplg_enum_template *enum_ctl, { struct snd_soc_tplg_enum_control *ec; struct tplg_elem *elem; - int ret, i; + int ret, i, num_items; tplg_dbg(" Control Enum: %s\n", enum_ctl->hdr.name); @@ -765,15 +766,14 @@ int tplg_add_enum(snd_tplg_t *tplg, struct snd_tplg_enum_template *enum_ctl, return ret; } - ec->items = enum_ctl->items; - if (ec->items > SND_SOC_TPLG_NUM_TEXTS) - ec->items = SND_SOC_TPLG_NUM_TEXTS; - + num_items = enum_ctl->items < SND_SOC_TPLG_NUM_TEXTS ? + enum_ctl->items : SND_SOC_TPLG_NUM_TEXTS; + ec->items = num_items; ec->mask = enum_ctl->mask; ec->count = enum_ctl->items; if (enum_ctl->texts != NULL) { - for (i = 0; i < ec->items; i++) { + for (i = 0; i < num_items; i++) { if (enum_ctl->texts[i] != NULL) strncpy(ec->texts[i], enum_ctl->texts[i], SNDRV_CTL_ELEM_ID_NAME_MAXLEN); @@ -781,7 +781,7 @@ int tplg_add_enum(snd_tplg_t *tplg, struct snd_tplg_enum_template *enum_ctl, } if (enum_ctl->values != NULL) { - for (i = 0; i < ec->items; i++) { + for (i = 0; i < num_items; i++) { if (enum_ctl->values[i]) continue; diff --git a/src/topology/pcm.c b/src/topology/pcm.c index 8eb62e46..d75aad88 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -550,7 +550,7 @@ int tplg_add_pcm_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t) } pcm->num_streams = pcm_tpl->num_streams; - for (i = 0; i < pcm->num_streams; i++) + for (i = 0; i < pcm_tpl->num_streams; i++) tplg_add_stream_object(&pcm->stream[i], &pcm_tpl->stream[i]); return 0; @@ -583,7 +583,7 @@ int tplg_add_link_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t) lk->id = link->id; lk->num_streams = link->num_streams; - for (i = 0; i < lk->num_streams; i++) + for (i = 0; i < link->num_streams; i++) tplg_add_stream_object(&lk->stream[i], &link->stream[i]); return 0; -- cgit v1.2.1