]> git.alsa-project.org Git - alsa-lib.git/commitdiff
topology: Not compare a for loop iterator with ABI __le32 variables
authorMengdong Lin <mengdong.lin@linux.intel.com>
Thu, 19 Nov 2015 08:33:05 +0000 (03:33 -0500)
committerTakashi Iwai <tiwai@suse.de>
Thu, 19 Nov 2015 09:17:36 +0000 (10:17 +0100)
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 <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/topology/ctl.c
src/topology/pcm.c

index 7d8787f347b858d2141f50714e2d5e047a204272..1c073f7cc32a1fe37dfc4b9d87eda6e95b1929d3 100644 (file)
@@ -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;
 
index 8eb62e46bfc26565231fd0a8435d6c526186e65d..d75aad88672a3e2069465f739d34e0ee6494146d 100644 (file)
@@ -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;