glimpse
glimpse copied to clipboard
Remove unnecessary null pointer checks
An extra null pointer check is not needed in functions like the following.
Would you like to add the following semantic patch approach to a test directory?
@Remove_unnecessary_pointer_checks1@
expression x;
@@
-if (\(x != 0 \| x != NULL\))
free(x);
@Remove_unnecessary_pointer_checks2@
expression x;
@@
-if (\(x != 0 \| x != NULL\)) {
free(x);
x = \(0 \| NULL\);
-}
@Remove_unnecessary_pointer_checks3@
expression a, b;
@@
-if (\(a != 0 \| a != NULL\) && \(b != 0 \| b != NULL\))
+if (a)
free(b);
@Remove_unnecessary_pointer_checks4@
expression a, b;
@@
-if (\(a != 0 \| a != NULL\) && \(b != 0 \| b != NULL\)) {
+if (a) {
free(b);
b = \(0 \| NULL\);
}
How do you think about to apply a corresponding update suggestion which can be generated by the software "Coccinelle"?