Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary null pointer checks #276

Closed
elfring opened this issue Dec 28, 2020 · 6 comments
Closed

Remove unnecessary null pointer checks #276

elfring opened this issue Dec 28, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request priority-low
Milestone

Comments

@elfring
Copy link

elfring commented Dec 28, 2020

Extra null pointer checks are not needed in functions like the following.

@michaelrsweet
Copy link
Owner

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

@michaelrsweet michaelrsweet self-assigned this Dec 28, 2020
@michaelrsweet michaelrsweet added enhancement New feature or request priority-low labels Dec 28, 2020
@michaelrsweet michaelrsweet added this to the Stable milestone Dec 28, 2020
@elfring
Copy link
Author

elfring commented Dec 28, 2020

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);

@michaelrsweet
Copy link
Owner

@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.

@elfring
Copy link
Author

elfring commented Dec 28, 2020

🤔 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)?

@michaelrsweet
Copy link
Owner

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

@elfring
Copy link
Author

elfring commented Oct 26, 2021

Thanks for your small source code improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority-low
Projects
None yet
Development

No branches or pull requests

2 participants