Skip to contentSkip to conversation

ASoC: DAPM: Fix build warning

PATCH Superseded Charles Keepax 2 participants 3 messages Mar 25, 2015

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: DAPM: Fix build warning

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.

---
 sound/soc/soc-dapm.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
sound/soc/soc-dapm.c +6 -4
index 049b300..7640370 100644
@@ -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,
Signature · 1 line
1.7.2.5
#1 lore raw

At Wed, 25 Mar 2015 10:13:28 +0000,

Quoted 9 lines · Charles Keepax

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,

Quoted 5 lines

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.

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

Quoted 41 lines
---
 sound/soc/soc-dapm.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
sound/soc/soc-dapm.c +6 -4
index 049b300..7640370 100644
@@ -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,
Signature · 6 lines
1.7.2.5

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#2 lore raw
Quoted 17 lines · Takashi Iwai

At Wed, 25 Mar 2015 10:13:28 +0000,

Quoted 9 lines · Charles Keepax

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,

Quoted 5 lines

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.

Quoted 8 lines

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