Skip to contentSkip to conversation

ASoC: soc-core: Fix sparse warning in be32_to_cpup() call

PATCH Superseded Jyri Sarha 2 participants 3 messages Sep 17, 2015

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jyri Sarha

author
#0 lore raw

PATCH 1/1 ASoC: soc-core: Fix sparse warning in be32_to_cpup() call

---
 sound/soc/soc-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-core.c +1 -1
index 1929f0e..614b831 100644
@@ -3301,7 +3301,7 @@ static int snd_soc_of_get_slot_mask(struct device_node *np,
 		return 0;
 	val /= sizeof(u32);
 	for (i = 0; i < val; i++)
-		if (be32_to_cpup(&of_slot_mask[i]))
+		if (be32_to_cpup((__be32 *)&of_slot_mask[i]))
 			*mask |= (1 << i);
 
 	return val;
Signature · 1 line
1.9.1
maintainer
#1 lore raw

sound/soc/soc-core.c static int snd_soc_of_get_slot_mask(struct device_node *np, · line 3305

Quoted 6 lines · Jyri Sarha
sound/soc/soc-core.c +1 -1
 	val /= sizeof(u32);
 	for (i = 0; i < val; i++)
-		if (be32_to_cpup(&of_slot_mask[i]))
+		if (be32_to_cpup((__be32 *)&of_slot_mask[i]))
 			*mask |= (1 << i);

There was no changelog and this is setting off alarm bells since the cast just smashes warnings - are you sure we're not missing some other annotations and that a cast is the best thing here?

author
#2 lore raw
Quoted 13 lines · Mark Brown

sound/soc/soc-core.c static int snd_soc_of_get_slot_mask(struct device_node *np, · line 3305

Quoted 6 lines · Jyri Sarha
  	val /= sizeof(u32);
  	for (i = 0; i < val; i++)
sound/soc/soc-core.c +1 -1
-		if (be32_to_cpup(&of_slot_mask[i]))
+		if (be32_to_cpup((__be32 *)&of_slot_mask[i]))
  			*mask |= (1 << i);

There was no changelog and this is setting off alarm bells since the cast just smashes warnings - are you sure we're not missing some other annotations and that a cast is the best thing here?

You are right, I was a bit hasty. It is better to declare of_slot_mask to const __be32 * in the first place, instead of just const u32 * and then casting it to something else.

I'll send a new patch shortly.

BR,
Jyri