Searching designated initialisers with SmPL
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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 26 lines · Markus Elfring
Hello,
I hoped to achieve something together with the semantic patch language by the following search pattern.
@display@
identifier action, driver;
@@
static structplatform_driverdriver =
{
<+...
*.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
Quoted 2 lines
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
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 1 line
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
Quoted 1 line
.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
Quoted 1 line
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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 9 lines · Julia Lawall
Quoted 5 lines · Markus Elfring
Hello,
I hoped to achieve something together with the semantic patch language by the following search pattern.
Quoted 9 lines
Quoted 9 lines
@display@
identifier action, driver;
@@
static structplatform_driverdriver =
{
<+...
*.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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 3 lines
static struct
platform_driverdriver = { . 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.
Quoted 1 line
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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 8 lines · Markus Elfring
Quoted 3 lines
static struct
platform_driverdriver = { . 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.
Quoted 5 lines
Quoted 1 line
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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci