s5k5baf: remove unnecessary static in s5k5baf_get_selection()
PATCH 1/1 s5k5baf: remove unnecessary static in s5k5baf_get_selection()
Remove unnecessary static on local variable rtype. 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 27765 5656 320 33741 83cd drivers/media/i2c/s5k5baf.o
after:
text data bss dec hex filename 27733 5600 256 33589 8335 drivers/media/i2c/s5k5baf.o
--- drivers/media/i2c/s5k5baf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/s5k5baf.c +1 -1
@@ -1374,7 +1374,7 @@ static int s5k5baf_get_selection(struct v4l2_subdev *sd,struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_selection *sel) { - static enum selection_rect rtype; + enum selection_rect rtype;struct s5k5baf *state =to_s5k5baf (sd); rtype =s5k5baf_get_sel_rect (sel->pad, sel->target);
Signature · 1 line
2.5.0
Quoted 39 lines · Gustavo A. R. Silva
Remove unnecessary static on local variable rtype. 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 27765 5656 320 33741 83cd drivers/media/i2c/s5k5baf.o
Quoted 6 lines
after:
text data bss dec hex filename 27733 5600 256 33589 8335 drivers/media/i2c/s5k5baf.oSigned-off-by Gustavo A. R. Silva <[email protected]>
--
Regards
Andrzej
Quoted 17 lines
--- drivers/media/i2c/s5k5baf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/i2c/s5k5baf.c +1
-1@@ -1374,7 +1374,7 @@ static int s5k5baf_get_selection(struct v4l2_subdev *sd,struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_selection *sel) { - static enum selection_rect rtype; + enum selection_rect rtype;struct s5k5baf *state =to_s5k5baf (sd); rtype =s5k5baf_get_sel_rect (sel->pad, sel->target);