PVS-StudioWarnings

PVS-Studio warning V547 for MTASA

Nov 20th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. int
  2. utf8_wctomb (unsigned char *dest, wchar_t wc, int dest_size)
  3. {
  4.   if (!dest)
  5.     return 0;
  6.   int count;
  7.   if (wc < 0x80)
  8.     count = 1;
  9.   else if (wc < 0x800)
  10.     count = 2;
  11.   else if (wc < 0x10000)
  12.     count = 3;
  13.   else if (wc < 0x200000)
  14.     count = 4;
  15.   else if (wc < 0x4000000)
  16.     count = 5;
  17.   else if (wc <= 0x7fffffff)
  18.     count = 6;
  19.   else
  20.     return RET_ILSEQ;
  21.   ....
  22. }
  23.  
  24. This suspicious code was found in MTASA project by PVS-Studio static code analyzer.
  25. Warning message is:
  26. V547 Expression 'wc < 0x10000' is always true. The value range of wchar_t type: [0, 65535]. utf8.h 121
  27.  
  28. 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