Skip to contentSkip to conversation

ASoC: rsnd: tidyup original for_each_rsnd_xxx macro

PATCH Applied Kuninori Morimoto 2 participants 2 messages Feb 12, 2014 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 52f54917.qk3y9f+gv07U3vXN%[email protected]

#1 lore raw

PATCH 1/1 ASoC: rsnd: tidyup original for_each_rsnd_xxx macro

From: Kuninori Morimoto <[email protected]>

Current for_each_rsnd_xxx macro will read out-of-array's memory after last loop operation.
It was not good C language operation, and the binary which was compiled by (at least) gcc 4.8.1 is broken
This patch tidyup these issues

---
 sound/soc/sh/rcar/adg.c  |    7 ++++---
 sound/soc/sh/rcar/rsnd.h |    7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)
sound/soc/sh/rcar/adg.c +4 -3
index 8d3a82e..bc8961c 100644
@@ -25,9 +25,10 @@ struct rsnd_adg {
 };
 
 #define for_each_rsnd_clk(pos, adg, i)		\
-	for (i = 0, (pos) = adg->clk[i];	\
-	     i < CLKMAX;			\
-	     i++, (pos) = adg->clk[i])
+	for (i = 0;				\
+	     (i < CLKMAX) &&			\
+	     ((pos) = adg->clk[i]);		\
+	     i++)
 #define rsnd_priv_to_adg(priv) ((struct rsnd_adg *)(priv)->adg)
 
 
sound/soc/sh/rcar/rsnd.h +4 -3
index 8b66dc1..9e4efb4 100644
@@ -216,9 +216,10 @@ struct rsnd_dai {
 
 #define rsnd_dai_nr(priv) ((priv)->dai_nr)
 #define for_each_rsnd_dai(rdai, priv, i)		\
-	for (i = 0, (rdai) = rsnd_dai_get(priv, i);	\
-	     i < rsnd_dai_nr(priv);			\
-	     i++, (rdai) = rsnd_dai_get(priv, i))
+	for (i = 0;					\
+	     (i < rsnd_dai_nr(priv)) &&			\
+	     ((rdai) = rsnd_dai_get(priv, i));		\
+	     i++)
 
 struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id);
 int rsnd_dai_disconnect(struct rsnd_mod *mod);
Signature · 1 line
1.7.9.5
maintainer Applied
#2 lore raw
Quoted 4 lines · Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

Current for_each_rsnd_xxx macro will read out-of-array's memory after last loop operation.

Applied, thanks.