Skip to contentSkip to conversation

ASoC: rsnd: remove unnecessary static in rsnd_ssiu_probe()

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Jul 17, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: rsnd: remove unnecessary static in rsnd_ssiu_probe()

Remove unnecessary static on local variable ops. Such variable is initialized before being used, on every execution path throughout the function. The static has no benefit and, removing it reduces the code size.

This issue was detected using Coccinelle and the following semantic patch:

@bad exists@
position p;
identifier x;
type T;
@@

static T x@p;
...
x = <+...x...+>

@@
identifier x;
expression e;
type T;
position p != bad.p;
@@

-static
T x@p;
... when != x
when strict
?x = e;

In the following log you can see the difference in the code size. Also, there is a significant difference in the bss segment. This log is the output of the size command, before and after the code change:

before:
text data bss dec hex filename
3211 680 64 3955 f73 sound/soc/sh/rcar/ssiu.o

after:
text data bss dec hex filename
3207 592 0 3799 ed7 sound/soc/sh/rcar/ssiu.o

---
 sound/soc/sh/rcar/ssiu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sh/rcar/ssiu.c +1 -1
index bed2c9c..4d94875 100644
@@ -250,7 +250,7 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv)
 {
 	struct device *dev = rsnd_priv_to_dev(priv);
 	struct rsnd_ssiu *ssiu;
-	static struct rsnd_mod_ops *ops;
+	struct rsnd_mod_ops *ops;
 	int i, nr, ret;
 
 	/* same number to SSI */
Signature · 1 line
2.5.0
#1 lore raw
Quoted 5 lines · Gustavo A. R. Silva

Remove unnecessary static on local variable ops. Such variable is initialized before being used, on every execution path throughout the function. The static has no benefit and, removing it reduces the code size.

[]

Quoted 11 lines

In the following log you can see the difference in the code size. Also, there is a significant difference in the bss segment. This log is the output of the size command, before and after the code change:

before:
text data bss dec hex filename
3211 680 64 3955 f73 sound/soc/sh/rcar/ssiu.o

after:
text data bss dec hex filename
3207 592 0 3799 ed7 sound/soc/sh/rcar/ssiu.o

[]

sound/soc/sh/rcar/ssiu.c

Quoted 1 line
sound/soc/sh/rcar/ssiu.c +0 -0

[]

sound/soc/sh/rcar/ssiu.c int rsnd_ssiu_probe(struct rsnd_priv *priv) · line 256

Quoted 9 lines
sound/soc/sh/rcar/ssiu.c +1 -1
@@ -250,7 +250,7 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv)
 {
 	struct device *dev = rsnd_priv_to_dev(priv);
 	struct rsnd_ssiu *ssiu;
-	static struct rsnd_mod_ops *ops;
+	struct rsnd_mod_ops *ops;
 	int i, nr, ret;
 
 	/* same number to SSI */

I'm not an sh user anymore, but it's curious to me why the static removal has such a large impact on data size.

Is this for an allyesconfig with debug symbols?

btw: this does compile for x86 and those sizes seem
more sensible.

$ size sound/soc/sh/rcar/ssiu.o*   text	   data	    bss	    dec	    hex	filename
   1950	    248	      0	   2198	    896	sound/soc/sh/rcar/ssiu.o.defconfig.new
   1950	    248	      8	   2206	    89e	sound/soc/sh/rcar/ssiu.o.defconfig.old
   2692	    248	      0	   2940	    b7c	sound/soc/sh/rcar/ssiu.o.allyesconfig.new
   2692	    248	      8	   2948	    b84	sound/soc/sh/rcar/ssiu.o.allyesconfig.old