Skip to contentSkip to conversation

wireless: airo: remove unnecessary static in writerids()

PATCH Applied Gustavo A. R. Silva 2 participants 2 messages Jul 18, 2017 – Jul 19, 2017

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

PATCH 1/1 wireless: airo: remove unnecessary static in writerids()

Remove unnecessary static on local function pointer _writer_. Such pointer is initialized before being used, on every execution path throughout the function. The static has no benefit and, removing it reduces the object file 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 a significant difference in the object file size. This log is the output of the size command, before and after the code change:

before:
text data bss dec hex filename
113797 19152 1216 134165 20c15 drivers/net/wireless/cisco/airo.o

after:
text data bss dec hex filename
113881 19096 1152 134129 20bf1 drivers/net/wireless/cisco/airo.o

---
 drivers/net/wireless/cisco/airo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/cisco/airo.c +1 -1
index 84143a0..1066d84 100644
@@ -7837,7 +7837,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
 	struct airo_info *ai = dev->ml_priv;
 	int  ridcode;
         int  enabled;
-	static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
+	int (*writer)(struct airo_info *, u16 rid, const void *, int, int);
 	unsigned char *iobuf;
 
 	/* Only super-user can write RIDs */
Signature · 1 line
2.5.0
maintainer Applied
#1 lore raw

From: "Gustavo A. R. Silva" <[email protected]>
Date: Tue, 18 Jul 2017 15:37:11 -0500

Quoted 6 lines

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

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

...

Quoted 1 line

Applied.