Advertisement
PVS-StudioWarnings

PVS-Studio warning V547 for Chromium

Nov 26th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. typedef UINT_PTR SOCKET;
  2.  
  3. SOCKET socket_;
  4.  
  5. int TCPServerSocketWin::Listen(....) {
  6.   ....
  7.   socket_ = socket(address.GetSockAddrFamily(),
  8.                    SOCK_STREAM, IPPROTO_TCP);
  9.   if (socket_ < 0) {
  10.     PLOG(ERROR) << "socket() returned an error";
  11.     return MapSystemError(WSAGetLastError());
  12.   }
  13.   ....
  14. }
  15.  
  16. This suspicious code was found in Chromium project by PVS-Studio static code analyzer.
  17. Warning message is:
  18. V547 Expression 'socket_ < 0' is always false. Unsigned type value is never < 0. tcp_server_socket_win.cc 48
  19.  
  20. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement