Advertisement
PVS-StudioWarnings

PVS-Studio warning V547 for Boost

Nov 20th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. typedef SOCKET socket_type;
  2.  
  3. class socket_holder
  4. {
  5.   ....
  6.   socket_type socket_;
  7.   ....
  8.   socket_type get() const { return socket_; }
  9.   ....
  10. };
  11.  
  12. template <typename Socket>
  13. boost::system::error_code accept(....)
  14. {
  15.   ....
  16.   // On success, assign new connection to peer socket object.
  17.   if (new_socketnew_socket.get() >= 0)
  18.   {
  19.     if (peer_endpoint)
  20.       peer_endpoint->resize(addr_len);
  21.     if (!peer.assign(impl.protocol_, new_socket.get(), ec))
  22.       new_socket.release();
  23.   }
  24.   return ec;
  25. }
  26.  
  27. This suspicious code was found in Boost project by PVS-Studio static code analyzer.
  28. Warning message is:
  29. V547 Expression 'new_socket.get() >= 0' is always true. Unsigned type value is always >= 0. win_iocp_socket_service.hpp 436
  30.  
  31. 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