linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] Drop unnecessary static
@ 2017-05-04 20:10 Julia Lawall
  2017-05-04 20:10 ` [PATCH 1/9] mtd: cfi_cmdset_0020: " Julia Lawall
                   ` (9 more replies)
  0 siblings, 10 replies; 28+ messages in thread
From: Julia Lawall @ 2017-05-04 20:10 UTC (permalink / raw)
  To: linux-pm
  Cc: keescook, kernel-janitors, linux-mtd, linux-kernel, drbd-dev,
	linux-omap, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, linux-input, linux-iio

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(-)

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

* [PATCH 1/9] mtd: cfi_cmdset_0020: Drop unnecessary static
  2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
@ 2017-05-04 20:10 ` Julia Lawall
  2017-05-11 18:49   ` Brian Norris
  2017-05-04 20:10 ` [PATCH 2/9] mtd: physmap_of: " Julia Lawall
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Julia Lawall @ 2017-05-04 20:10 UTC (permalink / raw)
  To: David Woodhouse
  Cc: keescook, kernel-janitors, Brian Norris, Boris Brezillon,
	Marek Vasut, Richard Weinberger, Cyrille Pitchen, linux-mtd,
	linux-kernel

Drop static on a local variable, when the variable is initialized before
any 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
  16671      48      16   16735    415f drivers/mtd/chips/cfi_cmdset_0020.o

after:
   text    data     bss     dec     hex filename
  16639      48       8   16695    4137 drivers/mtd/chips/cfi_cmdset_0020.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/mtd/chips/cfi_cmdset_0020.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index 94d3eb4..7d34296 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -666,7 +666,7 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,
 	size_t	 totlen = 0, thislen;
 	int	 ret = 0;
 	size_t	 buflen = 0;
-	static char *buffer;
+	char *buffer;
 
 	if (!ECCBUF_SIZE) {
 		/* We should fall back to a general writev implementation.

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

* [PATCH 2/9] mtd: physmap_of: Drop unnecessary static
  2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
  2017-05-04 20:10 ` [PATCH 1/9] mtd: cfi_cmdset_0020: " Julia Lawall
@ 2017-05-04 20:10 ` Julia Lawall
  2017-05-04 20:10 ` [PATCH 3/9] drbd: " Julia Lawall
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 28+ messages in thread
From: Julia Lawall @ 2017-05-04 20:10 UTC (permalink / raw)
  To: David Woodhouse
  Cc: keescook, kernel-janitors, Brian Norris, Boris Brezillon,
	Marek Vasut, Richard Weinberger, Cyrille Pitchen, linux-mtd,
	linux-kernel

Drop static on a local variable, when the variable is initialized before
any 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
    835      80       8     923     39b drivers/mtd/maps/physmap_of_gemini.o

after:
   text    data     bss     dec     hex filename
    823      80       0     903     387 drivers/mtd/maps/physmap_of_gemini.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/mtd/maps/physmap_of_gemini.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/maps/physmap_of_gemini.c b/drivers/mtd/maps/physmap_of_gemini.c
index 9d371cd..05b286b 100644
--- a/drivers/mtd/maps/physmap_of_gemini.c
+++ b/drivers/mtd/maps/physmap_of_gemini.c
@@ -59,7 +59,7 @@ int of_flash_probe_gemini(struct platform_device *pdev,
 			  struct device_node *np,
 			  struct map_info *map)
 {
-	static struct regmap *rmap;
+	struct regmap *rmap;
 	struct device *dev = &pdev->dev;
 	u32 val;
 	int ret;

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

* [PATCH 3/9] drbd: Drop unnecessary static
  2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
  2017-05-04 20:10 ` [PATCH 1/9] mtd: cfi_cmdset_0020: " Julia Lawall
  2017-05-04 20:10 ` [PATCH 2/9] mtd: physmap_of: " Julia Lawall
@ 2017-05-04 20:10 ` Julia Lawall
  2017-05-05  7:19   ` Roland Kammerer
  2017-05-04 20:10 ` [PATCH 4/9] power: supply: axp20x_usb_power: " Julia Lawall
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Julia Lawall @ 2017-05-04 20:10 UTC (permalink / raw)
  To: Philipp Reisner
  Cc: keescook, kernel-janitors, Lars Ellenberg, drbd-dev, linux-kernel

Drop static on a local variable, when the variable is initialized before
any 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
  67299    2291    1056   70646   113f6 drivers/block/drbd/drbd_nl.o

after:
   text    data     bss     dec     hex filename
  67283    2291    1056   70630   113e6 drivers/block/drbd/drbd_nl.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/block/drbd/drbd_nl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 02255a0..ad0fcb4 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -2294,7 +2294,7 @@ static bool conn_ov_running(struct drbd_connection *connection)
 static enum drbd_ret_code
 check_net_options(struct drbd_connection *connection, struct net_conf *new_net_conf)
 {
-	static enum drbd_ret_code rv;
+	enum drbd_ret_code rv;
 	struct drbd_peer_device *peer_device;
 	int i;
 

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

* [PATCH 4/9] power: supply: axp20x_usb_power: Drop unnecessary static
  2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
                   ` (2 preceding siblings ...)
  2017-05-04 20:10 ` [PATCH 3/9] drbd: " Julia Lawall
@ 2017-05-04 20:10 ` Julia Lawall
  2017-05-15 13:25   ` Sebastian Reichel
  2017-05-04 20:10 ` [PATCH 5/9] mfd: " Julia Lawall
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Julia Lawall @ 2017-05-04 20:10 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: keescook, kernel-janitors, Chen-Yu Tsai, linux-pm, linux-kernel

Drop static on a local variable, when 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.

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
   2865     252       8    3125     c35 drivers/power/supply/axp20x_usb_power.o

after:
   text    data     bss     dec     hex filename
   2822     252       0    3074     c02 drivers/power/supply/axp20x_usb_power.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/power/supply/axp20x_usb_power.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c
index 2397c48..44f70dc 100644
--- a/drivers/power/supply/axp20x_usb_power.c
+++ b/drivers/power/supply/axp20x_usb_power.c
@@ -339,7 +339,7 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
 		"VBUS_REMOVAL", "VBUS_VALID", "VBUS_NOT_VALID", NULL };
 	static const char * const axp22x_irq_names[] = {
 		"VBUS_PLUGIN", "VBUS_REMOVAL", NULL };
-	static const char * const *irq_names;
+	const char * const *irq_names;
 	const struct power_supply_desc *usb_power_desc;
 	int i, irq, ret;
 

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

* [PATCH 5/9] mfd: Drop unnecessary static
  2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
                   ` (3 preceding siblings ...)
  2017-05-04 20:10 ` [PATCH 4/9] power: supply: axp20x_usb_power: " Julia Lawall
@ 2017-05-04 20:10 ` Julia Lawall
  2017-06-27 23:46   ` Kees Cook
  2017-07-17 11:01   ` Lee Jones
  2017-05-04 20:10 ` [PATCH 6/9] regulator: palmas: " Julia Lawall
                   ` (4 subsequent siblings)
  9 siblings, 2 replies; 28+ messages in thread
From: Julia Lawall @ 2017-05-04 20:10 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: keescook, kernel-janitors, Lee Jones, linux-omap, linux-kernel

Drop static on a local variable, when the variable is initialized before
any use, on every possible execution path through the function.

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 increases the code size but decreases the size of the bss segment.

before:
   text    data     bss     dec     hex filename
   3369     272     300    3941     f65 drivers/mfd/twl4030-irq.o

after:
   text    data     bss     dec     hex filename
   3401     272      28    3701     e75 drivers/mfd/twl4030-irq.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/mfd/twl4030-irq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index b46c0cf..c775f27 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -683,7 +683,7 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base)
 
 int twl4030_init_irq(struct device *dev, int irq_num)
 {
-	static struct irq_chip	twl4030_irq_chip;
+	struct irq_chip	twl4030_irq_chip;
 	int			status, i;
 	int			irq_base, irq_end, nr_irqs;
 	struct			device_node *node = dev->of_node;

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

* [PATCH 6/9] regulator: palmas: Drop unnecessary static
  2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
                   ` (4 preceding siblings ...)
  2017-05-04 20:10 ` [PATCH 5/9] mfd: " Julia Lawall
@ 2017-05-04 20:10 ` Julia Lawall
  2017-05-14 10:13   ` Mark Brown
  2017-05-23 11:24   ` Applied "regulator: palmas: Drop unnecessary static" to the regulator tree Mark Brown
  2017-05-04 20:10 ` [PATCH 7/9] iio: hid-sensor-accel-3d: Drop unnecessary static Julia Lawall
                   ` (3 subsequent siblings)
  9 siblings, 2 replies; 28+ messages in thread
From: Julia Lawall @ 2017-05-04 20:10 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: keescook, kernel-janitors, Liam Girdwood, Mark Brown, linux-omap,
	linux-kernel

Drop static on a local variable, when the variable is initialized before
any use, on every possible execution path through the function.

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>

There is no reduction in code size in this case, but the change does reduce
the size of the bss segment, containing uninitialized static data.

before:
   text    data     bss     dec     hex filename
  12882    3480       8   16370    3ff2 drivers/regulator/palmas-regulator.o

after:
   text    data     bss     dec     hex filename
  12882    3480       0   16362    3fea drivers/regulator/palmas-regulator.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/regulator/palmas-regulator.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 31ae5ee..34d4a62 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -1491,7 +1491,7 @@ static int palmas_dt_to_pdata(struct device *dev,
 	}
 
 	for (idx = 0; idx < ddata->max_reg; idx++) {
-		static struct of_regulator_match *match;
+		struct of_regulator_match *match;
 		struct palmas_reg_init *rinit;
 		struct device_node *np;
 

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

* [PATCH 7/9] iio: hid-sensor-accel-3d: Drop unnecessary static
  2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
                   ` (5 preceding siblings ...)
  2017-05-04 20:10 ` [PATCH 6/9] regulator: palmas: " Julia Lawall
@ 2017-05-04 20:10 ` Julia Lawall
  2017-05-07 12:57   ` Jonathan Cameron
  2017-05-04 20:10 ` [PATCH 8/9] clocksource/drivers/fttmr010: " Julia Lawall
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Julia Lawall @ 2017-05-04 20:10 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: keescook, kernel-janitors, Jonathan Cameron, Srinivas Pandruvada,
	Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	linux-input, linux-iio, linux-kernel

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 <Julia.Lawall@lip6.fr>

---
 drivers/iio/accel/hid-sensor-accel-3d.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 43a6cb0..2238a26 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -347,7 +347,7 @@ static int accel_3d_parse_report(struct platform_device *pdev,
 static int hid_accel_3d_probe(struct platform_device *pdev)
 {
 	int ret = 0;
-	static const char *name;
+	const char *name;
 	struct iio_dev *indio_dev;
 	struct accel_3d_state *accel_state;
 	const struct iio_chan_spec *channel_spec;

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

* [PATCH 8/9] clocksource/drivers/fttmr010: Drop unnecessary static
  2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
                   ` (6 preceding siblings ...)
  2017-05-04 20:10 ` [PATCH 7/9] iio: hid-sensor-accel-3d: Drop unnecessary static Julia Lawall
@ 2017-05-04 20:10 ` Julia Lawall
  2017-06-27 23:45   ` Kees Cook
  2017-05-04 20:10 ` [PATCH 9/9] mfd: max8925-i2c: " Julia Lawall
  2017-06-27 23:47 ` [PATCH 0/9] " Kees Cook
  9 siblings, 1 reply; 28+ messages in thread
From: Julia Lawall @ 2017-05-04 20:10 UTC (permalink / raw)
  To: Daniel Lezcano; +Cc: keescook, kernel-janitors, Thomas Gleixner, linux-kernel

Drop static on a local variable, when the variable is initialized before
any 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
   1777    4352      20    6149    1805 drivers/clocksource/timer-fttmr010.o

after:
   text    data     bss     dec     hex filename
   1770    4352      12    6134    17f6 drivers/clocksource/timer-fttmr010.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/clocksource/timer-fttmr010.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c
index b4a6f1e..055c65e 100644
--- a/drivers/clocksource/timer-fttmr010.c
+++ b/drivers/clocksource/timer-fttmr010.c
@@ -263,7 +263,7 @@ static int __init fttmr010_timer_of_init(struct device_node *np)
 
 static int __init gemini_timer_of_init(struct device_node *np)
 {
-	static struct regmap *map;
+	struct regmap *map;
 	int ret;
 	u32 val;
 

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

* [PATCH 9/9] mfd: max8925-i2c: Drop unnecessary static
  2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
                   ` (7 preceding siblings ...)
  2017-05-04 20:10 ` [PATCH 8/9] clocksource/drivers/fttmr010: " Julia Lawall
@ 2017-05-04 20:10 ` Julia Lawall
  2017-06-27 23:47   ` Kees Cook
  2017-07-17 11:00   ` Lee Jones
  2017-06-27 23:47 ` [PATCH 0/9] " Kees Cook
  9 siblings, 2 replies; 28+ messages in thread
From: Julia Lawall @ 2017-05-04 20:10 UTC (permalink / raw)
  To: Lee Jones; +Cc: keescook, kernel-janitors, linux-kernel

Drop static on a local variable, when the variable is initialized before
any 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
   2579     240      16    2835     b13 drivers/mfd/max8925-i2c.o

after:
   text    data     bss     dec     hex filename
   2531     240       8    2779     adb drivers/mfd/max8925-i2c.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/mfd/max8925-i2c.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
index 5c80aea..1006323 100644
--- a/drivers/mfd/max8925-i2c.c
+++ b/drivers/mfd/max8925-i2c.c
@@ -151,7 +151,7 @@ static int max8925_probe(struct i2c_client *client,
 				   const struct i2c_device_id *id)
 {
 	struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
-	static struct max8925_chip *chip;
+	struct max8925_chip *chip;
 	struct device_node *node = client->dev.of_node;
 
 	if (node && !pdata) {

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

* Re: [PATCH 3/9] drbd: Drop unnecessary static
  2017-05-04 20:10 ` [PATCH 3/9] drbd: " Julia Lawall
@ 2017-05-05  7:19   ` Roland Kammerer
  2017-06-27 23:49     ` Kees Cook
  0 siblings, 1 reply; 28+ messages in thread
From: Roland Kammerer @ 2017-05-05  7:19 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Philipp Reisner, keescook, kernel-janitors, Lars Ellenberg,
	drbd-dev, linux-kernel

On Thu, May 04, 2017 at 10:10:48PM +0200, Julia Lawall wrote:
> Drop static on a local variable, when the variable is initialized before
> any 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
>   67299    2291    1056   70646   113f6 drivers/block/drbd/drbd_nl.o
> 
> after:
>    text    data     bss     dec     hex filename
>   67283    2291    1056   70630   113e6 drivers/block/drbd/drbd_nl.o
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>  drivers/block/drbd/drbd_nl.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
> index 02255a0..ad0fcb4 100644
> --- a/drivers/block/drbd/drbd_nl.c
> +++ b/drivers/block/drbd/drbd_nl.c
> @@ -2294,7 +2294,7 @@ static bool conn_ov_running(struct drbd_connection *connection)
>  static enum drbd_ret_code
>  check_net_options(struct drbd_connection *connection, struct net_conf *new_net_conf)
>  {
> -	static enum drbd_ret_code rv;
> +	enum drbd_ret_code rv;
>  	struct drbd_peer_device *peer_device;
>  	int i;

Yes, that already got dropped for drbd9 and is obviously correct for
in-tree drbd8.

Signed-off-by: Roland Kammerer <roland.kammerer@linbit.com>

Regards, rck

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

* Re: [PATCH 7/9] iio: hid-sensor-accel-3d: Drop unnecessary static
  2017-05-04 20:10 ` [PATCH 7/9] iio: hid-sensor-accel-3d: Drop unnecessary static Julia Lawall
@ 2017-05-07 12:57   ` Jonathan Cameron
  0 siblings, 0 replies; 28+ messages in thread
From: Jonathan Cameron @ 2017-05-07 12:57 UTC (permalink / raw)
  To: Julia Lawall, Jiri Kosina
  Cc: keescook, kernel-janitors, Srinivas Pandruvada, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-input,
	linux-iio, linux-kernel

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 <Julia.Lawall@lip6.fr>
Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to play with it.

Thanks,

Jonathan
> 
> ---
>  drivers/iio/accel/hid-sensor-accel-3d.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
> index 43a6cb0..2238a26 100644
> --- a/drivers/iio/accel/hid-sensor-accel-3d.c
> +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
> @@ -347,7 +347,7 @@ static int accel_3d_parse_report(struct platform_device *pdev,
>  static int hid_accel_3d_probe(struct platform_device *pdev)
>  {
>  	int ret = 0;
> -	static const char *name;
> +	const char *name;
>  	struct iio_dev *indio_dev;
>  	struct accel_3d_state *accel_state;
>  	const struct iio_chan_spec *channel_spec;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH 1/9] mtd: cfi_cmdset_0020: Drop unnecessary static
  2017-05-04 20:10 ` [PATCH 1/9] mtd: cfi_cmdset_0020: " Julia Lawall
@ 2017-05-11 18:49   ` Brian Norris
  0 siblings, 0 replies; 28+ messages in thread
From: Brian Norris @ 2017-05-11 18:49 UTC (permalink / raw)
  To: Julia Lawall
  Cc: David Woodhouse, keescook, kernel-janitors, Boris Brezillon,
	Marek Vasut, Richard Weinberger, Cyrille Pitchen, linux-mtd,
	linux-kernel

On Thu, May 04, 2017 at 10:10:46PM +0200, Julia Lawall wrote:
> Drop static on a local variable, when the variable is initialized before
> any 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
>   16671      48      16   16735    415f drivers/mtd/chips/cfi_cmdset_0020.o
> 
> after:
>    text    data     bss     dec     hex filename
>   16639      48       8   16695    4137 drivers/mtd/chips/cfi_cmdset_0020.o
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Applied patches 1 and 2 to l2-mtd.git/next, for 4.13.

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

* Re: [PATCH 6/9] regulator: palmas: Drop unnecessary static
  2017-05-04 20:10 ` [PATCH 6/9] regulator: palmas: " Julia Lawall
@ 2017-05-14 10:13   ` Mark Brown
  2017-05-15 10:41     ` Julia Lawall
  2017-05-23 11:24   ` Applied "regulator: palmas: Drop unnecessary static" to the regulator tree Mark Brown
  1 sibling, 1 reply; 28+ messages in thread
From: Mark Brown @ 2017-05-14 10:13 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Tony Lindgren, keescook, kernel-janitors, Liam Girdwood,
	linux-omap, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]

On Thu, May 04, 2017 at 10:10:51PM +0200, Julia Lawall wrote:
> Drop static on a local variable, when the variable is initialized before
> any use, on every possible execution path through the function.

When sending a bunch of changes like this please either send the cover
letter to everyone or send each patch separately (this seems like it
stands alone just fine).  The first question when only one patch in a
series is visible is always what are the interdependencies.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 6/9] regulator: palmas: Drop unnecessary static
  2017-05-14 10:13   ` Mark Brown
@ 2017-05-15 10:41     ` Julia Lawall
  2017-05-15 10:54       ` Mark Brown
  0 siblings, 1 reply; 28+ messages in thread
From: Julia Lawall @ 2017-05-15 10:41 UTC (permalink / raw)
  To: Mark Brown
  Cc: Tony Lindgren, keescook, kernel-janitors, Liam Girdwood,
	linux-omap, linux-kernel



On Sun, 14 May 2017, Mark Brown wrote:

> On Thu, May 04, 2017 at 10:10:51PM +0200, Julia Lawall wrote:
> > Drop static on a local variable, when the variable is initialized before
> > any use, on every possible execution path through the function.
>
> When sending a bunch of changes like this please either send the cover
> letter to everyone or send each patch separately (this seems like it
> stands alone just fine).  The first question when only one patch in a
> series is visible is always what are the interdependencies.

Not sure what is best to do.  If the cover letter goes to everyone, it
could be rejected for too many recipients.  Currently it goes to all the
mailing lists.  If the patches are sent separately, then could there be a
cover letter for each one?  If the semantic patch is complicated, then I
typically put the whole thing there, and an abbreviated one in the actual
patch.  That is not relevant here, because the semantic patch is small.
Part of the purpose of the cover letter was to allow people who were not
interested to skip over the whole thing at once.

julia

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

* Re: [PATCH 6/9] regulator: palmas: Drop unnecessary static
  2017-05-15 10:41     ` Julia Lawall
@ 2017-05-15 10:54       ` Mark Brown
  0 siblings, 0 replies; 28+ messages in thread
From: Mark Brown @ 2017-05-15 10:54 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Tony Lindgren, keescook, kernel-janitors, Liam Girdwood,
	linux-omap, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

On Mon, May 15, 2017 at 06:41:41PM +0800, Julia Lawall wrote:

> mailing lists.  If the patches are sent separately, then could there be a
> cover letter for each one?  If the semantic patch is complicated, then I
> typically put the whole thing there, and an abbreviated one in the actual
> patch.  That is not relevant here, because the semantic patch is small.

Well, if the cover letter is needed to understand the patch then it
needs to go to everyone anyway...

> Part of the purpose of the cover letter was to allow people who were not
> interested to skip over the whole thing at once.

On the flip side things that lack context can get discarded easily.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 4/9] power: supply: axp20x_usb_power: Drop unnecessary static
  2017-05-04 20:10 ` [PATCH 4/9] power: supply: axp20x_usb_power: " Julia Lawall
@ 2017-05-15 13:25   ` Sebastian Reichel
  0 siblings, 0 replies; 28+ messages in thread
From: Sebastian Reichel @ 2017-05-15 13:25 UTC (permalink / raw)
  To: Julia Lawall
  Cc: keescook, kernel-janitors, Chen-Yu Tsai, linux-pm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1466 bytes --]

Hi Julia,

On Thu, May 04, 2017 at 10:10:49PM +0200, Julia Lawall wrote:
> Drop static on a local variable, when 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.
> 
> [...]
> 
> before:
>    text    data     bss     dec     hex filename
>    2865     252       8    3125     c35 drivers/power/supply/axp20x_usb_power.o
> 
> after:
>    text    data     bss     dec     hex filename
>    2822     252       0    3074     c02 drivers/power/supply/axp20x_usb_power.o

Thanks, queued.

-- Sebastian

> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>  drivers/power/supply/axp20x_usb_power.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c
> index 2397c48..44f70dc 100644
> --- a/drivers/power/supply/axp20x_usb_power.c
> +++ b/drivers/power/supply/axp20x_usb_power.c
> @@ -339,7 +339,7 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
>  		"VBUS_REMOVAL", "VBUS_VALID", "VBUS_NOT_VALID", NULL };
>  	static const char * const axp22x_irq_names[] = {
>  		"VBUS_PLUGIN", "VBUS_REMOVAL", NULL };
> -	static const char * const *irq_names;
> +	const char * const *irq_names;
>  	const struct power_supply_desc *usb_power_desc;
>  	int i, irq, ret;
>  
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Applied "regulator: palmas: Drop unnecessary static" to the regulator tree
  2017-05-04 20:10 ` [PATCH 6/9] regulator: palmas: " Julia Lawall
  2017-05-14 10:13   ` Mark Brown
@ 2017-05-23 11:24   ` Mark Brown
  1 sibling, 0 replies; 28+ messages in thread
From: Mark Brown @ 2017-05-23 11:24 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Mark Brown, Tony Lindgren, keescook, kernel-janitors,
	Liam Girdwood, Mark Brown, linux-omap, linux-kernel,
	linux-kernel

The patch

   regulator: palmas: Drop unnecessary static

has been applied to the regulator tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 96e4f5232c8cdb64cb18721ea0871c849346cbf5 Mon Sep 17 00:00:00 2001
From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Thu, 4 May 2017 22:10:51 +0200
Subject: [PATCH] regulator: palmas: Drop unnecessary static

Drop static on a local variable, when the variable is initialized before
any use, on every possible execution path through the function.

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>

There is no reduction in code size in this case, but the change does reduce
the size of the bss segment, containing uninitialized static data.

before:
   text    data     bss     dec     hex filename
  12882    3480       8   16370    3ff2 drivers/regulator/palmas-regulator.o

after:
   text    data     bss     dec     hex filename
  12882    3480       0   16362    3fea drivers/regulator/palmas-regulator.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/palmas-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 31ae5ee3a80d..34d4a62283d7 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -1491,7 +1491,7 @@ static int palmas_dt_to_pdata(struct device *dev,
 	}
 
 	for (idx = 0; idx < ddata->max_reg; idx++) {
-		static struct of_regulator_match *match;
+		struct of_regulator_match *match;
 		struct palmas_reg_init *rinit;
 		struct device_node *np;
 
-- 
2.11.0

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

* Re: [PATCH 8/9] clocksource/drivers/fttmr010: Drop unnecessary static
  2017-05-04 20:10 ` [PATCH 8/9] clocksource/drivers/fttmr010: " Julia Lawall
@ 2017-06-27 23:45   ` Kees Cook
  0 siblings, 0 replies; 28+ messages in thread
From: Kees Cook @ 2017-06-27 23:45 UTC (permalink / raw)
  To: kernel-janitors, Andrew Morton
  Cc: Daniel Lezcano, Julia Lawall, Thomas Gleixner, LKML

On Thu, May 4, 2017 at 1:10 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> Drop static on a local variable, when the variable is initialized before
> any 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
>    1777    4352      20    6149    1805 drivers/clocksource/timer-fttmr010.o
>
> after:
>    text    data     bss     dec     hex filename
>    1770    4352      12    6134    17f6 drivers/clocksource/timer-fttmr010.o
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>  drivers/clocksource/timer-fttmr010.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c
> index b4a6f1e..055c65e 100644
> --- a/drivers/clocksource/timer-fttmr010.c
> +++ b/drivers/clocksource/timer-fttmr010.c
> @@ -263,7 +263,7 @@ static int __init fttmr010_timer_of_init(struct device_node *np)
>
>  static int __init gemini_timer_of_init(struct device_node *np)
>  {
> -       static struct regmap *map;
> +       struct regmap *map;
>         int ret;
>         u32 val;
>
>

Acked-by: Kees Cook <keescook@chromium.org>

Kernel janitors or Andrew, can you pick this up?

Thanks!

-Kees

-- 
Kees Cook
Pixel Security

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

* Re: [PATCH 5/9] mfd: Drop unnecessary static
  2017-05-04 20:10 ` [PATCH 5/9] mfd: " Julia Lawall
@ 2017-06-27 23:46   ` Kees Cook
  2017-07-03 11:42     ` Lee Jones
  2017-07-17 11:01   ` Lee Jones
  1 sibling, 1 reply; 28+ messages in thread
From: Kees Cook @ 2017-06-27 23:46 UTC (permalink / raw)
  To: kernel-janitors, Andrew Morton
  Cc: Tony Lindgren, Julia Lawall, Lee Jones, linux-omap, LKML

On Thu, May 4, 2017 at 1:10 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> Drop static on a local variable, when the variable is initialized before
> any use, on every possible execution path through the function.
>
> 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 increases the code size but decreases the size of the bss segment.
>
> before:
>    text    data     bss     dec     hex filename
>    3369     272     300    3941     f65 drivers/mfd/twl4030-irq.o
>
> after:
>    text    data     bss     dec     hex filename
>    3401     272      28    3701     e75 drivers/mfd/twl4030-irq.o
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>  drivers/mfd/twl4030-irq.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
> index b46c0cf..c775f27 100644
> --- a/drivers/mfd/twl4030-irq.c
> +++ b/drivers/mfd/twl4030-irq.c
> @@ -683,7 +683,7 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base)
>
>  int twl4030_init_irq(struct device *dev, int irq_num)
>  {
> -       static struct irq_chip  twl4030_irq_chip;
> +       struct irq_chip twl4030_irq_chip;
>         int                     status, i;
>         int                     irq_base, irq_end, nr_irqs;
>         struct                  device_node *node = dev->of_node;
>

Acked-by: Kees Cook <keescook@chromium.org>

Kernel janitors or Andrew, can you pick this up?

Thanks!

-- 
Kees Cook
Pixel Security

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

* Re: [PATCH 9/9] mfd: max8925-i2c: Drop unnecessary static
  2017-05-04 20:10 ` [PATCH 9/9] mfd: max8925-i2c: " Julia Lawall
@ 2017-06-27 23:47   ` Kees Cook
  2017-07-03 11:42     ` Lee Jones
  2017-07-17 11:00   ` Lee Jones
  1 sibling, 1 reply; 28+ messages in thread
From: Kees Cook @ 2017-06-27 23:47 UTC (permalink / raw)
  To: kernel-janitors, Andrew Morton; +Cc: Lee Jones, LKML, Julia Lawall

On Thu, May 4, 2017 at 1:10 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> Drop static on a local variable, when the variable is initialized before
> any 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
>    2579     240      16    2835     b13 drivers/mfd/max8925-i2c.o
>
> after:
>    text    data     bss     dec     hex filename
>    2531     240       8    2779     adb drivers/mfd/max8925-i2c.o
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>  drivers/mfd/max8925-i2c.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
> index 5c80aea..1006323 100644
> --- a/drivers/mfd/max8925-i2c.c
> +++ b/drivers/mfd/max8925-i2c.c
> @@ -151,7 +151,7 @@ static int max8925_probe(struct i2c_client *client,
>                                    const struct i2c_device_id *id)
>  {
>         struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
> -       static struct max8925_chip *chip;
> +       struct max8925_chip *chip;
>         struct device_node *node = client->dev.of_node;
>
>         if (node && !pdata) {
>

Acked-by: Kees Cook <keescook@chromium.org>

Kernel janitors or Andrew, can you pick this up?

Thanks!

-Kees

-- 
Kees Cook
Pixel Security

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

* Re: [PATCH 0/9] Drop unnecessary static
  2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
                   ` (8 preceding siblings ...)
  2017-05-04 20:10 ` [PATCH 9/9] mfd: max8925-i2c: " Julia Lawall
@ 2017-06-27 23:47 ` Kees Cook
  9 siblings, 0 replies; 28+ messages in thread
From: Kees Cook @ 2017-06-27 23:47 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Linux PM list, kernel-janitors, Linux mtd, LKML, drbd-dev,
	linux-omap, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, linux-input, linux-iio

On Thu, May 4, 2017 at 1:10 PM, Julia Lawall <Julia.Lawall@lip6.fr> 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

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

* Re: [PATCH 3/9] drbd: Drop unnecessary static
  2017-05-05  7:19   ` Roland Kammerer
@ 2017-06-27 23:49     ` Kees Cook
  2017-06-27 23:58       ` Jens Axboe
  0 siblings, 1 reply; 28+ messages in thread
From: Kees Cook @ 2017-06-27 23:49 UTC (permalink / raw)
  To: Roland Kammerer, Jens Axboe
  Cc: Julia Lawall, Philipp Reisner, kernel-janitors, Lars Ellenberg,
	drbd-dev, LKML

On Fri, May 5, 2017 at 12:19 AM, Roland Kammerer
<roland.kammerer@linbit.com> wrote:
> On Thu, May 04, 2017 at 10:10:48PM +0200, Julia Lawall wrote:
>> Drop static on a local variable, when the variable is initialized before
>> any 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
>>   67299    2291    1056   70646   113f6 drivers/block/drbd/drbd_nl.o
>>
>> after:
>>    text    data     bss     dec     hex filename
>>   67283    2291    1056   70630   113e6 drivers/block/drbd/drbd_nl.o
>>
>> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>>
>> ---
>>  drivers/block/drbd/drbd_nl.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
>> index 02255a0..ad0fcb4 100644
>> --- a/drivers/block/drbd/drbd_nl.c
>> +++ b/drivers/block/drbd/drbd_nl.c
>> @@ -2294,7 +2294,7 @@ static bool conn_ov_running(struct drbd_connection *connection)
>>  static enum drbd_ret_code
>>  check_net_options(struct drbd_connection *connection, struct net_conf *new_net_conf)
>>  {
>> -     static enum drbd_ret_code rv;
>> +     enum drbd_ret_code rv;
>>       struct drbd_peer_device *peer_device;
>>       int i;
>
> Yes, that already got dropped for drbd9 and is obviously correct for
> in-tree drbd8.
>
> Signed-off-by: Roland Kammerer <roland.kammerer@linbit.com>
>
> Regards, rck

Which tree should this go through? Jens, I think yours?

Thanks!

-Kees

-- 
Kees Cook
Pixel Security

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

* Re: [PATCH 3/9] drbd: Drop unnecessary static
  2017-06-27 23:49     ` Kees Cook
@ 2017-06-27 23:58       ` Jens Axboe
  0 siblings, 0 replies; 28+ messages in thread
From: Jens Axboe @ 2017-06-27 23:58 UTC (permalink / raw)
  To: Kees Cook, Roland Kammerer
  Cc: Julia Lawall, Philipp Reisner, kernel-janitors, Lars Ellenberg,
	drbd-dev, LKML

On 06/27/2017 05:49 PM, Kees Cook wrote:
> On Fri, May 5, 2017 at 12:19 AM, Roland Kammerer
> <roland.kammerer@linbit.com> wrote:
>> On Thu, May 04, 2017 at 10:10:48PM +0200, Julia Lawall wrote:
>>> Drop static on a local variable, when the variable is initialized before
>>> any 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
>>>   67299    2291    1056   70646   113f6 drivers/block/drbd/drbd_nl.o
>>>
>>> after:
>>>    text    data     bss     dec     hex filename
>>>   67283    2291    1056   70630   113e6 drivers/block/drbd/drbd_nl.o
>>>
>>> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>>>
>>> ---
>>>  drivers/block/drbd/drbd_nl.c |    2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
>>> index 02255a0..ad0fcb4 100644
>>> --- a/drivers/block/drbd/drbd_nl.c
>>> +++ b/drivers/block/drbd/drbd_nl.c
>>> @@ -2294,7 +2294,7 @@ static bool conn_ov_running(struct drbd_connection *connection)
>>>  static enum drbd_ret_code
>>>  check_net_options(struct drbd_connection *connection, struct net_conf *new_net_conf)
>>>  {
>>> -     static enum drbd_ret_code rv;
>>> +     enum drbd_ret_code rv;
>>>       struct drbd_peer_device *peer_device;
>>>       int i;
>>
>> Yes, that already got dropped for drbd9 and is obviously correct for
>> in-tree drbd8.
>>
>> Signed-off-by: Roland Kammerer <roland.kammerer@linbit.com>
>>
>> Regards, rck
> 
> Which tree should this go through? Jens, I think yours?

Yes, I'll queue it up for 4.13. Thanks Julia.

-- 
Jens Axboe

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

* Re: [PATCH 9/9] mfd: max8925-i2c: Drop unnecessary static
  2017-06-27 23:47   ` Kees Cook
@ 2017-07-03 11:42     ` Lee Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2017-07-03 11:42 UTC (permalink / raw)
  To: Kees Cook; +Cc: kernel-janitors, Andrew Morton, LKML, Julia Lawall

On Tue, 27 Jun 2017, Kees Cook wrote:

> On Thu, May 4, 2017 at 1:10 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> > Drop static on a local variable, when the variable is initialized before
> > any 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
> >    2579     240      16    2835     b13 drivers/mfd/max8925-i2c.o
> >
> > after:
> >    text    data     bss     dec     hex filename
> >    2531     240       8    2779     adb drivers/mfd/max8925-i2c.o
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> >
> > ---
> >  drivers/mfd/max8925-i2c.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
> > index 5c80aea..1006323 100644
> > --- a/drivers/mfd/max8925-i2c.c
> > +++ b/drivers/mfd/max8925-i2c.c
> > @@ -151,7 +151,7 @@ static int max8925_probe(struct i2c_client *client,
> >                                    const struct i2c_device_id *id)
> >  {
> >         struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
> > -       static struct max8925_chip *chip;
> > +       struct max8925_chip *chip;
> >         struct device_node *node = client->dev.of_node;
> >
> >         if (node && !pdata) {
> >
> 
> Acked-by: Kees Cook <keescook@chromium.org>
> 
> Kernel janitors or Andrew, can you pick this up?

Didn't see this before.

Thanks for the poke Kees, I will pick this up in due course.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 5/9] mfd: Drop unnecessary static
  2017-06-27 23:46   ` Kees Cook
@ 2017-07-03 11:42     ` Lee Jones
  0 siblings, 0 replies; 28+ messages in thread
From: Lee Jones @ 2017-07-03 11:42 UTC (permalink / raw)
  To: Kees Cook
  Cc: kernel-janitors, Andrew Morton, Tony Lindgren, Julia Lawall,
	linux-omap, LKML

On Tue, 27 Jun 2017, Kees Cook wrote:

> On Thu, May 4, 2017 at 1:10 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> > Drop static on a local variable, when the variable is initialized before
> > any use, on every possible execution path through the function.
> >
> > 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 increases the code size but decreases the size of the bss segment.
> >
> > before:
> >    text    data     bss     dec     hex filename
> >    3369     272     300    3941     f65 drivers/mfd/twl4030-irq.o
> >
> > after:
> >    text    data     bss     dec     hex filename
> >    3401     272      28    3701     e75 drivers/mfd/twl4030-irq.o
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> >
> > ---
> >  drivers/mfd/twl4030-irq.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
> > index b46c0cf..c775f27 100644
> > --- a/drivers/mfd/twl4030-irq.c
> > +++ b/drivers/mfd/twl4030-irq.c
> > @@ -683,7 +683,7 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base)
> >
> >  int twl4030_init_irq(struct device *dev, int irq_num)
> >  {
> > -       static struct irq_chip  twl4030_irq_chip;
> > +       struct irq_chip twl4030_irq_chip;
> >         int                     status, i;
> >         int                     irq_base, irq_end, nr_irqs;
> >         struct                  device_node *node = dev->of_node;
> >
> 
> Acked-by: Kees Cook <keescook@chromium.org>
> 
> Kernel janitors or Andrew, can you pick this up?

Same.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 9/9] mfd: max8925-i2c: Drop unnecessary static
  2017-05-04 20:10 ` [PATCH 9/9] mfd: max8925-i2c: " Julia Lawall
  2017-06-27 23:47   ` Kees Cook
@ 2017-07-17 11:00   ` Lee Jones
  1 sibling, 0 replies; 28+ messages in thread
From: Lee Jones @ 2017-07-17 11:00 UTC (permalink / raw)
  To: Julia Lawall; +Cc: keescook, kernel-janitors, linux-kernel

On Thu, 04 May 2017, Julia Lawall wrote:

> Drop static on a local variable, when the variable is initialized before
> any 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
>    2579     240      16    2835     b13 drivers/mfd/max8925-i2c.o
> 
> after:
>    text    data     bss     dec     hex filename
>    2531     240       8    2779     adb drivers/mfd/max8925-i2c.o
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>  drivers/mfd/max8925-i2c.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

> diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
> index 5c80aea..1006323 100644
> --- a/drivers/mfd/max8925-i2c.c
> +++ b/drivers/mfd/max8925-i2c.c
> @@ -151,7 +151,7 @@ static int max8925_probe(struct i2c_client *client,
>  				   const struct i2c_device_id *id)
>  {
>  	struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
> -	static struct max8925_chip *chip;
> +	struct max8925_chip *chip;
>  	struct device_node *node = client->dev.of_node;
>  
>  	if (node && !pdata) {
> 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 5/9] mfd: Drop unnecessary static
  2017-05-04 20:10 ` [PATCH 5/9] mfd: " Julia Lawall
  2017-06-27 23:46   ` Kees Cook
@ 2017-07-17 11:01   ` Lee Jones
  1 sibling, 0 replies; 28+ messages in thread
From: Lee Jones @ 2017-07-17 11:01 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Tony Lindgren, keescook, kernel-janitors, linux-omap, linux-kernel

On Thu, 04 May 2017, Julia Lawall wrote:

> Drop static on a local variable, when the variable is initialized before
> any use, on every possible execution path through the function.
> 
> 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 increases the code size but decreases the size of the bss segment.
> 
> before:
>    text    data     bss     dec     hex filename
>    3369     272     300    3941     f65 drivers/mfd/twl4030-irq.o
> 
> after:
>    text    data     bss     dec     hex filename
>    3401     272      28    3701     e75 drivers/mfd/twl4030-irq.o
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>  drivers/mfd/twl4030-irq.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

end of thread, other threads:[~2017-07-17 11:01 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
2017-05-04 20:10 ` [PATCH 1/9] mtd: cfi_cmdset_0020: " Julia Lawall
2017-05-11 18:49   ` Brian Norris
2017-05-04 20:10 ` [PATCH 2/9] mtd: physmap_of: " Julia Lawall
2017-05-04 20:10 ` [PATCH 3/9] drbd: " Julia Lawall
2017-05-05  7:19   ` Roland Kammerer
2017-06-27 23:49     ` Kees Cook
2017-06-27 23:58       ` Jens Axboe
2017-05-04 20:10 ` [PATCH 4/9] power: supply: axp20x_usb_power: " Julia Lawall
2017-05-15 13:25   ` Sebastian Reichel
2017-05-04 20:10 ` [PATCH 5/9] mfd: " Julia Lawall
2017-06-27 23:46   ` Kees Cook
2017-07-03 11:42     ` Lee Jones
2017-07-17 11:01   ` Lee Jones
2017-05-04 20:10 ` [PATCH 6/9] regulator: palmas: " Julia Lawall
2017-05-14 10:13   ` Mark Brown
2017-05-15 10:41     ` Julia Lawall
2017-05-15 10:54       ` Mark Brown
2017-05-23 11:24   ` Applied "regulator: palmas: Drop unnecessary static" to the regulator tree Mark Brown
2017-05-04 20:10 ` [PATCH 7/9] iio: hid-sensor-accel-3d: Drop unnecessary static Julia Lawall
2017-05-07 12:57   ` Jonathan Cameron
2017-05-04 20:10 ` [PATCH 8/9] clocksource/drivers/fttmr010: " Julia Lawall
2017-06-27 23:45   ` Kees Cook
2017-05-04 20:10 ` [PATCH 9/9] mfd: max8925-i2c: " Julia Lawall
2017-06-27 23:47   ` Kees Cook
2017-07-03 11:42     ` Lee Jones
2017-07-17 11:00   ` Lee Jones
2017-06-27 23:47 ` [PATCH 0/9] " Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).