Opened 19 years ago

Last modified 19 years ago

#819 closed Bug report

Server - AsyncSocketEx.cpp compiler warning.

Reported by: glenara Owned by:
Priority: normal Component: Other
Keywords: Cc: glenara, Tim Kosse
Component version: Operating system type:
Operating system version:

Description

When compiling the server the following warning occurs:

AsyncSocketEx.cpp(809) : warning C4552: '!=' :
operator has no effect; expected operator with side-effect

Which is:
VERIFY(closesocket(m_SocketData.hSocket)!
=SOCKET_ERROR);

Isn't it true that the SOCKET_ERROR won't exist unless
the first part fails? If this is true, then shouldn't this be:
VERIFY(closesocket(m_SocketData.hSocket) &&
SOCKET_ERROR);

This removes the warning.

Glen

Change History (2)

comment:1 by Tim Kosse, 19 years ago

SOCKET_ERROR is a constant and all the function does is to
assert in debug builds if the socket can't be closed.

comment:2 by glenara, 19 years ago

I guess I worded that wrong! Since the function is not
returning anything (due to the nature of VERIFY) there is
nothing to compare SOCKET_ERROR against.

Anyway, I was wrong about how to remove the warning :(

To remove the warning we simply need to add an extra set of
brackets.
VERIFY((closesocket(m_SocketData.hSocket) !=
SOCKET_ERROR));

I also tested it with the debug version (by creating an error)
and it works as expected.

Glen

Note: See TracTickets for help on using tickets.