cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] ormatting problems when introducing a function with coccinelle
@ 2019-04-07 18:49 Guenter Roeck
  2019-04-07 19:09 ` Julia Lawall
  2019-04-07 19:18 ` Julia Lawall
  0 siblings, 2 replies; 7+ messages in thread
From: Guenter Roeck @ 2019-04-07 18:49 UTC (permalink / raw)
  To: cocci

Hi Coccinelle experts,

I am trying to introduce a new function with coccinelle.

The semantic patch is something like

@devm depends on prb@
identifier r.initfn;
identifier fname.clkfunc;
@@
+ static void clkfunc(void *data) { clk_disable_unprepare(data); }
   initfn(...) { ... }

This works, but the resulting output is always

+static void armada_clk_disable_unprepare(void *data) {
+       clk_disable_unprepare(data);
+}
+
  static int armada_37xx_wdt_probe(struct platform_device *pdev)

meaning the opening '{' is in the same line as the function declaration.
It doesn't matter if I provide the function in a single line or
in multiple lines. It also doesn't matter if I try to manipulate
the function afterwards. The output looks always the same.

Is there a way to tell coccinelle that it should generate

+static void armada_clk_disable_unprepare(void *data)
+{
+       clk_disable_unprepare(data);
+}
+
  static int armada_37xx_wdt_probe(struct platform_device *pdev)

instead ?

Thanks,
Guenter
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Cocci] ormatting problems when introducing a function with coccinelle
  2019-04-07 18:49 [Cocci] ormatting problems when introducing a function with coccinelle Guenter Roeck
@ 2019-04-07 19:09 ` Julia Lawall
  2019-04-07 20:03   ` Guenter Roeck
  2019-04-07 19:18 ` Julia Lawall
  1 sibling, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2019-04-07 19:09 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: cocci



On Sun, 7 Apr 2019, Guenter Roeck wrote:

> Hi Coccinelle experts,
>
> I am trying to introduce a new function with coccinelle.
>
> The semantic patch is something like
>
> @devm depends on prb@
> identifier r.initfn;
> identifier fname.clkfunc;
> @@
> + static void clkfunc(void *data) { clk_disable_unprepare(data); }
>   initfn(...) { ... }

You can do:

+ static void clkfunc(void *data)
+{ clk_disable_unprepare(data); }
  initfn(...) { ... }

and then use the command line argument --smpl-spacing.

But I will check whether it can be easily fixed.

julia


>
> This works, but the resulting output is always
>
> +static void armada_clk_disable_unprepare(void *data) {
> +       clk_disable_unprepare(data);
> +}
> +
>  static int armada_37xx_wdt_probe(struct platform_device *pdev)
>
> meaning the opening '{' is in the same line as the function declaration.
> It doesn't matter if I provide the function in a single line or
> in multiple lines. It also doesn't matter if I try to manipulate
> the function afterwards. The output looks always the same.
>
> Is there a way to tell coccinelle that it should generate
>
> +static void armada_clk_disable_unprepare(void *data)
> +{
> +       clk_disable_unprepare(data);
> +}
> +
>  static int armada_37xx_wdt_probe(struct platform_device *pdev)
>
> instead ?
>
> Thanks,
> Guenter
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Cocci] ormatting problems when introducing a function with coccinelle
  2019-04-07 18:49 [Cocci] ormatting problems when introducing a function with coccinelle Guenter Roeck
  2019-04-07 19:09 ` Julia Lawall
@ 2019-04-07 19:18 ` Julia Lawall
  2019-04-07 20:14   ` Guenter Roeck
  1 sibling, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2019-04-07 19:18 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: cocci

On Sun, 7 Apr 2019, Guenter Roeck wrote:

> Hi Coccinelle experts,
>
> I am trying to introduce a new function with coccinelle.
>
> The semantic patch is something like
>
> @devm depends on prb@
> identifier r.initfn;
> identifier fname.clkfunc;
> @@
> + static void clkfunc(void *data) { clk_disable_unprepare(data); }
>   initfn(...) { ... }
>
> This works, but the resulting output is always
>
> +static void armada_clk_disable_unprepare(void *data) {
> +       clk_disable_unprepare(data);
> +}
> +
>  static int armada_37xx_wdt_probe(struct platform_device *pdev)
>
> meaning the opening '{' is in the same line as the function declaration.
> It doesn't matter if I provide the function in a single line or
> in multiple lines. It also doesn't matter if I try to manipulate
> the function afterwards. The output looks always the same.

You can try the new version on github.

julia


>
> Is there a way to tell coccinelle that it should generate
>
> +static void armada_clk_disable_unprepare(void *data)
> +{
> +       clk_disable_unprepare(data);
> +}
> +
>  static int armada_37xx_wdt_probe(struct platform_device *pdev)
>
> instead ?
>
> Thanks,
> Guenter
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Cocci] ormatting problems when introducing a function with coccinelle
  2019-04-07 19:09 ` Julia Lawall
@ 2019-04-07 20:03   ` Guenter Roeck
  2019-04-07 20:05     ` Julia Lawall
  0 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2019-04-07 20:03 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

Hi Julia,

On 4/7/19 12:09 PM, Julia Lawall wrote:
> 
> 
> On Sun, 7 Apr 2019, Guenter Roeck wrote:
> 
>> Hi Coccinelle experts,
>>
>> I am trying to introduce a new function with coccinelle.
>>
>> The semantic patch is something like
>>
>> @devm depends on prb@
>> identifier r.initfn;
>> identifier fname.clkfunc;
>> @@
>> + static void clkfunc(void *data) { clk_disable_unprepare(data); }
>>    initfn(...) { ... }
> 
> You can do:
> 
> + static void clkfunc(void *data)
> +{ clk_disable_unprepare(data); }
>    initfn(...) { ... }
> 
> and then use the command line argument --smpl-spacing.
> 

That kind of works,

+static void armada_clk_disable_unprepare(void *data)
+{
+       clk_disable_unprepare(data);
+}
+
  static int armada_37xx_wdt_probe(struct platform_device *pdev)

but it doesn't line wrap the calling code.

+       ret = devm_add_action_or_reset(&pdev->dev, armada_clk_disable_unprepare, dev->clk);
+       if (ret)
+               return ret;

This isn't really much better.

I tried --max-width, but it looks like that doesn't work with --smpl-spacing.

Thanks,
Guenter
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Cocci] ormatting problems when introducing a function with coccinelle
  2019-04-07 20:03   ` Guenter Roeck
@ 2019-04-07 20:05     ` Julia Lawall
  2019-04-07 20:17       ` Guenter Roeck
  0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2019-04-07 20:05 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: cocci



On Sun, 7 Apr 2019, Guenter Roeck wrote:

> Hi Julia,
>
> On 4/7/19 12:09 PM, Julia Lawall wrote:
> >
> >
> > On Sun, 7 Apr 2019, Guenter Roeck wrote:
> >
> > > Hi Coccinelle experts,
> > >
> > > I am trying to introduce a new function with coccinelle.
> > >
> > > The semantic patch is something like
> > >
> > > @devm depends on prb@
> > > identifier r.initfn;
> > > identifier fname.clkfunc;
> > > @@
> > > + static void clkfunc(void *data) { clk_disable_unprepare(data); }
> > >    initfn(...) { ... }
> >
> > You can do:
> >
> > + static void clkfunc(void *data)
> > +{ clk_disable_unprepare(data); }
> >    initfn(...) { ... }
> >
> > and then use the command line argument --smpl-spacing.
> >
>
> That kind of works,
>
> +static void armada_clk_disable_unprepare(void *data)
> +{
> +       clk_disable_unprepare(data);
> +}
> +
>  static int armada_37xx_wdt_probe(struct platform_device *pdev)
>
> but it doesn't line wrap the calling code.
>
> +       ret = devm_add_action_or_reset(&pdev->dev,
> armada_clk_disable_unprepare, dev->clk);
> +       if (ret)
> +               return ret;
>
> This isn't really much better.
>
> I tried --max-width, but it looks like that doesn't work with --smpl-spacing.

Did you try the new version?

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Cocci] ormatting problems when introducing a function with coccinelle
  2019-04-07 19:18 ` Julia Lawall
@ 2019-04-07 20:14   ` Guenter Roeck
  0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2019-04-07 20:14 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

On 4/7/19 12:18 PM, Julia Lawall wrote:
> On Sun, 7 Apr 2019, Guenter Roeck wrote:
> 
>> Hi Coccinelle experts,
>>
>> I am trying to introduce a new function with coccinelle.
>>
>> The semantic patch is something like
>>
>> @devm depends on prb@
>> identifier r.initfn;
>> identifier fname.clkfunc;
>> @@
>> + static void clkfunc(void *data) { clk_disable_unprepare(data); }
>>    initfn(...) { ... }
>>
>> This works, but the resulting output is always
>>
>> +static void armada_clk_disable_unprepare(void *data) {
>> +       clk_disable_unprepare(data);
>> +}
>> +
>>   static int armada_37xx_wdt_probe(struct platform_device *pdev)
>>
>> meaning the opening '{' is in the same line as the function declaration.
>> It doesn't matter if I provide the function in a single line or
>> in multiple lines. It also doesn't matter if I try to manipulate
>> the function afterwards. The output looks always the same.
> 
> You can try the new version on github.
> 

Super. That works just great. Thanks a lot!

Guenter

> julia
> 
> 
>>
>> Is there a way to tell coccinelle that it should generate
>>
>> +static void armada_clk_disable_unprepare(void *data)
>> +{
>> +       clk_disable_unprepare(data);
>> +}
>> +
>>   static int armada_37xx_wdt_probe(struct platform_device *pdev)
>>
>> instead ?
>>
>> Thanks,
>> Guenter
>> _______________________________________________
>> Cocci mailing list
>> Cocci@systeme.lip6.fr
>> https://systeme.lip6.fr/mailman/listinfo/cocci
>>
> 

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Cocci] ormatting problems when introducing a function with coccinelle
  2019-04-07 20:05     ` Julia Lawall
@ 2019-04-07 20:17       ` Guenter Roeck
  0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2019-04-07 20:17 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

On 4/7/19 1:05 PM, Julia Lawall wrote:
> 
> 
> On Sun, 7 Apr 2019, Guenter Roeck wrote:
> 
>> Hi Julia,
>>
>> On 4/7/19 12:09 PM, Julia Lawall wrote:
>>>
>>>
>>> On Sun, 7 Apr 2019, Guenter Roeck wrote:
>>>
>>>> Hi Coccinelle experts,
>>>>
>>>> I am trying to introduce a new function with coccinelle.
>>>>
>>>> The semantic patch is something like
>>>>
>>>> @devm depends on prb@
>>>> identifier r.initfn;
>>>> identifier fname.clkfunc;
>>>> @@
>>>> + static void clkfunc(void *data) { clk_disable_unprepare(data); }
>>>>     initfn(...) { ... }
>>>
>>> You can do:
>>>
>>> + static void clkfunc(void *data)
>>> +{ clk_disable_unprepare(data); }
>>>     initfn(...) { ... }
>>>
>>> and then use the command line argument --smpl-spacing.
>>>
>>
>> That kind of works,
>>
>> +static void armada_clk_disable_unprepare(void *data)
>> +{
>> +       clk_disable_unprepare(data);
>> +}
>> +
>>   static int armada_37xx_wdt_probe(struct platform_device *pdev)
>>
>> but it doesn't line wrap the calling code.
>>
>> +       ret = devm_add_action_or_reset(&pdev->dev,
>> armada_clk_disable_unprepare, dev->clk);
>> +       if (ret)
>> +               return ret;
>>
>> This isn't really much better.
>>
>> I tried --max-width, but it looks like that doesn't work with --smpl-spacing.
> 
> Did you try the new version?
> 
No, that was with the old version. The new version does the trick.

Again, thanks a lot!

Guenter
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-04-07 20:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-07 18:49 [Cocci] ormatting problems when introducing a function with coccinelle Guenter Roeck
2019-04-07 19:09 ` Julia Lawall
2019-04-07 20:03   ` Guenter Roeck
2019-04-07 20:05     ` Julia Lawall
2019-04-07 20:17       ` Guenter Roeck
2019-04-07 19:18 ` Julia Lawall
2019-04-07 20:14   ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).