Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1687996 > unrolled thread

[PATCH 00/11] Drop unnecessary static

Started byJulia Lawall <Julia.Lawall@lip6.fr>
First post2017-07-15 22:40 +0200
Last post2017-07-16 08:10 +0200
Articles 11 — 5 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 00/11] Drop unnecessary static Julia Lawall <Julia.Lawall@lip6.fr> - 2017-07-15 22:40 +0200
    [PATCH 08/11] ata: Drop unnecessary static Julia Lawall <Julia.Lawall@lip6.fr> - 2017-07-15 22:40 +0200
    [PATCH 03/11] mtd: physmap_of: Drop unnecessary static Julia Lawall <Julia.Lawall@lip6.fr> - 2017-07-15 22:40 +0200
      Re: [PATCH 03/11] mtd: physmap_of: Drop unnecessary static Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-07-17 22:00 +0200
    [PATCH 01/11] clk: mmp: Drop unnecessary static Julia Lawall <Julia.Lawall@lip6.fr> - 2017-07-15 22:40 +0200
      Re: [PATCH 01/11] clk: mmp: Drop unnecessary static Stephen Boyd <sboyd@codeaurora.org> - 2017-07-18 03:40 +0200
    [PATCH 04/11] fbdev: da8xx-fb: Drop unnecessary static Julia Lawall <Julia.Lawall@lip6.fr> - 2017-07-15 22:40 +0200
    [PATCH 06/11] irqchip: mips-cpu: Drop unnecessary static Julia Lawall <Julia.Lawall@lip6.fr> - 2017-07-15 22:40 +0200
      Re: [PATCH 06/11] irqchip: mips-cpu: Drop unnecessary static Mark D Rustad <mrustad@gmail.com> - 2017-07-15 23:00 +0200
        Re: [PATCH 06/11] irqchip: mips-cpu: Drop unnecessary static Julia Lawall <julia.lawall@lip6.fr> - 2017-07-15 23:00 +0200
          Re: [PATCH 06/11] irqchip: mips-cpu: Drop unnecessary static Mark D Rustad <mrustad@gmail.com> - 2017-07-16 08:10 +0200

#1687996 — [PATCH 00/11] Drop unnecessary static

FromJulia Lawall <Julia.Lawall@lip6.fr>
Date2017-07-15 22:40 +0200
Subject[PATCH 00/11] Drop unnecessary static
Message-ID<u3C13-64w-3@gated-at.bofh.it>
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(-)

[toc] | [next] | [standalone]


#1687997 — [PATCH 08/11] ata: Drop unnecessary static

FromJulia Lawall <Julia.Lawall@lip6.fr>
Date2017-07-15 22:40 +0200
Subject[PATCH 08/11] ata: Drop unnecessary static
Message-ID<u3C14-64w-15@gated-at.bofh.it>
In reply to#1687996
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>

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

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

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

diff -u -p a/drivers/ata/sata_gemini.c b/drivers/ata/sata_gemini.c
--- 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;

[toc] | [prev] | [next] | [standalone]


#1687998 — [PATCH 03/11] mtd: physmap_of: Drop unnecessary static

FromJulia Lawall <Julia.Lawall@lip6.fr>
Date2017-07-15 22:40 +0200
Subject[PATCH 03/11] mtd: physmap_of: Drop unnecessary static
Message-ID<u3C14-64w-23@gated-at.bofh.it>
In reply to#1687996
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>

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

---
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
--- 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;
 

[toc] | [prev] | [next] | [standalone]


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

FromBoris Brezillon <boris.brezillon@free-electrons.com>
Date2017-07-17 22:00 +0200
SubjectRe: [PATCH 03/11] mtd: physmap_of: Drop unnecessary static
Message-ID<u4kls-SQ-15@gated-at.bofh.it>
In reply to#1687998
Le Sat, 15 Jul 2017 22:07:38 +0200,
Julia Lawall <Julia.Lawall@lip6.fr> a écrit :

> 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>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>

> 
> ---
> 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
> --- 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;
>  
> 

[toc] | [prev] | [next] | [standalone]


#1687999 — [PATCH 01/11] clk: mmp: Drop unnecessary static

FromJulia Lawall <Julia.Lawall@lip6.fr>
Date2017-07-15 22:40 +0200
Subject[PATCH 01/11] clk: mmp: Drop unnecessary static
Message-ID<u3C14-64w-25@gated-at.bofh.it>
In reply to#1687996
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>

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

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

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

diff -u -p a/drivers/clk/mmp/clk.c b/drivers/clk/mmp/clk.c
--- 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)

[toc] | [prev] | [next] | [standalone]


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

FromStephen Boyd <sboyd@codeaurora.org>
Date2017-07-18 03:40 +0200
SubjectRe: [PATCH 01/11] clk: mmp: Drop unnecessary static
Message-ID<u4pEu-4kz-21@gated-at.bofh.it>
In reply to#1687999
On 07/15, Julia Lawall 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>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1688000 — [PATCH 04/11] fbdev: da8xx-fb: Drop unnecessary static

FromJulia Lawall <Julia.Lawall@lip6.fr>
Date2017-07-15 22:40 +0200
Subject[PATCH 04/11] fbdev: da8xx-fb: Drop unnecessary static
Message-ID<u3C14-64w-29@gated-at.bofh.it>
In reply to#1687996
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>

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

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

 drivers/video/fbdev/da8xx-fb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/video/fbdev/da8xx-fb.c b/drivers/video/fbdev/da8xx-fb.c
--- 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;

[toc] | [prev] | [next] | [standalone]


#1688001 — [PATCH 06/11] irqchip: mips-cpu: Drop unnecessary static

FromJulia Lawall <Julia.Lawall@lip6.fr>
Date2017-07-15 22:40 +0200
Subject[PATCH 06/11] irqchip: mips-cpu: Drop unnecessary static
Message-ID<u3C14-64w-31@gated-at.bofh.it>
In reply to#1687996
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>

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

---
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
--- 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 */

[toc] | [prev] | [next] | [standalone]


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

FromMark D Rustad <mrustad@gmail.com>
Date2017-07-15 23:00 +0200
SubjectRe: [PATCH 06/11] irqchip: mips-cpu: Drop unnecessary static
Message-ID<u3Ckp-6aP-9@gated-at.bofh.it>
In reply to#1688001

[Multipart message — attachments visible in raw view] — view raw

> On Jul 15, 2017, at 1:07 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> 
> 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.

> 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>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
> 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
> --- 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 */
> 

--
Mark Rustad, MRustad@gmail.com

[toc] | [prev] | [next] | [standalone]


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

FromJulia Lawall <julia.lawall@lip6.fr>
Date2017-07-15 23:00 +0200
SubjectRe: [PATCH 06/11] irqchip: mips-cpu: Drop unnecessary static
Message-ID<u3Ckq-6aP-29@gated-at.bofh.it>
In reply to#1688002

On Sat, 15 Jul 2017, Mark D Rustad wrote:

>
> > On Jul 15, 2017, at 1:07 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> >
> > 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

>
> > 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>
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> >
> > ---
> > 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
> > --- 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 */
> >
>
> --
> Mark Rustad, MRustad@gmail.com
>
>

[toc] | [prev] | [next] | [standalone]


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

FromMark D Rustad <mrustad@gmail.com>
Date2017-07-16 08:10 +0200
SubjectRe: [PATCH 06/11] irqchip: mips-cpu: Drop unnecessary static
Message-ID<u3KUG-3rI-3@gated-at.bofh.it>
In reply to#1688004

[Multipart message — attachments visible in raw view] — view raw

> On Jul 15, 2017, at 1:59 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> 
> On Sat, 15 Jul 2017, Mark D Rustad wrote:
> 
>> 
>>> On Jul 15, 2017, at 1:07 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
>>> 
>>> 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

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

>> 
>>> 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>
>>> 
>>> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>>> 
>>> ---
>>> 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
>>> --- 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 */
>>> 
>> 
>> --
>> Mark Rustad, MRustad@gmail.com

--
Mark Rustad, MRustad@gmail.com

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web