Advertisement
PVS-StudioWarnings

PVS-Studio warning V583 for VirtualBox

Nov 21st, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. static const uint8_t g_acDaysInMonths[12] =
  2. {
  3.   /*Jan Feb Mar Arp May Jun Jul Aug Sep Oct Nov Dec */
  4.     31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
  5. };
  6.  
  7. static const uint8_t g_acDaysInMonthsLeap[12] =
  8. {
  9.   /*Jan Feb Mar Arp May Jun Jul Aug Sep Oct Nov Dec */
  10.     31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
  11. };
  12.  
  13. static PRTTIME rtTimeNormalizeInternal(PRTTIME pTime)
  14. {
  15.   ....
  16.   unsigned cDaysInMonth = fLeapYear
  17.     ? g_acDaysInMonthsLeap[pTime->u8Month - 1]          //<==
  18.     : g_acDaysInMonthsLeap[pTime->u8Month - 1];         //<==
  19.   ....
  20. }
  21.  
  22. This suspicious code was found in VirtualBox project by PVS-Studio static code analyzer.
  23. Warning message is:
  24. V583 The '?:' operator, regardless of its conditional expression, always returns one and the same value: g_acDaysInMonthsLeap[pTime->u8Month - 1]. time.cpp 453
  25.  
  26. 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
Advertisement