* [PATCH] ASoC: DAPM: Fix build warning
@ 2015-03-25 10:13 Charles Keepax
2015-03-25 10:53 ` [alsa-devel] " Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Charles Keepax @ 2015-03-25 10:13 UTC (permalink / raw)
To: broonie; +Cc: lgirdwood, nikesh, alsa-devel, linux-kernel, patches
commit c66150824b8a ("ASoC: dapm: add code to configure dai link
parameters") introduced the following build warning:
sound/soc/soc-dapm.c: In function 'snd_soc_dapm_new_pcm':
sound/soc/soc-dapm.c:3389:4: warning: passing argument 1 of 'snprintf'
discards 'const' qualifier from pointer target type
snprintf(w_param_text[count], len,
This patch fixes this by adding a non-const temporary variable to hold
the value as it is created before assigning to the entry in
w_param_text.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
sound/soc/soc-dapm.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 049b300..7640370 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3376,18 +3376,20 @@ int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
for (count = 0 ; count < num_params; count++) {
if (!config->stream_name) {
+ char *anon_name;
+
dev_warn(card->dapm.dev,
"ASoC: anonymous config %d for dai link %s\n",
count, link_name);
len = strlen("Anonymous Configuration ") + 3;
- w_param_text[count] =
- devm_kzalloc(card->dev, len, GFP_KERNEL);
- if (!w_param_text[count]) {
+ anon_name = devm_kzalloc(card->dev, len, GFP_KERNEL);
+ if (!anon_name) {
ret = -ENOMEM;
goto outfree_link_name;
}
- snprintf(w_param_text[count], len,
+ snprintf(anon_name, len,
"Anonymous Configuration %d", count);
+ w_param_text[count] = anon_name;
} else {
w_param_text[count] = devm_kmemdup(card->dev,
config->stream_name,
--
1.7.2.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [alsa-devel] [PATCH] ASoC: DAPM: Fix build warning
2015-03-25 10:13 [PATCH] ASoC: DAPM: Fix build warning Charles Keepax
@ 2015-03-25 10:53 ` Takashi Iwai
2015-03-25 11:03 ` Charles Keepax
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2015-03-25 10:53 UTC (permalink / raw)
To: Charles Keepax
Cc: broonie, alsa-devel, patches, lgirdwood, nikesh, linux-kernel
At Wed, 25 Mar 2015 10:13:28 +0000,
Charles Keepax wrote:
>
> commit c66150824b8a ("ASoC: dapm: add code to configure dai link
> parameters") introduced the following build warning:
>
> sound/soc/soc-dapm.c: In function 'snd_soc_dapm_new_pcm':
> sound/soc/soc-dapm.c:3389:4: warning: passing argument 1 of 'snprintf'
> discards 'const' qualifier from pointer target type
> snprintf(w_param_text[count], len,
>
> This patch fixes this by adding a non-const temporary variable to hold
> the value as it is created before assigning to the entry in
> w_param_text.
>
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
An easier fix would be to replace with devm_kasprintf(). Then you can
do it all in a single line.
w_param_text[count] = devm_kasprintf(card->dev, GFP_KERNEL,
"Anonymous Configuration %d", count);
Takashi
> ---
> sound/soc/soc-dapm.c | 10 ++++++----
> 1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
> index 049b300..7640370 100644
> --- a/sound/soc/soc-dapm.c
> +++ b/sound/soc/soc-dapm.c
> @@ -3376,18 +3376,20 @@ int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
>
> for (count = 0 ; count < num_params; count++) {
> if (!config->stream_name) {
> + char *anon_name;
> +
> dev_warn(card->dapm.dev,
> "ASoC: anonymous config %d for dai link %s\n",
> count, link_name);
> len = strlen("Anonymous Configuration ") + 3;
> - w_param_text[count] =
> - devm_kzalloc(card->dev, len, GFP_KERNEL);
> - if (!w_param_text[count]) {
> + anon_name = devm_kzalloc(card->dev, len, GFP_KERNEL);
> + if (!anon_name) {
> ret = -ENOMEM;
> goto outfree_link_name;
> }
> - snprintf(w_param_text[count], len,
> + snprintf(anon_name, len,
> "Anonymous Configuration %d", count);
> + w_param_text[count] = anon_name;
> } else {
> w_param_text[count] = devm_kmemdup(card->dev,
> config->stream_name,
> --
> 1.7.2.5
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [alsa-devel] [PATCH] ASoC: DAPM: Fix build warning
2015-03-25 10:53 ` [alsa-devel] " Takashi Iwai
@ 2015-03-25 11:03 ` Charles Keepax
0 siblings, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2015-03-25 11:03 UTC (permalink / raw)
To: Takashi Iwai
Cc: broonie, alsa-devel, patches, lgirdwood, nikesh, linux-kernel
On Wed, Mar 25, 2015 at 11:53:30AM +0100, Takashi Iwai wrote:
> At Wed, 25 Mar 2015 10:13:28 +0000,
> Charles Keepax wrote:
> >
> > commit c66150824b8a ("ASoC: dapm: add code to configure dai link
> > parameters") introduced the following build warning:
> >
> > sound/soc/soc-dapm.c: In function 'snd_soc_dapm_new_pcm':
> > sound/soc/soc-dapm.c:3389:4: warning: passing argument 1 of 'snprintf'
> > discards 'const' qualifier from pointer target type
> > snprintf(w_param_text[count], len,
> >
> > This patch fixes this by adding a non-const temporary variable to hold
> > the value as it is created before assigning to the entry in
> > w_param_text.
> >
> > Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
>
> An easier fix would be to replace with devm_kasprintf(). Then you can
> do it all in a single line.
>
> w_param_text[count] = devm_kasprintf(card->dev, GFP_KERNEL,
> "Anonymous Configuration %d", count);
>
>
> Takashi
Thanks wasn't aware of that one, I will respin.
Thanks,
Charles
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-25 11:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-25 10:13 [PATCH] ASoC: DAPM: Fix build warning Charles Keepax
2015-03-25 10:53 ` [alsa-devel] " Takashi Iwai
2015-03-25 11:03 ` Charles Keepax
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox