All of lore.kernel.org
 help / color / mirror / Atom feed
* EDAC: remove unnecessary static in edac_fake_inject_write()
@ 2017-07-04 21:44 ` Gustavo A. R. Silva
  0 siblings, 0 replies; 35+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-04 21:44 UTC (permalink / raw)
  To: Borislav Petkov, Mauro Carvalho Chehab
  Cc: linux-edac, linux-kernel, Gustavo A. R. Silva

Remove unnecessary static on local variable _type_.
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 and,
also a significant difference in bss segment. This log is the output
of the size command, before and after the code change:

before:
   text    data     bss     dec     hex filename
   2966     920     128    4014     fae drivers/edac/debugfs.o

after:
   text     data     bss    dec     hex filename
   2961     832      64    3857     f11 drivers/edac/debugfs.o

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/edac/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/edac/debugfs.c b/drivers/edac/debugfs.c
index 92dbb7e..ba0af49 100644
--- a/drivers/edac/debugfs.c
+++ b/drivers/edac/debugfs.c
@@ -8,7 +8,7 @@ static ssize_t edac_fake_inject_write(struct file *file,
 {
 	struct device *dev = file->private_data;
 	struct mem_ctl_info *mci = to_mci(dev);
-	static enum hw_event_mc_err_type type;
+	enum hw_event_mc_err_type type;
 	u16 errcount = mci->fake_inject_count;
 
 	if (!errcount)

^ permalink raw reply related	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2017-07-24 10:35 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-04 21:44 EDAC: remove unnecessary static in edac_fake_inject_write() Gustavo A. R. Silva
2017-07-04 21:44 ` [PATCH] " Gustavo A. R. Silva
2017-07-17  8:39 ` [Cocci] " Borislav Petkov
2017-07-17  8:39   ` Borislav Petkov
2017-07-17  8:39   ` Borislav Petkov
2017-07-21 20:08   ` [Cocci] [PATCH] " Julia Lawall
2017-07-21 20:08     ` Julia Lawall
2017-07-21 20:08     ` Julia Lawall
2017-07-22  6:36     ` [Cocci] [PATCH] " Borislav Petkov
2017-07-22  6:36       ` Borislav Petkov
2017-07-22  6:36       ` Borislav Petkov
2017-07-22  6:39       ` [Cocci] [PATCH] " Julia Lawall
2017-07-22  6:39         ` Julia Lawall
2017-07-22  6:39         ` Julia Lawall
2017-07-22 16:22       ` [Cocci] [PATCH] " Gustavo A. R. Silva
2017-07-22 16:22         ` Gustavo A. R. Silva
2017-07-22 16:22         ` Gustavo A. R. Silva
2017-07-23  2:31         ` [Cocci] [PATCH] " Gustavo A. R. Silva
2017-07-23  2:31           ` Gustavo A. R. Silva
2017-07-23  2:31           ` Gustavo A. R. Silva
2017-07-23  5:07           ` [Cocci] [PATCH] " Julia Lawall
2017-07-23  5:07             ` Julia Lawall
2017-07-23  5:07             ` Julia Lawall
2017-07-23  5:42             ` [Cocci] [PATCH] " Gustavo A. R. Silva
2017-07-23  5:42               ` Gustavo A. R. Silva
2017-07-23  5:42               ` Gustavo A. R. Silva
2017-07-23  5:53               ` [Cocci] [PATCH] " Julia Lawall
2017-07-23  5:53                 ` Julia Lawall
2017-07-23  5:53                 ` Julia Lawall
2017-07-23  6:25                 ` [Cocci] [PATCH] " Gustavo A. R. Silva
2017-07-23  6:25                   ` Gustavo A. R. Silva
2017-07-23  6:25                   ` Gustavo A. R. Silva
2017-07-24 10:34                   ` [Cocci] [PATCH] " Borislav Petkov
2017-07-24 10:34                     ` Borislav Petkov
2017-07-24 10:34                     ` Borislav Petkov

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.