Coccinelle archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] Searching designated initialisers with SmPL
@ 2019-10-27 15:12 Markus Elfring
  2019-10-27 16:14 ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Markus Elfring @ 2019-10-27 15:12 UTC (permalink / raw)
  To: Coccinelle

Hello,

I hoped to achieve something together with the semantic patch language
by the following search pattern.

@display@
identifier action, driver;
@@
 static struct platform_driver driver =
 {
 <+...
*.remove = action
 ...+>
 };


Unfortunately, I stumble on another error message.

elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci show_designated_initialisers6.cocci
…
minus: parse error:
  File "show_designated_initialisers6.cocci", line 7, column 1, charpos = 91
  around = '.',
  whole content = *.remove = action


How would you like to clarify the software behaviour for
such an use case?

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

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

* Re: [Cocci] Searching designated initialisers with SmPL
  2019-10-27 15:12 [Cocci] Searching designated initialisers with SmPL Markus Elfring
@ 2019-10-27 16:14 ` Julia Lawall
  2019-10-27 16:47   ` Markus Elfring
  2019-10-27 16:50   ` Julia Lawall
  0 siblings, 2 replies; 6+ messages in thread
From: Julia Lawall @ 2019-10-27 16:14 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Coccinelle

[-- Attachment #1: Type: text/plain, Size: 888 bytes --]



On Sun, 27 Oct 2019, Markus Elfring wrote:

> Hello,
>
> I hoped to achieve something together with the semantic patch language
> by the following search pattern.
>
> @display@
> identifier action, driver;
> @@
>  static struct platform_driver driver =
>  {
>  <+...
> *.remove = action
>  ...+>
>  };
>
>
> Unfortunately, I stumble on another error message.
>
> elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci show_designated_initialisers6.cocci
> …
> minus: parse error:
>   File "show_designated_initialisers6.cocci", line 7, column 1, charpos = 91
>   around = '.',
>   whole content = *.remove = action
>
>
> How would you like to clarify the software behaviour for
> such an use case?

I don't know why you would even expect this to work.  .remove is not a
mainingful construct in the C language.  It is part of one, but it is not
a construct by itself.

julia

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

* Re: [Cocci] Searching designated initialisers with SmPL
  2019-10-27 16:14 ` Julia Lawall
@ 2019-10-27 16:47   ` Markus Elfring
  2019-10-27 16:50   ` Julia Lawall
  1 sibling, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2019-10-27 16:47 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Coccinelle

> I don't know why you would even expect this to work.

I suggest to take another look at related information sources.
https://en.cppreference.com/w/c/language/struct_initialization


> .remove is not a mainingful construct in the C language.

I got an other impression from the declaration of a known data structure.
https://elixir.bootlin.com/linux/v5.4-rc2/source/include/linux/platform_device.h#L188
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/platform_device.h?id=153a971ff578e9c8c5eadc9463c1d73a6adc8693#n190


> It is part of one, but it is not a construct by itself.

I am trying to improve source code analysis also around the usage
of function pointers.

But I have found some interesting information by the following search approach.

@find@
identifier action, driver;
@@
 static struct platform_driver driver =
 {
 ...,
 .remove = action,
 ...
 };

@display@
identifier find.action;
type T;
@@
 T action(...)
 {
 <+...
*kfree(...);
 ...+>
 }


So I guess that the clarification can become more interesting also for
the influence of commas and related SmPL constructs.

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

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

* Re: [Cocci] Searching designated initialisers with SmPL
  2019-10-27 16:14 ` Julia Lawall
  2019-10-27 16:47   ` Markus Elfring
@ 2019-10-27 16:50   ` Julia Lawall
  2019-10-27 17:08     ` Markus Elfring
  1 sibling, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2019-10-27 16:50 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Coccinelle



On Sun, 27 Oct 2019, Julia Lawall wrote:

>
>
> On Sun, 27 Oct 2019, Markus Elfring wrote:
>
> > Hello,
> >
> > I hoped to achieve something together with the semantic patch language
> > by the following search pattern.
> >
> > @display@
> > identifier action, driver;
> > @@
> >  static struct platform_driver driver =
> >  {
> >  <+...
> > *.remove = action
> >  ...+>
> >  };

Sorry, I thought that the above code was in a function definition.

It should be:

static struct platform_driver driver = { . remove = acrtion, };

There is no need for any form of ...

On the other hand the trailing comma is required.

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

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

* Re: [Cocci] Searching designated initialisers with SmPL
  2019-10-27 16:50   ` Julia Lawall
@ 2019-10-27 17:08     ` Markus Elfring
  2019-10-27 17:17       ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Markus Elfring @ 2019-10-27 17:08 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Coccinelle

> static struct platform_driver driver = { . remove = acrtion, };
>
> There is no need for any form of ...

I feel still unsure about the omission of SmPL ellipses
for the search of designated initialisers.


> On the other hand the trailing comma is required.

Thanks for such information.

Can this view change for the application of simpler search patterns?

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

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

* Re: [Cocci] Searching designated initialisers with SmPL
  2019-10-27 17:08     ` Markus Elfring
@ 2019-10-27 17:17       ` Julia Lawall
  0 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2019-10-27 17:17 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Coccinelle



On Sun, 27 Oct 2019, Markus Elfring wrote:

> > static struct platform_driver driver = { . remove = acrtion, };
> >
> > There is no need for any form of ...
>
> I feel still unsure about the omission of SmPL ellipses
> for the search of designated initialisers.
>
>
> > On the other hand the trailing comma is required.
>
> Thanks for such information.
>
> Can this view change for the application of simpler search patterns?

No.

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

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-27 15:12 [Cocci] Searching designated initialisers with SmPL Markus Elfring
2019-10-27 16:14 ` Julia Lawall
2019-10-27 16:47   ` Markus Elfring
2019-10-27 16:50   ` Julia Lawall
2019-10-27 17:08     ` Markus Elfring
2019-10-27 17:17       ` Julia Lawall

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git