* [PATCH 0/9] Drop unnecessary static
@ 2017-05-04 20:10 Julia Lawall
2017-05-04 20:10 ` [PATCH 4/9] power: supply: axp20x_usb_power: " Julia Lawall
2017-06-27 23:47 ` [PATCH 0/9] " Kees Cook
0 siblings, 2 replies; 4+ 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] 4+ 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
@ 2017-05-04 20:10 ` Julia Lawall
2017-05-15 13:25 ` Sebastian Reichel
2017-06-27 23:47 ` [PATCH 0/9] " Kees Cook
1 sibling, 1 reply; 4+ 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] 4+ 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; 4+ 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] 4+ 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 4/9] power: supply: axp20x_usb_power: " Julia Lawall
@ 2017-06-27 23:47 ` Kees Cook
1 sibling, 0 replies; 4+ 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] 4+ messages in thread
end of thread, other threads:[~2017-06-27 23:47 UTC | newest]
Thread overview: 4+ 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 4/9] power: supply: axp20x_usb_power: " Julia Lawall
2017-05-15 13:25 ` Sebastian Reichel
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