* [Cocci] Checking the deletion of a multiplication operator with SmPL
@ 2020-08-29 8:25 Markus Elfring
2020-08-29 9:16 ` Julia Lawall
0 siblings, 1 reply; 6+ messages in thread
From: Markus Elfring @ 2020-08-29 8:25 UTC (permalink / raw)
To: Coccinelle; +Cc: Gustavo A. R. Silva, Kees Cook
Hello,
The following small script variant for the semantic patch language gets accepted
according to the software combination “Coccinelle 1.0.8-00159-g730dbb03”.
@replacement@
identifier array, instance, size;
type T;
@@
(
-sizeof(T)
|
-sizeof(*instance->array)
)
*
+flex_array_size(instance, array,
instance->size
+ )
But I observe data processing difficulties if I would like to mark
the multiplication operator also for deletion (on a separate line).
elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci flex_array_size-test2-20200829.cocci
init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
File "flex_array_size-test2-20200829.cocci", line 10, column 1, charpos = 103
around = '*',
whole content = -*
Can such a transformation specification become supported?
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] Checking the deletion of a multiplication operator with SmPL
2020-08-29 8:25 [Cocci] Checking the deletion of a multiplication operator with SmPL Markus Elfring
@ 2020-08-29 9:16 ` Julia Lawall
2020-08-29 11:02 ` [Cocci] Checking the application of a SmPL disjunction for a function call addition Markus Elfring
0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2020-08-29 9:16 UTC (permalink / raw)
To: Markus Elfring; +Cc: Coccinelle, Kees Cook, Gustavo A. R. Silva
[-- Attachment #1: Type: text/plain, Size: 1323 bytes --]
On Sat, 29 Aug 2020, Markus Elfring wrote:
> Hello,
>
> The following small script variant for the semantic patch language gets accepted
> according to the software combination “Coccinelle 1.0.8-00159-g730dbb03”.
>
> @replacement@
> identifier array, instance, size;
> type T;
> @@
> (
> -sizeof(T)
> |
> -sizeof(*instance->array)
> )
> *
> +flex_array_size(instance, array,
> instance->size
> + )
This semantic patch will fail if the sizeof(T) option is matched, becuse
then it won't be able to create the + code, since it won't know what array
should be.
>
>
> But I observe data processing difficulties if I would like to mark
> the multiplication operator also for deletion (on a separate line).
>
> elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci flex_array_size-test2-20200829.cocci
> init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
> File "flex_array_size-test2-20200829.cocci", line 10, column 1, charpos = 103
> around = '*',
> whole content = -*
>
>
> Can such a transformation specification become supported?
This doens't work because you have no space beterrn the - and the *. The
characters - + * ? ( ) | and & are treated in a special way in column 0,
and more generally when there is no whitespace before them in the line.
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] Checking the application of a SmPL disjunction for a function call addition
2020-08-29 9:16 ` Julia Lawall
@ 2020-08-29 11:02 ` Markus Elfring
2020-08-29 11:11 ` Julia Lawall
0 siblings, 1 reply; 6+ messages in thread
From: Markus Elfring @ 2020-08-29 11:02 UTC (permalink / raw)
To: Julia Lawall, Denis Efremov; +Cc: Coccinelle, Kees Cook, Gustavo A. R. Silva
>> @replacement@
>> identifier array, instance, size;
>> type T;
>> @@
>> (
>> -sizeof(T)
>> |
>> -sizeof(*instance->array)
>> )
>> *
>> +flex_array_size(instance, array,
>> instance->size
>> + )
>
> This semantic patch will fail if the sizeof(T) option is matched, becuse
> then it won't be able to create the + code, since it won't know what array
> should be.
Will this information trigger further consequences for the clarification
of the topic “[RFC PATCH] coccinelle: api: add flex_array_size.cocci script”?
https://lore.kernel.org/cocci/20200828163134.496386-1-efremov@linux.com/
https://systeme.lip6.fr/pipermail/cocci/2020-August/008169.html
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] Checking the application of a SmPL disjunction for a function call addition
2020-08-29 11:02 ` [Cocci] Checking the application of a SmPL disjunction for a function call addition Markus Elfring
@ 2020-08-29 11:11 ` Julia Lawall
2020-08-29 11:14 ` Markus Elfring
0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2020-08-29 11:11 UTC (permalink / raw)
To: Markus Elfring; +Cc: Kees Cook, Coccinelle, Gustavo A. R. Silva
[-- Attachment #1: Type: text/plain, Size: 877 bytes --]
On Sat, 29 Aug 2020, Markus Elfring wrote:
> >> @replacement@
> >> identifier array, instance, size;
> >> type T;
> >> @@
> >> (
> >> -sizeof(T)
> >> |
> >> -sizeof(*instance->array)
> >> )
> >> *
> >> +flex_array_size(instance, array,
> >> instance->size
> >> + )
> >
> > This semantic patch will fail if the sizeof(T) option is matched, becuse
> > then it won't be able to create the + code, since it won't know what array
> > should be.
>
> Will this information trigger further consequences for the clarification
> of the topic “[RFC PATCH] coccinelle: api: add flex_array_size.cocci script”?
> https://lore.kernel.org/cocci/20200828163134.496386-1-efremov@linux.com/
> https://systeme.lip6.fr/pipermail/cocci/2020-August/008169.html
As far as I can see, in that semantic patch, array is always inherited
from a previous rule.
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] Checking the application of a SmPL disjunction for a function call addition
2020-08-29 11:11 ` Julia Lawall
@ 2020-08-29 11:14 ` Markus Elfring
2020-08-29 11:45 ` Julia Lawall
0 siblings, 1 reply; 6+ messages in thread
From: Markus Elfring @ 2020-08-29 11:14 UTC (permalink / raw)
To: Julia Lawall, Denis Efremov; +Cc: Coccinelle, Kees Cook, Gustavo A. R. Silva
>> Will this information trigger further consequences for the clarification
>> of the topic “[RFC PATCH] coccinelle: api: add flex_array_size.cocci script”?
>> https://lore.kernel.org/cocci/20200828163134.496386-1-efremov@linux.com/
>> https://systeme.lip6.fr/pipermail/cocci/2020-August/008169.html
>
> As far as I can see, in that semantic patch, array is always inherited
> from a previous rule.
Does this technical detail change the handling of the discussed SmPL disjunction
in any ways?
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] Checking the application of a SmPL disjunction for a function call addition
2020-08-29 11:14 ` Markus Elfring
@ 2020-08-29 11:45 ` Julia Lawall
0 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2020-08-29 11:45 UTC (permalink / raw)
To: Markus Elfring; +Cc: Kees Cook, Coccinelle, Gustavo A. R. Silva
[-- Attachment #1: Type: text/plain, Size: 729 bytes --]
On Sat, 29 Aug 2020, Markus Elfring wrote:
> >> Will this information trigger further consequences for the clarification
> >> of the topic “[RFC PATCH] coccinelle: api: add flex_array_size.cocci script”?
> >> https://lore.kernel.org/cocci/20200828163134.496386-1-efremov@linux.com/
> >> https://systeme.lip6.fr/pipermail/cocci/2020-August/008169.html
> >
> > As far as I can see, in that semantic patch, array is always inherited
> > from a previous rule.
>
> Does this technical detail change the handling of the discussed SmPL disjunction
> in any ways?
size is bound if and only if array is bound. All of the rules contain
size in the removed (and thus matched) code, so a binding of array is
always available.
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
end of thread, other threads:[~2020-08-29 11:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-29 8:25 [Cocci] Checking the deletion of a multiplication operator with SmPL Markus Elfring
2020-08-29 9:16 ` Julia Lawall
2020-08-29 11:02 ` [Cocci] Checking the application of a SmPL disjunction for a function call addition Markus Elfring
2020-08-29 11:11 ` Julia Lawall
2020-08-29 11:14 ` Markus Elfring
2020-08-29 11:45 ` Julia Lawall
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).