Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1636031 > unrolled thread
| Started by | Julia Lawall <Julia.Lawall@lip6.fr> |
|---|---|
| First post | 2017-05-04 22:40 +0200 |
| Last post | 2017-05-05 09:20 +0200 |
| Articles | 8 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 0/9] Drop unnecessary static Julia Lawall <Julia.Lawall@lip6.fr> - 2017-05-04 22:40 +0200
[PATCH 2/9] mtd: physmap_of: Drop unnecessary static Julia Lawall <Julia.Lawall@lip6.fr> - 2017-05-04 22:40 +0200
[PATCH 5/9] mfd: Drop unnecessary static Julia Lawall <Julia.Lawall@lip6.fr> - 2017-05-04 22:40 +0200
[PATCH 9/9] mfd: max8925-i2c: Drop unnecessary static Julia Lawall <Julia.Lawall@lip6.fr> - 2017-05-04 22:40 +0200
[PATCH 1/9] mtd: cfi_cmdset_0020: Drop unnecessary static Julia Lawall <Julia.Lawall@lip6.fr> - 2017-05-04 22:40 +0200
Re: [PATCH 1/9] mtd: cfi_cmdset_0020: Drop unnecessary static Brian Norris <computersforpeace@gmail.com> - 2017-05-11 21:00 +0200
[PATCH 3/9] drbd: Drop unnecessary static Julia Lawall <Julia.Lawall@lip6.fr> - 2017-05-04 22:40 +0200
Re: [PATCH 3/9] drbd: Drop unnecessary static Roland Kammerer <roland.kammerer@linbit.com> - 2017-05-05 09:20 +0200
| From | Julia Lawall <Julia.Lawall@lip6.fr> |
|---|---|
| Date | 2017-05-04 22:40 +0200 |
| Subject | [PATCH 0/9] Drop unnecessary static |
| Message-ID | <tDvHz-8tt-5@gated-at.bofh.it> |
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(-)
[toc] | [next] | [standalone]
| From | Julia Lawall <Julia.Lawall@lip6.fr> |
|---|---|
| Date | 2017-05-04 22:40 +0200 |
| Subject | [PATCH 2/9] mtd: physmap_of: Drop unnecessary static |
| Message-ID | <tDvHA-8tt-35@gated-at.bofh.it> |
| In reply to | #1636031 |
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;
[toc] | [prev] | [next] | [standalone]
| From | Julia Lawall <Julia.Lawall@lip6.fr> |
|---|---|
| Date | 2017-05-04 22:40 +0200 |
| Subject | [PATCH 5/9] mfd: Drop unnecessary static |
| Message-ID | <tDvHB-8tt-45@gated-at.bofh.it> |
| In reply to | #1636031 |
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;
[toc] | [prev] | [next] | [standalone]
| From | Julia Lawall <Julia.Lawall@lip6.fr> |
|---|---|
| Date | 2017-05-04 22:40 +0200 |
| Subject | [PATCH 9/9] mfd: max8925-i2c: Drop unnecessary static |
| Message-ID | <tDvHB-8tt-47@gated-at.bofh.it> |
| In reply to | #1636031 |
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) {
[toc] | [prev] | [next] | [standalone]
| From | Julia Lawall <Julia.Lawall@lip6.fr> |
|---|---|
| Date | 2017-05-04 22:40 +0200 |
| Subject | [PATCH 1/9] mtd: cfi_cmdset_0020: Drop unnecessary static |
| Message-ID | <tDvHB-8tt-49@gated-at.bofh.it> |
| In reply to | #1636031 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Brian Norris <computersforpeace@gmail.com> |
|---|---|
| Date | 2017-05-11 21:00 +0200 |
| Subject | Re: [PATCH 1/9] mtd: cfi_cmdset_0020: Drop unnecessary static |
| Message-ID | <tG1tE-1Bw-17@gated-at.bofh.it> |
| In reply to | #1636037 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Julia Lawall <Julia.Lawall@lip6.fr> |
|---|---|
| Date | 2017-05-04 22:40 +0200 |
| Subject | [PATCH 3/9] drbd: Drop unnecessary static |
| Message-ID | <tDvHA-8tt-43@gated-at.bofh.it> |
| In reply to | #1636031 |
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;
[toc] | [prev] | [next] | [standalone]
| From | Roland Kammerer <roland.kammerer@linbit.com> |
|---|---|
| Date | 2017-05-05 09:20 +0200 |
| Subject | Re: [PATCH 3/9] drbd: Drop unnecessary static |
| Message-ID | <tDFGW-6Yr-7@gated-at.bofh.it> |
| In reply to | #1636040 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web