Skip to contentSkip to conversation

Drop unnecessary static

PATCH Applied Julia Lawall 14 participants 35 messages Jul 15, 2017 – Aug 17, 2017

Subsystems (16)
lore
Share & tools
lore
#0 lore raw

cover Drop unnecessary static

These patches fix cases where there is a static on a local variable, but the variable is initialized before any possible use. Thus, the static has no benefit.

---

 drivers/ata/sata_gemini.c                     |    2 +-
 drivers/clk/clk-moxart.c                      |    4 ++--
 drivers/clk/mmp/clk.c                         |    2 +-
 drivers/iio/orientation/hid-sensor-rotation.c |    2 +-
 drivers/irqchip/irq-digicolor.c               |    2 +-
 drivers/irqchip/irq-gic-realview.c            |    2 +-
 drivers/irqchip/irq-mips-cpu.c                |    2 +-
 drivers/mfd/max8925-i2c.c                     |    2 +-
 drivers/mfd/twl4030-irq.c                     |    2 +-
 drivers/mtd/maps/physmap_of_versatile.c       |    2 +-
 drivers/video/fbdev/da8xx-fb.c                |    2 +-
 11 files changed, 12 insertions(+), 12 deletions(-)
#1 lore raw

PATCH 1/11 clk: mmp: Drop unnecessary static

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
These patches are all independent of each other.

 drivers/clk/mmp/clk.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/mmp/clk.c +1 -1
diff -u -p a/drivers/clk/mmp/clk.c b/drivers/clk/mmp/clk.c
@@ -9,7 +9,7 @@
 void mmp_clk_init(struct device_node *np, struct mmp_clk_unit *unit,
 		int nr_clks)
 {
-	static struct clk **clk_table;
+	struct clk **clk_table;
 
 	clk_table = kcalloc(nr_clks, sizeof(struct clk *), GFP_KERNEL);
 	if (!clk_table)
Applied
#2 lore raw

Re: [PATCH 01/11] clk: mmp: Drop unnecessary static

Quoted 29 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

Quoted 3 lines

---

Applied to clk-next

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#3 lore raw

PATCH 2/11 clk: moxart: Drop unnecessary static

In reply to Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
These patches are all independent of each other.

 drivers/clk/clk-moxart.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/clk-moxart.c +2 -2
diff -u -p a/drivers/clk/clk-moxart.c b/drivers/clk/clk-moxart.c
@@ -18,7 +18,7 @@
 
 static void __init moxart_of_pll_clk_init(struct device_node *node)
 {
-	static void __iomem *base;
+	void __iomem *base;
 	struct clk_hw *hw;
 	struct clk *ref_clk;
 	unsigned int mul;
@@ -57,7 +57,7 @@ CLK_OF_DECLARE(moxart_pll_clock, "moxa,m
 
 static void __init moxart_of_apb_clk_init(struct device_node *node)
 {
-	static void __iomem *base;
+	void __iomem *base;
 	struct clk_hw *hw;
 	struct clk *pll_clk;
 	unsigned int div, val;
#4 lore raw

Re: [PATCH 02/11] clk: moxart: Drop unnecessary static

Quoted 29 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

Quoted 4 lines

---
These patches are all independent of each other.

Already got this one a few days earlier.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#5 lore raw

PATCH 3/11 mtd: physmap_of: Drop unnecessary static

In reply to Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
These patches are all independent of each other.

 drivers/mtd/maps/physmap_of_versatile.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/maps/physmap_of_versatile.c +1 -1
diff -u -p a/drivers/mtd/maps/physmap_of_versatile.c b/drivers/mtd/maps/physmap_of_versatile.c
@@ -97,7 +97,7 @@ static const struct of_device_id ebi_mat
 static int ap_flash_init(struct platform_device *pdev)
 {
 	struct device_node *ebi;
-	static void __iomem *ebi_base;
+	void __iomem *ebi_base;
 	u32 val;
 	int ret;
 
Acked-by on v1 3/11
#6 lore raw

Re: [PATCH 03/11] mtd: physmap_of: Drop unnecessary static

Le Sat, 15 Jul 2017 22:07:38 +0200,
Julia Lawall <[email protected]> a écrit :

Quoted 29 lines

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

Quoted 1 line
Quoted 12 lines

---
These patches are all independent of each other.

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

diff -u -p a/drivers/mtd/maps/physmap_of_versatile.c b/drivers/mtd/maps/physmap_of_versatile.c

drivers/mtd/maps/physmap_of_versatile.c static const struct of_device_id ebi_mat · line 103

Quoted 8 lines
drivers/mtd/maps/physmap_of_versatile.c +1 -1
@@ -97,7 +97,7 @@ static const struct of_device_id ebi_mat
 static int ap_flash_init(struct platform_device *pdev)
 {
 	struct device_node *ebi;
-	static void __iomem *ebi_base;
+	void __iomem *ebi_base;
 	u32 val;
 	int ret;
 

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

Re: [PATCH 03/11] mtd: physmap_of: Drop unnecessary static

In reply to Julia Lawall

Le Sat, 15 Jul 2017 22:07:38 +0200,
Julia Lawall <[email protected]> a écrit :

Quoted 16 lines

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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...+>

Quoted 13 lines

@@
identifier x;
expression e;
type T;
position p != bad.p;
@@
-static
T x@p;
... when != x
when strict
?x = e;
// </smpl>

Applied to l2-mtd/master.

Thanks,

Boris

Quoted 13 lines

---
These patches are all independent of each other.

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

diff -u -p a/drivers/mtd/maps/physmap_of_versatile.c b/drivers/mtd/maps/physmap_of_versatile.c

drivers/mtd/maps/physmap_of_versatile.c static const struct of_device_id ebi_mat · line 103

Quoted 8 lines
drivers/mtd/maps/physmap_of_versatile.c +1 -1
@@ -97,7 +97,7 @@ static const struct of_device_id ebi_mat
 static int ap_flash_init(struct platform_device *pdev)
 {
 	struct device_node *ebi;
-	static void __iomem *ebi_base;
+	void __iomem *ebi_base;
 	u32 val;
 	int ret;
 

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

PATCH 4/11 fbdev: da8xx-fb: Drop unnecessary static

In reply to Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
These patches are all independent of each other.

 drivers/video/fbdev/da8xx-fb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/da8xx-fb.c +1 -1
diff -u -p a/drivers/video/fbdev/da8xx-fb.c b/drivers/video/fbdev/da8xx-fb.c
@@ -1341,7 +1341,7 @@ static int fb_probe(struct platform_devi
 {
 	struct da8xx_lcdc_platform_data *fb_pdata  						dev_get_platdata(&device->dev);
-	static struct resource *lcdc_regs;
+	struct resource *lcdc_regs;
 	struct lcd_ctrl_config *lcd_cfg;
 	struct fb_videomode *lcdc_info;
 	struct fb_info *da8xx_fb_info;
 
#9 lore raw

Re: [PATCH 04/11] fbdev: da8xx-fb: Drop unnecessary static

Quoted 29 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

Quoted 1 line

Patch queued for 4.14, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

#10 lore raw

PATCH 5/11 irqchip/gic/realview: Drop unnecessary static

In reply to Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
These patches are all independent of each other.

 drivers/irqchip/irq-gic-realview.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-realview.c +1 -1
diff -u -p a/drivers/irqchip/irq-gic-realview.c b/drivers/irqchip/irq-gic-realview.c
@@ -43,7 +43,7 @@ static const struct of_device_id syscon_
 static int __init
 realview_gic_of_init(struct device_node *node, struct device_node *parent)
 {
-	static struct regmap *map;
+	struct regmap *map;
 	struct device_node *np;
 	const struct of_device_id *gic_id;
 	u32 pld1_ctrl;
#11 lore raw

[tip:irq/urgent] irqchip/gic/realview: Drop unnecessary static

irqchip/gic/realview: Drop unnecessary static
Commit-ID:  512f9e790897e84d5b802436768508ee4628fc16
Gitweb:     http://git.kernel.org/tip/512f9e790897e84d5b802436768508ee4628fc16
Author:     Julia Lawall <[email protected]>
AuthorDate: Sat, 15 Jul 2017 22:07:40 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 18 Jul 2017 21:59:22 +0200

irqchip/gic/realview: Drop unnecessary static

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
 drivers/irqchip/irq-gic-realview.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-realview.c +1 -1
index 54c2964..18d58d2 100644
@@ -43,7 +43,7 @@ static const struct of_device_id syscon_pldset_of_match[] = {
 static int __init
 realview_gic_of_init(struct device_node *node, struct device_node *parent)
 {
-	static struct regmap *map;
+	struct regmap *map;
 	struct device_node *np;
 	const struct of_device_id *gic_id;
 	u32 pld1_ctrl;
#12 lore raw

PATCH 6/11 irqchip: mips-cpu: Drop unnecessary static

In reply to Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
These patches are all independent of each other.

 drivers/irqchip/irq-mips-cpu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-mips-cpu.c +1 -1
diff -u -p a/drivers/irqchip/irq-mips-cpu.c b/drivers/irqchip/irq-mips-cpu.c
@@ -154,7 +154,7 @@ asmlinkage void __weak plat_irq_dispatch
 static int mips_cpu_intc_map(struct irq_domain *d, unsigned int irq,
 			     irq_hw_number_t hw)
 {
-	static struct irq_chip *chip;
+	struct irq_chip *chip;
 
 	if (hw < 2 && cpu_has_mipsmt) {
 		/* Software interrupts are used for MT/CMT IPI */
#13 lore raw

Re: [PATCH 06/11] irqchip: mips-cpu: Drop unnecessary static

Quoted 5 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

I think this is in error like the other one. I believe that the irq_chip structure needs a persistent lifetime.

Quoted 39 lines

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>

---
These patches are all independent of each other.

drivers/irqchip/irq-mips-cpu.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/irqchip/irq-mips-cpu.c b/drivers/irqchip/irq-mips-cpu.c

drivers/irqchip/irq-mips-cpu.c asmlinkage void __weak plat_irq_dispatch · line 160

Quoted 8 lines
drivers/irqchip/irq-mips-cpu.c +1 -1
@@ -154,7 +154,7 @@ asmlinkage void __weak plat_irq_dispatch
 static int mips_cpu_intc_map(struct irq_domain *d, unsigned int irq,
 			     irq_hw_number_t hw)
 {
-	static struct irq_chip *chip;
+	struct irq_chip *chip;
 
 	if (hw < 2 && cpu_has_mipsmt) {
 		/* Software interrupts are used for MT/CMT IPI */

--
Mark Rustad, [email protected]

#14 lore raw

Re: [PATCH 06/11] irqchip: mips-cpu: Drop unnecessary static

Quoted 7 lines · Mark D Rustad
Quoted 5 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

I think this is in error like the other one. I believe that the irq_chip structure needs a persistent lifetime.

I'm not following in this case. chip is a pointer to a structure, not a structure. Its address is not taken. irq_set_chip_and_handler that uses it below is a fnuction, so it just gets the value.

julia

Quoted 53 lines
Quoted 40 lines

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>

---
These patches are all independent of each other.

drivers/irqchip/irq-mips-cpu.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/irqchip/irq-mips-cpu.c b/drivers/irqchip/irq-mips-cpu.c

drivers/irqchip/irq-mips-cpu.c asmlinkage void __weak plat_irq_dispatch · line 160

Quoted 8 lines
drivers/irqchip/irq-mips-cpu.c +1 -1
@@ -154,7 +154,7 @@ asmlinkage void __weak plat_irq_dispatch
 static int mips_cpu_intc_map(struct irq_domain *d, unsigned int irq,
 			     irq_hw_number_t hw)
 {
-	static struct irq_chip *chip;
+	struct irq_chip *chip;
 
 	if (hw < 2 && cpu_has_mipsmt) {
 		/* Software interrupts are used for MT/CMT IPI */

--
Mark Rustad, [email protected]

#15 lore raw

Re: [PATCH 06/11] irqchip: mips-cpu: Drop unnecessary static

Quoted 10 lines · Julia Lawall
Quoted 6 lines · Mark D Rustad
Quoted 5 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

Quoted 7 lines
Quoted 1 line

I think this is in error like the other one. I believe that the irq_chip structure needs a persistent lifetime.

I'm not following in this case. chip is a pointer to a structure, not a structure. Its address is not taken. irq_set_chip_and_handler that uses it below is a fnuction, so it just gets the value.

julia

Sorry. My mistake. I didn't look quite hard enough at this one.

Quoted 45 lines
Quoted 45 lines
Quoted 45 lines

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>

---
These patches are all independent of each other.

drivers/irqchip/irq-mips-cpu.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/irqchip/irq-mips-cpu.c b/drivers/irqchip/irq-mips-cpu.c

drivers/irqchip/irq-mips-cpu.c +1 -1
@@ -154,7 +154,7 @@ asmlinkage void __weak plat_irq_dispatch
 static int mips_cpu_intc_map(struct irq_domain *d, unsigned int irq,
 			     irq_hw_number_t hw)
 {
-	static struct irq_chip *chip;
+	struct irq_chip *chip;
 
Quoted 6 lines
Quoted 6 lines

drivers/irqchip/irq-mips-cpu.c asmlinkage void __weak plat_irq_dispatch · line 160

Quoted 3 lines
drivers/irqchip/irq-mips-cpu.c +0 -0
 	if (hw < 2 && cpu_has_mipsmt) {
 		/* Software interrupts are used for MT/CMT IPI */

--
Mark Rustad, [email protected]

--
Mark Rustad, [email protected]

#16 lore raw

[tip:irq/urgent] irqchip/mips-cpu: Drop unnecessary static

In reply to Julia Lawall
irqchip/mips-cpu: Drop unnecessary static
Commit-ID:  82faeffa7e130e2ae43aa681a34c02d56dabd177
Gitweb:     http://git.kernel.org/tip/82faeffa7e130e2ae43aa681a34c02d56dabd177
Author:     Julia Lawall <[email protected]>
AuthorDate: Sat, 15 Jul 2017 22:07:41 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 18 Jul 2017 21:59:22 +0200

irqchip/mips-cpu: Drop unnecessary static

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
 drivers/irqchip/irq-mips-cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-mips-cpu.c +1 -1
index 0a8ed1c..14461cb 100644
@@ -154,7 +154,7 @@ asmlinkage void __weak plat_irq_dispatch(void)
 static int mips_cpu_intc_map(struct irq_domain *d, unsigned int irq,
 			     irq_hw_number_t hw)
 {
-	static struct irq_chip *chip;
+	struct irq_chip *chip;
 
 	if (hw < 2 && cpu_has_mipsmt) {
 		/* Software interrupts are used for MT/CMT IPI */
#17 lore raw

PATCH 7/11 mfd: Drop unnecessary static

In reply to Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
These patches are all independent of each other.

 drivers/mfd/twl4030-irq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/twl4030-irq.c +1 -1
diff -u -p a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
@@ -685,7 +685,7 @@ int twl4030_sih_setup(struct device *dev
 
 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;
#18 lore raw

Re: [PATCH 07/11] mfd: Drop unnecessary static

Quoted 4 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

I think in this case the use relies on the structure continuing to exist, so a stack object is not an acceptable substitute. Just because it is initialized doesn't mean that it doesn't need a persistent lifetime.

Quoted 38 lines

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>

---
These patches are all independent of each other.

drivers/mfd/twl4030-irq.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c

drivers/mfd/twl4030-irq.c int twl4030_sih_setup(struct device *dev · line 691

Quoted 8 lines
drivers/mfd/twl4030-irq.c +1 -1
@@ -685,7 +685,7 @@ int twl4030_sih_setup(struct device *dev
 
 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;

--
Mark Rustad, [email protected]

#19 lore raw

Re: [PATCH 07/11] mfd: Drop unnecessary static

Quoted 6 lines · Mark D Rustad
Quoted 4 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

I think in this case the use relies on the structure continuing to exist, so a stack object is not an acceptable substitute. Just because it is initialized doesn't mean that it doesn't need a persistent lifetime.

OK, I see. Thanks for the feedback. I'll extend the rule to ensure that the address of the variable is not taken. Ignore this patch in any case.

julia

Quoted 52 lines
Quoted 39 lines

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>

---
These patches are all independent of each other.

drivers/mfd/twl4030-irq.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c

drivers/mfd/twl4030-irq.c int twl4030_sih_setup(struct device *dev · line 691

Quoted 8 lines
drivers/mfd/twl4030-irq.c +1 -1
@@ -685,7 +685,7 @@ int twl4030_sih_setup(struct device *dev
 
 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;

--
Mark Rustad, [email protected]

#20 lore raw

Re: [PATCH 07/11] mfd: Drop unnecessary static

Hi!

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

Actually... it has possible other benefit -- saving stack space. I've used static for that purpose before. So ... careful with the automation.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#21 lore raw

Re: [PATCH 07/11] mfd: Drop unnecessary static

Quoted 8 lines · Pavel Machek

Hi!

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

Actually... it has possible other benefit -- saving stack space. I've used static for that purpose before. So ... careful with the automation.

This means any functions like this must not be thread safe, though...

-Kees

Signature · 2 lines
Kees Cook
Pixel Security
#22 lore raw

Re: [PATCH 07/11] mfd: Drop unnecessary static

In reply to Julia Lawall
Quoted 29 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

Quoted 7 lines

---
These patches are all independent of each other.

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

Looks like I didn't reply to this patch.

Just to let you know, it has been applied.

Quoted 13 lines

diff -u -p a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c

drivers/mfd/twl4030-irq.c +1 -1
@@ -685,7 +685,7 @@ int twl4030_sih_setup(struct device *dev
 
 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;
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#23 lore raw

PATCH 8/11 ata: Drop unnecessary static

In reply to Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
These patches are all independent of each other.

 drivers/ata/sata_gemini.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/sata_gemini.c +1 -1
diff -u -p a/drivers/ata/sata_gemini.c b/drivers/ata/sata_gemini.c
@@ -305,7 +305,7 @@ static int gemini_sata_probe(struct plat
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
 	struct sata_gemini *sg;
-	static struct regmap *map;
+	struct regmap *map;
 	struct resource *res;
 	enum gemini_muxmode muxmode;
 	u32 gmode;
Acked-by on v1 8/11
#24 lore raw

Re: [PATCH 08/11] ata: Drop unnecessary static

Quoted 29 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

Quoted 1 line

Yours,
Linus Walleij

Applied
#25 lore raw

Re: [PATCH 08/11] ata: Drop unnecessary static

In reply to Julia Lawall
Quoted 29 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

Quoted 1 line

Applied to libata/for-4.14.

Thanks.

Signature · 1 line
tejun
#26 lore raw

PATCH 9/11 iio: orientation: hid-sensor-rotation: Drop unnecessary static

In reply to Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
These patches are all independent of each other.

 drivers/iio/orientation/hid-sensor-rotation.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/orientation/hid-sensor-rotation.c +1 -1
diff -u -p a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
@@ -238,7 +238,7 @@ static int dev_rot_parse_report(struct p
 static int hid_dev_rot_probe(struct platform_device *pdev)
 {
 	int ret;
-	static char *name;
+	char *name;
 	struct iio_dev *indio_dev;
 	struct dev_rot_state *rot_state;
 	struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
maintainer Applied
#27 lore raw

Re: [PATCH 09/11] iio: orientation: hid-sensor-rotation: Drop unnecessary static

Quoted 29 lines · On Sat, 15 Jul 2017 22:07:44 +0200 Julia Lawall <[email protected]> wrote:

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

Quoted 1 line

Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan

Quoted 20 lines

---
These patches are all independent of each other.

 drivers/iio/orientation/hid-sensor-rotation.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c

drivers/iio/orientation/hid-sensor-rotation.c +1 -1
@@ -238,7 +238,7 @@ static int dev_rot_parse_report(struct p
 static int hid_dev_rot_probe(struct platform_device *pdev)
 {
 	int ret;
-	static char *name;
+	char *name;
 	struct iio_dev *indio_dev;
 	struct dev_rot_state *rot_state;
 	struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
#28 lore raw

PATCH 10/11 irqchip: digicolor: Drop unnecessary static

In reply to Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
These patches are all independent of each other.

 drivers/irqchip/irq-digicolor.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-digicolor.c +1 -1
diff -u -p a/drivers/irqchip/irq-digicolor.c b/drivers/irqchip/irq-digicolor.c
@@ -71,7 +71,7 @@ static void __init digicolor_set_gc(void
 static int __init digicolor_of_init(struct device_node *node,
 				struct device_node *parent)
 {
-	static void __iomem *reg_base;
+	void __iomem *reg_base;
 	unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN;
 	struct regmap *ucregs;
 	int ret;
maintainer Acked-by on v1 10/11
#29 lore raw

Re: [PATCH 10/11] irqchip: digicolor: Drop unnecessary static

Hi Julia,

Quoted 29 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

Quoted 1 line

Thanks,
baruch

Quoted 19 lines

---
These patches are all independent of each other.

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

diff -u -p a/drivers/irqchip/irq-digicolor.c b/drivers/irqchip/irq-digicolor.c

drivers/irqchip/irq-digicolor.c +1 -1
@@ -71,7 +71,7 @@ static void __init digicolor_set_gc(void
 static int __init digicolor_of_init(struct device_node *node,
 				struct device_node *parent)
 {
-	static void __iomem *reg_base;
+	void __iomem *reg_base;
 	unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN;
 	struct regmap *ucregs;
 	int ret;
Signature · 2 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{   - [email protected] - tel: +972.52.368.4656, http://www.tkos.co.il -
#30 lore raw

[tip:irq/urgent] irqchip/digicolor: Drop unnecessary static

In reply to Julia Lawall
irqchip/digicolor: Drop unnecessary static
Commit-ID:  acc80c39929b9f2ff8b45fcfe103385a3e45c1a7
Gitweb:     http://git.kernel.org/tip/acc80c39929b9f2ff8b45fcfe103385a3e45c1a7
Author:     Julia Lawall <[email protected]>
AuthorDate: Sat, 15 Jul 2017 22:07:45 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 18 Jul 2017 21:59:23 +0200

irqchip/digicolor: Drop unnecessary static

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
 drivers/irqchip/irq-digicolor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-digicolor.c +1 -1
index dad85e7..3aae015 100644
@@ -71,7 +71,7 @@ static void __init digicolor_set_gc(void __iomem *reg_base, unsigned irq_base,
 static int __init digicolor_of_init(struct device_node *node,
 				struct device_node *parent)
 {
-	static void __iomem *reg_base;
+	void __iomem *reg_base;
 	unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN;
 	struct regmap *ucregs;
 	int ret;
#31 lore raw

PATCH 11/11 mfd: max8925-i2c: Drop unnecessary static

In reply to Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

---
These patches are all independent of each other.

 drivers/mfd/max8925-i2c.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/max8925-i2c.c +1 -1
diff -u -p a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
@@ -151,7 +151,7 @@ static int max8925_probe(struct i2c_clie
 				   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) {
Applied
#32 lore raw

Re: [PATCH 11/11] mfd: max8925-i2c: Drop unnecessary static

Quoted 29 lines · Julia Lawall

Drop static on a local variable, when the variable is initialized before any possible use. Thus, the static has no benefit.

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>

Quoted 7 lines

---
These patches are all independent of each other.

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

Applied, thanks.

Quoted 13 lines

diff -u -p a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c

drivers/mfd/max8925-i2c.c +1 -1
@@ -151,7 +151,7 @@ static int max8925_probe(struct i2c_clie
 				   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) {
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#33 lore raw
In reply to Julia Lawall
Quoted 3 lines · Julia Lawall

These patches fix cases where there is a static on a local variable, but the variable is initialized before any possible use. Thus, the static has no benefit.

Nice one.

#34 lore raw
Quoted 6 lines · Joe Perches
Quoted 3 lines · Julia Lawall

These patches fix cases where there is a static on a local variable, but the variable is initialized before any possible use. Thus, the static has no benefit.

Nice one.

Thanks. It was suggested by Kees Cook a while ago. There seem to be many opportunities.

julia