issues found in VirtualBox source code checked by PSV Studio

Discussions related to using the OSE version of VirtualBox.
Post Reply
Serge Kraikov
Posts: 6
Joined: 19. Dec 2013, 06:37

issues found in VirtualBox source code checked by PSV Studio

Post by Serge Kraikov »

I recently found the blog post http://www.viva64.com/en/b/0281/,
where the author run his C++ static analyser (PVS Studio) against VirtualBox source code, and found a couple of issues.
As I know, he does not reported found issues.
I wonder are VirtualBox developers know about these issues?
Should I create bugtracker tikets for them?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: issues found in VirtualBox source code checked by PSV St

Post by mpack »

Are the warnings useful? Just because a static analyzer flagged some warnings doesn't mean it is right.
Serge Kraikov
Posts: 6
Joined: 19. Dec 2013, 06:37

Re: issues found in VirtualBox source code checked by PSV St

Post by Serge Kraikov »

I know there should be false positive warnings, and maybe there are no serious bugs,
but most issues are suspicious, for example:

V626 Consider checking for misprints. It's possible that ',' should be replaced by ';'. ldrmemory.cpp 317

Code: Select all

/*@file
 *IPRT-Binary Image Loader, The Memory/Debugger Oriented Parts.*/
RTDECL(int) RTLdrOpenInMemory(....)
{
  if (RT_SUCCESS(rc))
  {
    ....
  }
  else
    pfnDtor(pvUser),                   //<==
  *phLdrMod = NIL_RTLDRMOD;
}
V583 The '?:' operator, regardless of its conditional expression, always returns one and the same value: g_acDaysInMonthsLeap[pTime->u8Month - 1]. time.cpp 453

Code: Select all

static const uint8_t g_acDaysInMonths[12] =
{
  /*Jan Feb Mar Arp May Jun Jul Aug Sep Oct Nov Dec */
    31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};

static const uint8_t g_acDaysInMonthsLeap[12] =
{
  /*Jan Feb Mar Arp May Jun Jul Aug Sep Oct Nov Dec */
    31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};

static PRTTIME rtTimeNormalizeInternal(PRTTIME pTime)
{
  ....
  unsigned cDaysInMonth = fLeapYear
    ? g_acDaysInMonthsLeap[pTime->u8Month - 1]          //<==
    : g_acDaysInMonthsLeap[pTime->u8Month - 1];         //<==
  ....
}
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: issues found in VirtualBox source code checked by PSV St

Post by mpack »

I agree, that comma looks suspicious given the indentation of the next line.

This is a user forum. Perhaps you should raise this on the developer mailing list rather than here.
frank
Oracle Corporation
Posts: 3362
Joined: 7. Jun 2007, 09:11
Primary OS: Debian Sid
VBox Version: PUEL
Guest OSses: Linux, Windows
Location: Dresden, Germany
Contact:

Re: issues found in VirtualBox source code checked by PSV St

Post by frank »

Thank you for this notification. We went through these issues and fixed most of them. I don't think there was any serious issue (some of the issues reported in HostDrivers/Support were already fixed after 4.3.16) but nevertheless it makes sense to fix them. VBox 4.3.18 will contain a part of these fixes.

Thanks again!
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: issues found in VirtualBox source code checked by PSV St

Post by mpack »

Frank, did you see the similar topic in the beta area?
frank
Oracle Corporation
Posts: 3362
Joined: 7. Jun 2007, 09:11
Primary OS: Debian Sid
VBox Version: PUEL
Guest OSses: Linux, Windows
Location: Dresden, Germany
Contact:

Re: issues found in VirtualBox source code checked by PSV St

Post by frank »

No, I didn't but these are the same reports AFAICS.
Post Reply