PVS-StudioWarnings

PVS-Studio warning V604 for DDKSamples

Nov 12th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. VOID
  2. ReportToString(
  3.    PHID_DATA pData,
  4.    _Inout_updates_bytes_(iBuffSize) LPSTR szBuff,
  5.    UINT iBuffSize
  6. )
  7. {
  8.   ....
  9.   if(FAILED(StringCbPrintf (szBuff,
  10.                 iBuffSize,
  11.                 "Usage Page: 0x%x, Usages: ",
  12.                 pData -> UsagePage)))
  13.   {
  14.     for(j=0; j<sizeof(szBuff); j++)
  15.     {
  16.       szBuff[j] = '\0';
  17.     }
  18.     return;
  19.   }
  20.   ....
  21. }
  22.  
  23. Most likely this is what should be written here: for(j=0; j<iBuffSize; j++)
  24.  
  25. This suspicious code was found in DDKSamples project by PVS-Studio static code analyzer.
  26. Warning message is:
  27. V604 It is odd that the number of iterations in the loop equals to the size of the 'szBuff' pointer. hclient.c 1688
  28.  
  29. 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