Skip to content

Conversation

@robert-scheck
Copy link
Contributor

@robert-scheck robert-scheck commented Apr 7, 2025

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 last 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