[alsa-devel] [PATCH][alsa-lib] topology: fix sign-compare warning introduced to set_link_hw_config() and tplg_add_link_object()
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)
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)
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
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
participants (3)
-
Mengdong Lin
-
Takashi Iwai
-
Takashi Sakamoto