From 995f8b003c07f34a611e70ce2cb5550215c8082c Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Fri, 13 Mar 2015 21:21:10 +0000 Subject: Fix several bugs found by Clang. Note few patches were obtained from upstream. Other patches were submitted to upstream. --- emulators/virtualbox-ose-additions/Makefile | 2 +- emulators/virtualbox-ose/Makefile | 2 +- .../files/patch-include-VBox-com-array.h | 29 ++++++++++++++++++++++ .../files/patch-include-VBox-vmm-cpumctx.h | 11 ++++++++ .../files/patch-src-VBox-Devices-Input-PS2M.cpp | 13 ++++++++++ .../files/patch-src-VBox-Devices-USB-DevOHCI.cpp | 11 ++++++++ ...Box-Frontends-VBoxManage-VBoxManageModifyVM.cpp | 11 ++++++++ ...ds-VirtualBox-src-runtime-UIKeyboardHandler.cpp | 20 +++++++++++++++ ...patch-src-VBox-Main-src-client-ConsoleImpl2.cpp | 22 ++++++++-------- ...-VBox-Main-src-server-freebsd-NetIf-freebsd.cpp | 17 +++++++++++++ ...-src-VBox-Runtime-common-checksum-manifest3.cpp | 11 ++++++++ ...-src-VBox-Runtime-common-dbg-dbgmodcodeview.cpp | 11 ++++++++ ...VBox-Runtime-common-ldr-ldrELFRelocatable.cpp.h | 11 ++++++++ .../files/patch-src-VBox-VMM-VMMR3-CPUMR3CpuId.cpp | 27 ++++++++++++++++++++ .../files/patch-src-VBox-VMM-VMMR3-PDMDriver.cpp | 15 +++++++++++ 15 files changed, 199 insertions(+), 14 deletions(-) create mode 100644 emulators/virtualbox-ose/files/patch-include-VBox-com-array.h create mode 100644 emulators/virtualbox-ose/files/patch-include-VBox-vmm-cpumctx.h create mode 100644 emulators/virtualbox-ose/files/patch-src-VBox-Devices-Input-PS2M.cpp create mode 100644 emulators/virtualbox-ose/files/patch-src-VBox-Devices-USB-DevOHCI.cpp create mode 100644 emulators/virtualbox-ose/files/patch-src-VBox-Frontends-VBoxManage-VBoxManageModifyVM.cpp create mode 100644 emulators/virtualbox-ose/files/patch-src-VBox-Frontends-VirtualBox-src-runtime-UIKeyboardHandler.cpp create mode 100644 emulators/virtualbox-ose/files/patch-src-VBox-Main-src-server-freebsd-NetIf-freebsd.cpp create mode 100644 emulators/virtualbox-ose/files/patch-src-VBox-Runtime-common-checksum-manifest3.cpp create mode 100644 emulators/virtualbox-ose/files/patch-src-VBox-Runtime-common-dbg-dbgmodcodeview.cpp create mode 100644 emulators/virtualbox-ose/files/patch-src-VBox-Runtime-common-ldr-ldrELFRelocatable.cpp.h create mode 100644 emulators/virtualbox-ose/files/patch-src-VBox-VMM-VMMR3-CPUMR3CpuId.cpp create mode 100644 emulators/virtualbox-ose/files/patch-src-VBox-VMM-VMMR3-PDMDriver.cpp (limited to 'emulators') diff --git a/emulators/virtualbox-ose-additions/Makefile b/emulators/virtualbox-ose-additions/Makefile index fc0cbabfa286..5508d2973dd7 100644 --- a/emulators/virtualbox-ose-additions/Makefile +++ b/emulators/virtualbox-ose-additions/Makefile @@ -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/ \ diff --git a/emulators/virtualbox-ose/Makefile b/emulators/virtualbox-ose/Makefile index 3febf2ad43b3..fb2dcb064504 100644 --- a/emulators/virtualbox-ose/Makefile +++ b/emulators/virtualbox-ose/Makefile @@ -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/ \ diff --git a/emulators/virtualbox-ose/files/patch-include-VBox-com-array.h b/emulators/virtualbox-ose/files/patch-include-VBox-com-array.h new file mode 100644 index 000000000000..f4ee788e799d --- /dev/null +++ b/emulators/virtualbox-ose/files/patch-include-VBox-com-array.h @@ -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]; + } + diff --git a/emulators/virtualbox-ose/files/patch-include-VBox-vmm-cpumctx.h b/emulators/virtualbox-ose/files/patch-include-VBox-vmm-cpumctx.h new file mode 100644 index 000000000000..001f3f9a16b5 --- /dev/null +++ b/emulators/virtualbox-ose/files/patch-include-VBox-vmm-cpumctx.h @@ -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 \ diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Devices-Input-PS2M.cpp b/emulators/virtualbox-ose/files/patch-src-VBox-Devices-Input-PS2M.cpp new file mode 100644 index 000000000000..1a7d3040848c --- /dev/null +++ b/emulators/virtualbox-ose/files/patch-src-VBox-Devices-Input-PS2M.cpp @@ -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. */ diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Devices-USB-DevOHCI.cpp b/emulators/virtualbox-ose/files/patch-src-VBox-Devices-USB-DevOHCI.cpp new file mode 100644 index 000000000000..4c6e66f3fbf4 --- /dev/null +++ b/emulators/virtualbox-ose/files/patch-src-VBox-Devices-USB-DevOHCI.cpp @@ -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); + } + } diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Frontends-VBoxManage-VBoxManageModifyVM.cpp b/emulators/virtualbox-ose/files/patch-src-VBox-Frontends-VBoxManage-VBoxManageModifyVM.cpp new file mode 100644 index 000000000000..34e6943432ba --- /dev/null +++ b/emulators/virtualbox-ose/files/patch-src-VBox-Frontends-VBoxManage-VBoxManageModifyVM.cpp @@ -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) diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Frontends-VirtualBox-src-runtime-UIKeyboardHandler.cpp b/emulators/virtualbox-ose/files/patch-src-VBox-Frontends-VirtualBox-src-runtime-UIKeyboardHandler.cpp new file mode 100644 index 000000000000..fe412a78387c --- /dev/null +++ b/emulators/virtualbox-ose/files/patch-src-VBox-Frontends-VirtualBox-src-runtime-UIKeyboardHandler.cpp @@ -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) + { diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-client-ConsoleImpl2.cpp b/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-client-ConsoleImpl2.cpp index 5297d38f48a6..332db3d68e09 100644 --- a/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-client-ConsoleImpl2.cpp +++ b/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-client-ConsoleImpl2.cpp @@ -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; } diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-server-freebsd-NetIf-freebsd.cpp b/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-server-freebsd-NetIf-freebsd.cpp new file mode 100644 index 000000000000..15d5c4169bd1 --- /dev/null +++ b/emulators/virtualbox-ose/files/patch-src-VBox-Main-src-server-freebsd-NetIf-freebsd.cpp @@ -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 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); + } diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-common-checksum-manifest3.cpp b/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-common-checksum-manifest3.cpp new file mode 100644 index 000000000000..4c1976dbe4ff --- /dev/null +++ b/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-common-checksum-manifest3.cpp @@ -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. diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-common-dbg-dbgmodcodeview.cpp b/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-common-dbg-dbgmodcodeview.cpp new file mode 100644 index 000000000000..1f5f25551752 --- /dev/null +++ b/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-common-dbg-dbgmodcodeview.cpp @@ -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; + } + } diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-common-ldr-ldrELFRelocatable.cpp.h b/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-common-ldr-ldrELFRelocatable.cpp.h new file mode 100644 index 000000000000..36cdd038c6fd --- /dev/null +++ b/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-common-ldr-ldrELFRelocatable.cpp.h @@ -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 diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-VMM-VMMR3-CPUMR3CpuId.cpp b/emulators/virtualbox-ose/files/patch-src-VBox-VMM-VMMR3-CPUMR3CpuId.cpp new file mode 100644 index 000000000000..f503e5052592 --- /dev/null +++ b/emulators/virtualbox-ose/files/patch-src-VBox-VMM-VMMR3-CPUMR3CpuId.cpp @@ -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: diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-VMM-VMMR3-PDMDriver.cpp b/emulators/virtualbox-ose/files/patch-src-VBox-VMM-VMMR3-PDMDriver.cpp new file mode 100644 index 000000000000..87fb98872214 --- /dev/null +++ b/emulators/virtualbox-ose/files/patch-src-VBox-VMM-VMMR3-PDMDriver.cpp @@ -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); + } + } + /* -- cgit v1.2.3