PVS-StudioWarnings

PVS-Studio warning V547 for samba

Nov 13th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. struct server_id {
  2.   uint32_t pid;
  3.   uint32_t vnn;
  4.   uint64_t unique_id;
  5. }
  6.  
  7. struct server_id interpret_pid(const char *pid_string)
  8. {
  9.   struct server_id result;
  10.   ....
  11.   /* Assigning to result.pid may have overflowed
  12.      Map negative pid to -1: i.e. error */
  13.   if (result.pid < 0) {
  14.     result.pid = -1;
  15.   }
  16.   ....
  17. }
  18.  
  19. This suspicious code was found in samba project by PVS-Studio static code analyzer.
  20. Warning message is:
  21. V547 Expression 'result.pid < 0' is always false. Unsigned type value is never < 0. util.c 2376
  22.  
  23. 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