coccinelle: fix the equals-null transformation

The original issue with this transformation was that we were replacing
the whole if statement instead of just the expression inside. That
caused the code to be weirdly formatted, as Coccinelle put a new block
around each replaced if statement.

This version replaces just the inner expression if it's in its incorrect
form, otherwise it just accepts it (to avoid recursion).
This commit is contained in:
Frantisek Sumsal 2020-10-01 16:13:30 +02:00
parent 3bc3c734c6
commit 473de9b708
1 changed files with 21 additions and 6 deletions

View File

@ -2,13 +2,28 @@
expression e;
statement s;
@@
- if (e == NULL)
+ if (!e)
s
if (
(
!e
|
- e == NULL
+ !e
)
)
{...}
else s
@@
expression e;
statement s;
@@
- if (e != NULL)
+ if (e)
s
if (
(
e
|
- e != NULL
+ e
)
)
{...}
else s