Fix several bugs found by Clang. Note few patches were obtained from

upstream.  Other patches were submitted to upstream.
This commit is contained in:
Jung-uk Kim 2015-03-13 21:21:10 +00:00
parent b767ec123f
commit 995f8b003c
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=381235
15 changed files with 199 additions and 14 deletions

View file

@ -3,7 +3,7 @@
PORTNAME= virtualbox-ose
DISTVERSION= 4.3.24
PORTREVISION= 2
PORTREVISION= 3
CATEGORIES= emulators
MASTER_SITES= http://download.virtualbox.org/virtualbox/${DISTVERSION}/ \
http://tmp.chruetertee.ch/ \

View file

@ -3,7 +3,7 @@
PORTNAME= virtualbox-ose
DISTVERSION= 4.3.24
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= emulators
MASTER_SITES= http://download.virtualbox.org/virtualbox/${DISTVERSION}/ \
http://tmp.chruetertee.ch/ \

View file

@ -0,0 +1,29 @@
--- include/VBox/com/array.h.orig 2015-03-02 10:06:38.000000000 -0500
+++ include/VBox/com/array.h 2015-03-12 17:52:37.107759000 -0400
@@ -908,12 +908,12 @@
*/
const T operator[] (size_t aIdx) const
{
- AssertReturn(m.arr != NULL, *((T *)NULL));
- AssertReturn(aIdx < size(), *((T *)NULL));
+ Assert(m.arr != NULL);
+ Assert(aIdx < size());
#ifdef VBOX_WITH_XPCOM
return m.arr[aIdx];
#else
- AssertReturn(m.raw != NULL, *((T *)NULL));
+ Assert(m.raw != NULL);
return m.raw[aIdx];
#endif
}
@@ -1409,8 +1409,8 @@
*/
const nsID &operator[] (size_t aIdx) const
{
- AssertReturn(m.arr != NULL, **((const nsID * *)NULL));
- AssertReturn(aIdx < size(), **((const nsID * *)NULL));
+ Assert(m.arr != NULL);
+ Assert(aIdx < size());
return *m.arr[aIdx];
}

View file

@ -0,0 +1,11 @@
--- include/VBox/vmm/cpumctx.h.orig 2015-03-12 18:53:45.762704000 -0400
+++ include/VBox/vmm/cpumctx.h 2015-03-12 18:56:23.765105000 -0400
@@ -84,7 +84,7 @@
# define CPUMSELREG_ARE_HIDDEN_PARTS_VALID(a_pVCpu, a_pSelReg) \
( ((a_pSelReg)->fFlags & CPUMSELREG_FLAGS_VALID) \
&& ( (a_pSelReg)->ValidSel == (a_pSelReg)->Sel \
- || ( (a_pVCpu) /*!= NULL*/ \
+ || ( ((a_pVCpu) != NULL) \
&& (a_pSelReg)->ValidSel == ((a_pSelReg)->Sel & X86_SEL_MASK_OFF_RPL) \
&& ((a_pSelReg)->Sel & X86_SEL_RPL) == 1 \
&& ((a_pSelReg)->ValidSel & X86_SEL_RPL) == 0 \

View file

@ -0,0 +1,13 @@
--- src/VBox/Devices/Input/PS2M.cpp.orig 2015-03-02 10:09:15.000000000 -0500
+++ src/VBox/Devices/Input/PS2M.cpp 2015-03-12 18:44:38.787177000 -0400
@@ -712,8 +712,8 @@
int8_t dX, dY, dZ;
/* Clamp the accumulated delta values to the allowed range. */
- dX = RT_MIN(RT_MAX(pThis->iAccumX, -256), 255);
- dY = RT_MIN(RT_MAX(pThis->iAccumY, -256), 255);
+ dX = RT_MIN(RT_MAX(pThis->iAccumX, -128), 127);
+ dY = RT_MIN(RT_MAX(pThis->iAccumY, -128), 127);
dZ = RT_MIN(RT_MAX(pThis->iAccumZ, -8), 7);
/* Start with the sync bit and buttons 1-3. */

View file

@ -0,0 +1,11 @@
--- src/VBox/Devices/USB/DevOHCI.cpp.orig 2015-03-02 10:09:35.000000000 -0500
+++ src/VBox/Devices/USB/DevOHCI.cpp 2015-03-12 16:15:51.519656000 -0400
@@ -3717,7 +3717,7 @@
pUrb = pThis->aInFlight[i].pUrb;
if (pThis->aInFlight[i].fInactive
&& pUrb->enmState == VUSBURBSTATE_IN_FLIGHT
- && !pUrb->enmType == VUSBXFERTYPE_CTRL)
+ && pUrb->enmType != VUSBXFERTYPE_CTRL)
pThis->RootHub.pIRhConn->pfnCancelUrbsEp(pThis->RootHub.pIRhConn, pUrb);
}
}

View file

@ -0,0 +1,11 @@
--- src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp.orig 2015-03-02 10:09:37.000000000 -0500
+++ src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp 2015-03-12 18:33:09.348465000 -0400
@@ -1732,7 +1732,7 @@
CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
uint32_t aliasMode = 0;
- if (!RTStrCmp(ValueUnion.psz, "default") == 0)
+ if (RTStrCmp(ValueUnion.psz, "default") != 0)
{
char *token = (char *)ValueUnion.psz;
while(token)

View file

@ -0,0 +1,20 @@
--- src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp.orig 2015-03-02 10:09:41.000000000 -0500
+++ src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp 2015-03-12 17:11:33.029804000 -0400
@@ -622,7 +622,7 @@
unsigned scan = handleXKeyEvent(pEvent);
/* Scancodes 0x00 (no valid translation) and 0x80 are ignored: */
- if (!scan & 0x7F)
+ if (!(scan & 0x7F))
{
fResult = true;
break;
@@ -1603,7 +1603,7 @@
{
KeySym ks = wrapXkbKeycodeToKeysym(pDisplay, keyCode, i, 0);
char symbol = 0;
- if (!XkbTranslateKeySym(pDisplay, &ks, 0, &symbol, 1, NULL) == 1)
+ if (XkbTranslateKeySym(pDisplay, &ks, 0, &symbol, 1, NULL) == 0)
symbol = 0;
if (symbol)
{

View file

@ -1,36 +1,34 @@
--- src/VBox/Main/src-client/ConsoleImpl2.cpp.orig 2013-09-06 08:30:10.000000000 -0400
+++ src/VBox/Main/src-client/ConsoleImpl2.cpp 2013-09-12 13:03:34.000000000 -0400
@@ -4031,12 +4031,13 @@
--- src/VBox/Main/src-client/ConsoleImpl2.cpp.orig 2015-03-02 10:09:53.000000000 -0500
+++ src/VBox/Main/src-client/ConsoleImpl2.cpp 2015-03-13 12:49:53.780376000 -0400
@@ -4447,12 +4447,12 @@
}
}
- Assert((int)maTapFD[uInstance] >= 0);
- if ((int)maTapFD[uInstance] >= 0)
+ const int fd = (int)(uintptr_t)maTapFD[uInstance];
+ Assert(fd >= 0);
+ if (fd >= 0)
+ Assert((intptr_t)maTapFD[uInstance] >= 0);
+ if ((intptr_t)maTapFD[uInstance] >= 0)
{
InsertConfigString(pLunL0, "Driver", "HostInterface");
InsertConfigNode(pLunL0, "Config", &pCfg);
- InsertConfigInteger(pCfg, "FileHandle", maTapFD[uInstance]);
+ InsertConfigInteger(pCfg, "FileHandle", fd);
+ InsertConfigInteger(pCfg, "FileHandle", (intptr_t)maTapFD[uInstance]);
}
#elif defined(VBOX_WITH_NETFLT)
@@ -4230,12 +4231,13 @@
@@ -4646,12 +4646,12 @@
}
}
- Assert((int)maTapFD[uInstance] >= 0);
- if ((int)maTapFD[uInstance] >= 0)
+ const int fd = (int)(uintptr_t)maTapFD[uInstance];
+ Assert(fd >= 0);
+ if (fd >= 0)
+ Assert((intptr_t)maTapFD[uInstance] >= 0);
+ if ((intptr_t)maTapFD[uInstance] >= 0)
{
InsertConfigString(pLunL0, "Driver", "HostInterface");
InsertConfigNode(pLunL0, "Config", &pCfg);
- InsertConfigInteger(pCfg, "FileHandle", maTapFD[uInstance]);
+ InsertConfigInteger(pCfg, "FileHandle", fd);
+ InsertConfigInteger(pCfg, "FileHandle", (intptr_t)maTapFD[uInstance]);
}
break;
}

View file

@ -0,0 +1,17 @@
--- src/VBox/Main/src-server/freebsd/NetIf-freebsd.cpp.orig 2015-03-02 10:09:55.000000000 -0500
+++ src/VBox/Main/src-server/freebsd/NetIf-freebsd.cpp 2015-03-12 19:23:15.950051000 -0400
@@ -290,12 +290,14 @@
ComObjPtr<HostNetworkInterface> IfObj;
IfObj.createObject();
if (SUCCEEDED(IfObj->init(Bstr(pNew->szName), enmType, pNew)))
+ {
/* Make sure the default interface gets to the beginning. */
if ( fDefaultIfaceExistent
&& pIfMsg->ifm_index == u16DefaultIface)
list.push_front(IfObj);
else
list.push_back(IfObj);
+ }
}
RTMemFree(pNew);
}

View file

@ -0,0 +1,11 @@
--- src/VBox/Runtime/common/checksum/manifest3.cpp.orig 2015-03-02 10:09:59.000000000 -0500
+++ src/VBox/Runtime/common/checksum/manifest3.cpp 2015-03-12 15:40:09.008443000 -0400
@@ -427,7 +427,7 @@
uint32_t cRefs = RTManifestRetain(hManifest);
AssertReturn(cRefs != UINT32_MAX, VERR_INVALID_HANDLE);
cRefs = RTVfsIoStrmRetain(hVfsIos);
- AssertReturnStmt(cRefs != UINT32_MAX, VERR_INVALID_HANDLE, RTManifestRelease(hManifest));
+ AssertReturnStmt(cRefs != UINT32_MAX, RTManifestRelease(hManifest), VERR_INVALID_HANDLE);
/*
* Create an instace of the passthru I/O stream.

View file

@ -0,0 +1,11 @@
--- src/VBox/Runtime/common/dbg/dbgmodcodeview.cpp.orig 2015-03-02 10:10:00.000000000 -0500
+++ src/VBox/Runtime/common/dbg/dbgmodcodeview.cpp 2015-03-12 16:22:25.459078000 -0400
@@ -2717,7 +2717,7 @@
{
/* Try the executable in case it has a NBxx tail header. */
rc2 = rtDbgModCvProbeFile(pMod, pMod->pszImgFile, enmArch);
- if (RT_FAILURE(rc2) && (RT_SUCCESS(rc) || VERR_DBG_NO_MATCHING_INTERPRETER))
+ if (RT_FAILURE(rc2) && (RT_SUCCESS(rc) || rc == VERR_DBG_NO_MATCHING_INTERPRETER))
rc = rc2;
}
}

View file

@ -0,0 +1,11 @@
--- src/VBox/Runtime/common/ldr/ldrELFRelocatable.cpp.h.orig 2015-03-02 10:10:00.000000000 -0500
+++ src/VBox/Runtime/common/ldr/ldrELFRelocatable.cpp.h 2015-03-12 15:59:41.932947000 -0400
@@ -249,7 +249,7 @@
}
else
{
- AssertReturn(pSym->st_shndx < pModElf->cSyms || pSym->st_shndx == SHN_ABS, ("%#x\n", pSym->st_shndx));
+ AssertMsg(pSym->st_shndx < pModElf->cSyms || pSym->st_shndx == SHN_ABS, ("%#x\n", pSym->st_shndx));
#if ELF_MODE == 64
SymValue = pSym->st_value;
#endif

View file

@ -0,0 +1,27 @@
--- src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp.orig 2015-03-02 10:10:12.000000000 -0500
+++ src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp 2015-03-12 18:58:11.784386000 -0400
@@ -146,15 +146,15 @@
case 0x06:
switch (bModel)
{
- case 0: kCpumMicroarch_AMD_K7_Palomino;
- case 1: kCpumMicroarch_AMD_K7_Palomino;
- case 2: kCpumMicroarch_AMD_K7_Palomino;
- case 3: kCpumMicroarch_AMD_K7_Spitfire;
- case 4: kCpumMicroarch_AMD_K7_Thunderbird;
- case 6: kCpumMicroarch_AMD_K7_Palomino;
- case 7: kCpumMicroarch_AMD_K7_Morgan;
- case 8: kCpumMicroarch_AMD_K7_Thoroughbred;
- case 10: kCpumMicroarch_AMD_K7_Barton; /* Thorton too. */
+ case 0: return kCpumMicroarch_AMD_K7_Palomino;
+ case 1: return kCpumMicroarch_AMD_K7_Palomino;
+ case 2: return kCpumMicroarch_AMD_K7_Palomino;
+ case 3: return kCpumMicroarch_AMD_K7_Spitfire;
+ case 4: return kCpumMicroarch_AMD_K7_Thunderbird;
+ case 6: return kCpumMicroarch_AMD_K7_Palomino;
+ case 7: return kCpumMicroarch_AMD_K7_Morgan;
+ case 8: return kCpumMicroarch_AMD_K7_Thoroughbred;
+ case 10: return kCpumMicroarch_AMD_K7_Barton; /* Thorton too. */
}
return kCpumMicroarch_AMD_K7_Unknown;
case 0x0f:

View file

@ -0,0 +1,15 @@
--- src/VBox/VMM/VMMR3/PDMDriver.cpp.orig 2015-03-02 10:10:12.000000000 -0500
+++ src/VBox/VMM/VMMR3/PDMDriver.cpp 2015-03-12 20:01:00.170988000 -0400
@@ -512,11 +512,7 @@
AssertLogRelRCReturn(rc, rc);
rc = CFGMR3ReplaceSubTree(*ppNode, pBelowThisCopy);
- if (RT_FAILURE(rc))
- {
- CFGMR3RemoveNode(pBelowThis);
- AssertLogRelReturn(("rc=%Rrc\n", rc), rc);
- }
+ AssertLogRelRCReturnStmt(rc, CFGMR3RemoveNode(pBelowThis), rc);
}
}
/*