liquidio: lio_main: remove unnecessary static in setup_io_queues()
Subsystems (3)
PATCH 1/1 liquidio: lio_main: remove unnecessary static in setup_io_queues()
Remove unnecessary static on local variables cpu_id_modulus and cpu_id. Such variables are 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. 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
78689 15272 27808 121769 1dba9 drivers/net/ethernet/cavium/liquidio/lio_main.o
after:
text data bss dec hex filename
78667 15128 27680 121475 1da83 drivers/net/ethernet/cavium/liquidio/lio_main.o
--- drivers/net/ethernet/cavium/liquidio/lio_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/cavium/liquidio/lio_main.c +2 -2
@@ -2544,8 +2544,8 @@ static inline int setup_io_queues(struct octeon_device *octeon_dev, {struct octeon_droq_ops droq_ops;struct net_device *netdev; -static int cpu_id; -static int cpu_id_modulus; +int cpu_id; +int cpu_id_modulus;struct octeon_droq *droq;struct napi_struct *napi;int q, q_no, retval =0 ;
Signature · 1 line
2.5.0
Quoted 66 lines · Gustavo A. R. Silva
Remove unnecessary static on local variables
cpu_id_modulusandcpu_id. Such variables are 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. 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
78689 15272 27808 121769 1dba9drivers/net/ethernet/cavium/liquidio/lio_main.oafter:
text data bss dec hex filename
78667 15128 27680 121475 1da83drivers/net/ethernet/cavium/liquidio/lio_main.oSigned-off-by Gustavo A. R. Silva <[email protected]>--- drivers/net/ethernet/cavium/liquidio/lio_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/ethernet/cavium/liquidio/lio_main.c +2
-2@@ -2544,8 +2544,8 @@ static inline int setup_io_queues(struct octeon_device *octeon_dev, {struct octeon_droq_ops droq_ops;struct net_device *netdev; -static int cpu_id; -static int cpu_id_modulus; +int cpu_id; +int cpu_id_modulus;struct octeon_droq *droq;struct napi_struct *napi;int q, q_no, retval =0 ;Signature · 1 line
2.5.0
Thanks.
From: "Gustavo A. R. Silva" <[email protected]>
Date: Tue, 18 Jul 2017 15:53:48 -0500
Quoted 6 lines
Remove unnecessary static on local variables
cpu_id_modulusandcpu_id. Such variables are 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
Signed-off-by Gustavo A. R. Silva <[email protected]>
Applied.