Skip to content

Remove duplicate/unreachable if() #128

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robert-scheck
Copy link
Contributor

Situation:

if (*eptr != '\n') { … }
if (errno == ERANGE && asn == ULONG_MAX) { … }
if (asn == 0 || asn >= 4294967295) { … }
if (eptr && *eptr != '\n') { … }

From my understanding the last if() is duplicate/redundant/unreachable, because whenever the second if() evaluates to true, the first if() already evaluated to true before.

In general this was spotted by GitHub CodeQL in my fork on GitHub, but as as "redundant null check due to previous dereference" (because strtoul() never sets *eptr to NULL).

The current code was introduced with commit b481111; the first if() was previously:

if (q[0] == '\0' || *eptr != '\0') { … }

I'm still not really sure why the previous *eptr check was changed from \0 to \n in the commit mentioned above…please cross-check before accepting this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant