* [PATCH 0/9] Drop unnecessary static
@ 2017-05-04 20:10 Julia Lawall
2017-05-04 20:10 ` [PATCH 5/9] mfd: " Julia Lawall
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Julia Lawall @ 2017-05-04 20:10 UTC (permalink / raw)
To: linux-pm
Cc: Lars-Peter Clausen, keescook, linux-iio, linux-input,
kernel-janitors, linux-kernel, linux-mtd, Peter Meerwald-Stadler,
Hartmut Knaack, linux-omap, drbd-dev
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/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 5/9] mfd: Drop unnecessary static
2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static 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
2017-06-27 23:47 ` [PATCH 0/9] Drop unnecessary static Kees Cook
2 siblings, 2 replies; 11+ 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] 11+ messages in thread
* [PATCH 6/9] regulator: palmas: Drop unnecessary static
2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
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-06-27 23:47 ` [PATCH 0/9] Drop unnecessary static Kees Cook
2 siblings, 2 replies; 11+ 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] 11+ 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; 11+ 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] 11+ 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; 11+ 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] 11+ 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; 11+ 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] 11+ 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; 11+ 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
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] 11+ 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; 11+ 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] 11+ messages in thread
* Re: [PATCH 0/9] Drop unnecessary static
2017-05-04 20:10 [PATCH 0/9] Drop unnecessary static Julia Lawall
2017-05-04 20:10 ` [PATCH 5/9] mfd: " Julia Lawall
2017-05-04 20:10 ` [PATCH 6/9] regulator: palmas: " Julia Lawall
@ 2017-06-27 23:47 ` Kees Cook
2 siblings, 0 replies; 11+ 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] 11+ 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; 11+ 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] 11+ 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; 11+ 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] 11+ messages in thread
end of thread, other threads:[~2017-07-17 11:01 UTC | newest]
Thread overview: 11+ 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 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-06-27 23:47 ` [PATCH 0/9] Drop unnecessary static Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox