PVS-StudioWarnings

PVS-Studio warning V547 for amtsdk

Nov 12th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. int ReadFileData(char* fileName, UINT8 data[], size_t size)
  2. {
  3.   size_t fileSize , bytesRead;
  4.   ...
  5.   bytesRead = read(fileno(fileHandle), data, (int) size);
  6.  
  7.   if (bytesRead < 0)
  8.   {
  9.     printf("Error while Reading file %s : %s",
  10.            fileName, strerror(errno));
  11.     bytesRead = 0;
  12.   }
  13.   ...
  14. }
  15.  
  16. This suspicious code was found in amtsdk project by PVS-Studio static code analyzer.
  17. Warning message is:
  18. V547 Expression 'bytesRead < 0' is always false. Unsigned type value is never < 0. RemoteConsole remote.c 173
  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