michaelrsweet/mxml

Remove unnecessary null pointer checks

elfring opened this issue · 6 comments

Agreed, target platforms for Mini-XML are not old C89 (or older) compilers anymore.

I am curious then if another software developer (besides me) can get into the mood to apply a corresponding update suggestion which could be generated by the software “Coccinelle” (also with the help of a variant from the following script).

@Remove_unnecessary_pointer_checks@
expression x;
@@
-if (\(x != 0 \| x != NULL\))
    free(x);

@elfring When it comes to detecting potential coding errors or inefficient patterns, I have no problem running a search or scan. But I have a hard time “blindly” trusting a global search-and-replace of this scope since in my experience it is easy to introduce coding/logic errors that way.

🤔 How do you think about to try a possible update generation out for the mentioned transformation pattern with the help of the semantic patch language (Coccinelle software)?

[master e058082] Clean up usage of free (Issue #276)