HomePhabricator

fix warning: comparison of unsigned expression < 0 is always false…
d7f1d200ab5dUnpublished

Unpublished Commit · Learn More

Repository Importing: This repository is still importing.

Description

fix warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]

Don't check for a negative parameter count, because not only will it
never happen, it doesn't make any sense either.

Invalid sockets (as returned by socket(2)) are always exactly -1 (not
just negative as negative file descriptors are technically not
prohibited by POSIX) on POSIX systems. Since we store them in SOCKET
(unsigned int), however, that really is ~0U (or MAX_UINT) which happens
to be what INVALID_SOCKET is already defined to, so an additional check
for being negative is not only unnecessary (unsigned integers aren't
*ever* negative) its redundant as well (the INVALID_SOCKET comparison is
enough).

Signed-off-by: Giel van Schijndel <me@mortis.eu>

Details

Provenance
Giel van Schijndel <me@mortis.eu>Authored on Jun 24 2011, 18:09
schancelPushed on Jan 5 2018, 21:58
schancelPushed on Jan 5 2018, 21:39
schancelPushed on Jan 5 2018, 21:17
Parents
rSTAGINGf85c0974492d: fix warnings: using the result of an assignment as a condition without…
Branches
Unknown
Tags
Unknown

Event Timeline

Giel van Schijndel <me@mortis.eu> committed rSTAGINGd7f1d200ab5d: fix warning: comparison of unsigned expression < 0 is always false… (authored by Giel van Schijndel <me@mortis.eu>).Jul 13 2011, 03:07