Skip to content

Commit

Permalink
fix warning: comparison of unsigned expression < 0 is always false [-…
Browse files Browse the repository at this point in the history
…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 <[email protected]>
  • Loading branch information
muggenhor committed Jul 13, 2011
1 parent f85c097 commit d7f1d20
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ void ThreadSocketHandler2(void* parg)
{
BOOST_FOREACH(CNode* pnode, vNodes)
{
if (pnode->hSocket == INVALID_SOCKET || pnode->hSocket < 0)
if (pnode->hSocket == INVALID_SOCKET)
continue;
FD_SET(pnode->hSocket, &fdsetRecv);
FD_SET(pnode->hSocket, &fdsetError);
Expand Down
2 changes: 1 addition & 1 deletion src/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ int64 GetAccountBalance(const string& strAccount, int nMinDepth)

Value getbalance(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 0 || params.size() > 2)
if (fHelp || params.size() > 2)
throw runtime_error(
"getbalance [account] [minconf=1]\n"
"If [account] is not specified, returns the server's total available balance.\n"
Expand Down

0 comments on commit d7f1d20

Please sign in to comment.