PVS-StudioWarnings

PVS-Studio warning V547 for PHP

Nov 17th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. static size_t php_ftp_dirstream_read(....)
  2. {
  3.   size_t tmp_len;
  4.   ....
  5.   /* Trim off trailing whitespace characters */
  6.   tmp_len--;
  7.   while (tmp_len >= 0 &&                  //<==
  8.     (ent->d_name[tmp_len] == '\n' ||
  9.      ent->d_name[tmp_len] == '\r' ||
  10.      ent->d_name[tmp_len] == '\t' ||
  11.      ent->d_name[tmp_len] == ' ')) {
  12.        ent->d_name[tmp_len--] = '\0';
  13.   }
  14.   ....
  15. }
  16.  
  17. This suspicious code was found in PHP project by PVS-Studio static code analyzer.
  18. Warning message is:
  19. V547 Expression 'tmp_len >= 0' is always true. Unsigned type value is always >= 0. ftp_fopen_wrapper.c 639
  20.  
  21. 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