Skip to contentSkip to conversation

coccinelle: Convert comma to semicolon

Cocci Markus Elfring 1 participant 1 message Aug 21, 2020

lore
Share & tools
lore
#0 lore raw
Quoted 9 lines
Quoted 8 lines

Add an imperfect test to detect these comma uses.

No false positives were found in testing, but many types of false negatives are possible.

e.g.:

	foo = bar() + 1,	/* comma use, but not direct assignment */
	bar = baz();
Quoted 5 lines

Hi.

I recently added a test for this condition to linux's checkpatch.

A similar coccinelle script might be:

I find it interesting that you present another transformation approach for the semantic patch language.

Quoted 10 lines
$ cat comma.cocci
@@
expression e1;
expression e2;
@@
	e1
(quoted diff) +1 -1
-	,
+	;
	e2;

Such a tiny SmPL script looks so simple.

Quoted 2 lines

This works reasonably well but it has several false positives for declarations like:

Would you like to filter the usage of code like “LIST_HEAD(list)” out?

Are there any more software development challenges to consider for special assignment statements?

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