Skip to contentSkip to conversation

Checking data processing for parentheses in SmPL scripts

Cocci Markus Elfring 2 participants 5 messages Nov 11, 2019 – Nov 12, 2019

lore
Share & tools
lore
#0 lore raw

Hello,

The following change specification gets accepted by the Coccinelle software.

@@
expression X;
@@
-((X-1)&X) == 0
+powerof2(X)

See also:
https://github.com/DragonFlyBSD/DragonFlyBSD/blob/722c3b8b6376deab9407ff00b5e63018ab3aef0b/test/cocci/useful_macros.cocci#L53

I got into the development mood to try another code variant out for the semantic patch language.

@adjustment@
expression X;
@@
+powerof2(
-(X-1)&
X)
- == 0

Unfortunately, the error message “unexpected close parenthesis in line 6” is reported then.
Can an other change variation make sense finally?

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#1 lore raw
Quoted 2 lines

Unfortunately, the error message “unexpected close parenthesis in line 6” is reported then.

The following change specification gets accepted by the Coccinelle software.

@adjustment@
expression X;
@@
+powerof2
(
-(X-1)&
X)
- == 0

Would you like to discuss similar SmPL code variations any more?

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#2 lore raw
Quoted 15 lines · Markus Elfring
Quoted 2 lines

Unfortunately, the error message “unexpected close parenthesis in line 6” is reported then.

The following change specification gets accepted by the Coccinelle software.

@adjustment@
expression X;
@@

(quoted diff) +1 -2
+powerof2
 (
-(X-1)&
 X)
- == 0
Quoted 1 line

Would you like to discuss similar SmPL code variations any more?

What is the question, exactly? Is there any reason why you would not expect the above code to be accepted?

julia

Quoted 8 lines

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#3 lore raw
Quoted 1 line

What is the question, exactly?

I became curious to clarify consequences around the error message “unexpected close parenthesis in line 6” for the other SmPL code variant from yesterday.
Is the Coccinelle software looking for pairs of parentheses?

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#4 lore raw
Quoted 6 lines · Markus Elfring
Quoted 1 line

What is the question, exactly?

I became curious to clarify consequences around the error message “unexpected close parenthesis in line 6” for the other SmPL code variant from yesterday.
Is the Coccinelle software looking for pairs of parentheses?

It looks for a ( in column 0 and a matching ) that is not in column 0. In your example there was no ( or ) in column 0, so the message is not relevant.

julia

Quoted 4 lines

Regards,
Markus

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci