* [PATCH] ASoC: rsnd: remove unnecessary static in rsnd_ssiu_probe()
@ 2017-07-17 15:30 Gustavo A. R. Silva
2017-07-17 16:31 ` Joe Perches
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-17 15:30 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
Cc: alsa-devel, linux-kernel, 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.
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
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
sound/soc/sh/rcar/ssiu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/sh/rcar/ssiu.c b/sound/soc/sh/rcar/ssiu.c
index bed2c9c..4d94875 100644
--- a/sound/soc/sh/rcar/ssiu.c
+++ b/sound/soc/sh/rcar/ssiu.c
@@ -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 */
--
2.5.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: rsnd: remove unnecessary static in rsnd_ssiu_probe()
2017-07-17 15:30 [PATCH] ASoC: rsnd: remove unnecessary static in rsnd_ssiu_probe() Gustavo A. R. Silva
@ 2017-07-17 16:31 ` Joe Perches
0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2017-07-17 16:31 UTC (permalink / raw)
To: Gustavo A. R. Silva, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai
Cc: alsa-devel, linux-kernel
On Mon, 2017-07-17 at 10:30 -0500, Gustavo A. R. Silva wrote:
> 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.
[]
> 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
[]
> diff --git a/sound/soc/sh/rcar/ssiu.c b/sound/soc/sh/rcar/ssiu.c
[]
> @@ -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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-17 16:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-17 15:30 [PATCH] ASoC: rsnd: remove unnecessary static in rsnd_ssiu_probe() Gustavo A. R. Silva
2017-07-17 16:31 ` Joe Perches
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.