From: Julia Lawall <hidden> Date: 2017-05-04 20:36:32
These patches fix cases where there is a static on a local variable, but
the variable is either first initialized or never used, on every possible
execution path through the function. The static has no benefit, and
dropping it reduces the code size.
---
drivers/block/drbd/drbd_nl.c | 2 +-
drivers/clocksource/timer-fttmr010.c | 2 +-
drivers/iio/accel/hid-sensor-accel-3d.c | 2 +-
drivers/mfd/max8925-i2c.c | 2 +-
drivers/mfd/twl4030-irq.c | 2 +-
drivers/mtd/chips/cfi_cmdset_0020.c | 2 +-
drivers/mtd/maps/physmap_of_gemini.c | 2 +-
drivers/power/supply/axp20x_usb_power.c | 2 +-
drivers/regulator/palmas-regulator.c | 2 +-
9 files changed, 9 insertions(+), 9 deletions(-)
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
From: Julia Lawall <hidden> Date: 2017-05-04 20:35:14
Drop static on a local variable, when the variable is initialized before
use, on every possible execution path through the function. The static has
no benefit, and dropping it reduces the code size.
The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@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;
// </smpl>
The change in code size is indicates by the following output from the size
command.
before:
text data bss dec hex filename
3879 512 8 4399 112f drivers/iio/accel/hid-sensor-accel-3d.o
after:
text data bss dec hex filename
3863 512 0 4375 1117 drivers/iio/accel/hid-sensor-accel-3d.o
Signed-off-by: Julia Lawall <redacted>
---
drivers/iio/accel/hid-sensor-accel-3d.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Jonathan Cameron <jic23@kernel.org> Date: 2017-05-07 22:26:06
On 04/05/17 21:10, Julia Lawall wrote:
Drop static on a local variable, when the variable is initialized before
use, on every possible execution path through the function. The static has
no benefit, and dropping it reduces the code size.
The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@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;
// </smpl>
The change in code size is indicates by the following output from the size
command.
before:
text data bss dec hex filename
3879 512 8 4399 112f drivers/iio/accel/hid-sensor-accel-3d.o
after:
text data bss dec hex filename
3863 512 0 4375 1117 drivers/iio/accel/hid-sensor-accel-3d.o
Signed-off-by: Julia Lawall <redacted>
Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to play with it.
Thanks,
Jonathan
@@ -347,7 +347,7 @@ static int accel_3d_parse_report(struct platform_device *pdev,staticinthid_accel_3d_probe(structplatform_device*pdev){intret=0;-staticconstchar*name;+constchar*name;structiio_dev*indio_dev;structaccel_3d_state*accel_state;conststructiio_chan_spec*channel_spec;--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, May 4, 2017 at 1:10 PM, Julia Lawall [off-list ref] wrote:
These patches fix cases where there is a static on a local variable, but
the variable is either first initialized or never used, on every possible
execution path through the function. The static has no benefit, and
dropping it reduces the code size.
---
drivers/block/drbd/drbd_nl.c | 2 +-
drivers/clocksource/timer-fttmr010.c | 2 +-
drivers/iio/accel/hid-sensor-accel-3d.c | 2 +-
drivers/mfd/max8925-i2c.c | 2 +-
drivers/mfd/twl4030-irq.c | 2 +-
drivers/mtd/chips/cfi_cmdset_0020.c | 2 +-
drivers/mtd/maps/physmap_of_gemini.c | 2 +-
drivers/power/supply/axp20x_usb_power.c | 2 +-
drivers/regulator/palmas-regulator.c | 2 +-
9 files changed, 9 insertions(+), 9 deletions(-)
It looks like most of these were taken. I pinged the other three. Thanks!
-Kees
--
Kees Cook
Pixel Security