* [Cocci] Question about a not made change
@ 2017-11-25 7:38 Francois-Xavier Le Bail
2017-11-25 7:44 ` Julia Lawall
0 siblings, 1 reply; 6+ messages in thread
From: Francois-Xavier Le Bail @ 2017-11-25 7:38 UTC (permalink / raw)
To: cocci
Hi,
I try the following patch:
-----
@@
u_char *p;
expression n;
@@
ND_PRINT(
...,
-p[n]
+EXTRACT_U_1(p + n)
)
-----
on the following (minimized) code:
-----
int main()
{
u_char *p;
ND_PRINT(ndo, ": %02x %02x", p[1], p[2]);
return 0;
}
-----
I got:
-----
+++ /tmp/cocci-output-1795-a34831-main.c
@@ -1,7 +1,7 @@
int main()
{
u_char *p;
- ND_PRINT(ndo, ": %02x %02x", p[1], p[2]);
+ ND_PRINT(ndo, ": %02x %02x", p[1], EXTRACT_U_1(p + 2));
return 0;
}
-----
Why the first p[1] is not change to EXTRACT_U_1(p + 1)?
Did I miss something obvious?
--
Francois-Xavier
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Question about a not made change
2017-11-25 7:38 [Cocci] Question about a not made change Francois-Xavier Le Bail
@ 2017-11-25 7:44 ` Julia Lawall
2017-11-25 7:54 ` Francois-Xavier Le Bail
2017-11-25 12:26 ` Francois-Xavier Le Bail
0 siblings, 2 replies; 6+ messages in thread
From: Julia Lawall @ 2017-11-25 7:44 UTC (permalink / raw)
To: cocci
On Sat, 25 Nov 2017, Francois-Xavier Le Bail wrote:
> Hi,
>
> I try the following patch:
> -----
> @@
> u_char *p;
> expression n;
> @@
> ND_PRINT(
> ...,
> -p[n]
> +EXTRACT_U_1(p + n)
> )
> -----
> on the following (minimized) code:
> -----
> int main()
> {
> u_char *p;
> ND_PRINT(ndo, ": %02x %02x", p[1], p[2]);
>
> return 0;
> }
> -----
> I got:
> -----
> +++ /tmp/cocci-output-1795-a34831-main.c
> @@ -1,7 +1,7 @@
> int main()
> {
> u_char *p;
> - ND_PRINT(ndo, ": %02x %02x", p[1], p[2]);
> + ND_PRINT(ndo, ": %02x %02x", p[1], EXTRACT_U_1(p + 2));
>
> return 0;
> }
> -----
> Why the first p[1] is not change to EXTRACT_U_1(p + 1)?
>
> Did I miss something obvious?
Yes :) There is no ,... after your change, so you only perform the change
when it is the last argument.
julia
>
> --
> Francois-Xavier
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Question about a not made change
2017-11-25 7:44 ` Julia Lawall
@ 2017-11-25 7:54 ` Francois-Xavier Le Bail
2017-11-25 12:26 ` Francois-Xavier Le Bail
1 sibling, 0 replies; 6+ messages in thread
From: Francois-Xavier Le Bail @ 2017-11-25 7:54 UTC (permalink / raw)
To: cocci
On 25/11/2017 08:44, Julia Lawall wrote:
>
>
> On Sat, 25 Nov 2017, Francois-Xavier Le Bail wrote:
>
>> Hi,
>>
>> I try the following patch:
>> -----
>> @@
>> u_char *p;
>> expression n;
>> @@
>> ND_PRINT(
>> ...,
>> -p[n]
>> +EXTRACT_U_1(p + n)
>> )
>> -----
>> on the following (minimized) code:
>> -----
>> int main()
>> {
>> u_char *p;
>> ND_PRINT(ndo, ": %02x %02x", p[1], p[2]);
>>
>> return 0;
>> }
>> -----
>> I got:
>> -----
>> +++ /tmp/cocci-output-1795-a34831-main.c
>> @@ -1,7 +1,7 @@
>> int main()
>> {
>> u_char *p;
>> - ND_PRINT(ndo, ": %02x %02x", p[1], p[2]);
>> + ND_PRINT(ndo, ": %02x %02x", p[1], EXTRACT_U_1(p + 2));
>>
>> return 0;
>> }
>> -----
>> Why the first p[1] is not change to EXTRACT_U_1(p + 1)?
>>
>> Did I miss something obvious?
>
> Yes :) There is no ,... after your change, so you only perform the change
> when it is the last argument.
Of course, THANKS!
--
Francois-Xavier
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Question about a not made change
2017-11-25 7:44 ` Julia Lawall
2017-11-25 7:54 ` Francois-Xavier Le Bail
@ 2017-11-25 12:26 ` Francois-Xavier Le Bail
2017-11-25 13:32 ` Julia Lawall
1 sibling, 1 reply; 6+ messages in thread
From: Francois-Xavier Le Bail @ 2017-11-25 12:26 UTC (permalink / raw)
To: cocci
On 25/11/2017 08:44, Julia Lawall wrote:
> On Sat, 25 Nov 2017, Francois-Xavier Le Bail wrote:
>> I try the following patch:
>> -----
>> @@
>> u_char *p;
>> expression n;
>> @@
>> ND_PRINT(
>> ...,
>> -p[n]
>> +EXTRACT_U_1(p + n)
>> )
>> -----
>> on the following (minimized) code:
>> -----
>> int main()
>> {
>> u_char *p;
>> ND_PRINT(ndo, ": %02x %02x", p[1], p[2]);
>>
>> return 0;
>> }
>> -----
>> I got:
>> -----
>> +++ /tmp/cocci-output-1795-a34831-main.c
>> @@ -1,7 +1,7 @@
>> int main()
>> {
>> u_char *p;
>> - ND_PRINT(ndo, ": %02x %02x", p[1], p[2]);
>> + ND_PRINT(ndo, ": %02x %02x", p[1], EXTRACT_U_1(p + 2));
>>
>> return 0;
>> }
>> -----
>> Why the first p[1] is not change to EXTRACT_U_1(p + 1)?
>>
>> Did I miss something obvious?
>
> Yes :) There is no ,... after your change, so you only perform the change
> when it is the last argument.
Thus, going closer my original problem, where ND_PRINT is a macro which requires double parenthesis,
I try :
-----
@@
u_char *p;
expression n;
@@
ND_PRINT((
...,
-p[n]
+EXTRACT_U_1(p + n)
,...
))
-----
I got:
- ND_PRINT((ndo, ": %x %x %x %x", p[1], p[2], p[3], p[4]));
+ ND_PRINT((ndo, ": %x %x %x %x", p[1], p[2], EXTRACT_U_1(p + 3), p[4]));
-----
Another thing I miss?
--
Francois-Xavier
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Question about a not made change
2017-11-25 12:26 ` Francois-Xavier Le Bail
@ 2017-11-25 13:32 ` Julia Lawall
2017-11-27 9:49 ` Francois-Xavier Le Bail
0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2017-11-25 13:32 UTC (permalink / raw)
To: cocci
On Sat, 25 Nov 2017, Francois-Xavier Le Bail wrote:
> On 25/11/2017 08:44, Julia Lawall wrote:
> > On Sat, 25 Nov 2017, Francois-Xavier Le Bail wrote:
> >> I try the following patch:
> >> -----
> >> @@
> >> u_char *p;
> >> expression n;
> >> @@
> >> ND_PRINT(
> >> ...,
> >> -p[n]
> >> +EXTRACT_U_1(p + n)
> >> )
> >> -----
> >> on the following (minimized) code:
> >> -----
> >> int main()
> >> {
> >> u_char *p;
> >> ND_PRINT(ndo, ": %02x %02x", p[1], p[2]);
> >>
> >> return 0;
> >> }
> >> -----
> >> I got:
> >> -----
> >> +++ /tmp/cocci-output-1795-a34831-main.c
> >> @@ -1,7 +1,7 @@
> >> int main()
> >> {
> >> u_char *p;
> >> - ND_PRINT(ndo, ": %02x %02x", p[1], p[2]);
> >> + ND_PRINT(ndo, ": %02x %02x", p[1], EXTRACT_U_1(p + 2));
> >>
> >> return 0;
> >> }
> >> -----
> >> Why the first p[1] is not change to EXTRACT_U_1(p + 1)?
> >>
> >> Did I miss something obvious?
> >
> > Yes :) There is no ,... after your change, so you only perform the change
> > when it is the last argument.
>
> Thus, going closer my original problem, where ND_PRINT is a macro which requires double parenthesis,
> I try :
> -----
> @@
> u_char *p;
> expression n;
> @@
> ND_PRINT((
> ...,
> -p[n]
> +EXTRACT_U_1(p + n)
> ,...
> ))
> -----
> I got:
> - ND_PRINT((ndo, ": %x %x %x %x", p[1], p[2], p[3], p[4]));
> + ND_PRINT((ndo, ": %x %x %x %x", p[1], p[2], EXTRACT_U_1(p + 3), p[4]));
> -----
>
> Another thing I miss?
I'mnot sure that the double parens are well supported. Try <+... ...+>
around your specific change, but I don't know if it will work.
julia
>
> --
> Francois-Xavier
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Question about a not made change
2017-11-25 13:32 ` Julia Lawall
@ 2017-11-27 9:49 ` Francois-Xavier Le Bail
0 siblings, 0 replies; 6+ messages in thread
From: Francois-Xavier Le Bail @ 2017-11-27 9:49 UTC (permalink / raw)
To: cocci
On 25/11/2017 14:32, Julia Lawall wrote:
>
>
> On Sat, 25 Nov 2017, Francois-Xavier Le Bail wrote:
>
>> On 25/11/2017 08:44, Julia Lawall wrote:
>>> On Sat, 25 Nov 2017, Francois-Xavier Le Bail wrote:
>>>> I try the following patch:
>>>> -----
>>>> @@
>>>> u_char *p;
>>>> expression n;
>>>> @@
>>>> ND_PRINT(
>>>> ...,
>>>> -p[n]
>>>> +EXTRACT_U_1(p + n)
>>>> )
>>>> -----
>>>> on the following (minimized) code:
>>>> -----
>>>> int main()
>>>> {
>>>> u_char *p;
>>>> ND_PRINT(ndo, ": %02x %02x", p[1], p[2]);
>>>>
>>>> return 0;
>>>> }
>>>> -----
>>>> I got:
>>>> -----
>>>> +++ /tmp/cocci-output-1795-a34831-main.c
>>>> @@ -1,7 +1,7 @@
>>>> int main()
>>>> {
>>>> u_char *p;
>>>> - ND_PRINT(ndo, ": %02x %02x", p[1], p[2]);
>>>> + ND_PRINT(ndo, ": %02x %02x", p[1], EXTRACT_U_1(p + 2));
>>>>
>>>> return 0;
>>>> }
>>>> -----
>>>> Why the first p[1] is not change to EXTRACT_U_1(p + 1)?
>>>>
>>>> Did I miss something obvious?
>>>
>>> Yes :) There is no ,... after your change, so you only perform the change
>>> when it is the last argument.
>>
>> Thus, going closer my original problem, where ND_PRINT is a macro which requires double parenthesis,
>> I try :
>> -----
>> @@
>> u_char *p;
>> expression n;
>> @@
>> ND_PRINT((
>> ...,
>> -p[n]
>> +EXTRACT_U_1(p + n)
>> ,...
>> ))
>> -----
>> I got:
>> - ND_PRINT((ndo, ": %x %x %x %x", p[1], p[2], p[3], p[4]));
>> + ND_PRINT((ndo, ": %x %x %x %x", p[1], p[2], EXTRACT_U_1(p + 3), p[4]));
>> -----
>>
>> Another thing I miss?
>
> I'm not sure that the double parens are well supported. Try <+... ...+>
> around your specific change, but I don't know if it will work.
It's works, Thank you !
--
Francois-Xavier
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-11-27 9:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-25 7:38 [Cocci] Question about a not made change Francois-Xavier Le Bail
2017-11-25 7:44 ` Julia Lawall
2017-11-25 7:54 ` Francois-Xavier Le Bail
2017-11-25 12:26 ` Francois-Xavier Le Bail
2017-11-25 13:32 ` Julia Lawall
2017-11-27 9:49 ` Francois-Xavier Le Bail
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.