ASoC: rsnd: tidyup original for_each_rsnd_xxx macro
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Wed, 12 Feb 2014 01:15:51 +0000 (17:15 -0800)
committerMark Brown <broonie@linaro.org>
Wed, 12 Feb 2014 11:59:35 +0000 (11:59 +0000)
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

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
sound/soc/sh/rcar/adg.c
sound/soc/sh/rcar/rsnd.h

index 8d3a82ef2db5776ae8caed7b825a856a272d9c17..bc8961c5e98699d32fb8f49aa5c60a039f107040 100644 (file)
@@ -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)
 
 
index 8b66dc15fa73374ecf269bea083e5a5d889fb904..9e4efb40416b57acad6f393c68ff6af1eca3ea97 100644 (file)
@@ -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);