diff --git a/gfx/layers/d3d9/CompositorD3D9.cpp b/gfx/layers/d3d9/CompositorD3D9.cpp index c8b1515a5307..be92764754ce 100644 --- a/gfx/layers/d3d9/CompositorD3D9.cpp +++ b/gfx/layers/d3d9/CompositorD3D9.cpp @@ -489,7 +489,6 @@ CompositorD3D9::SetMask(const EffectChain &aEffectChain, uint32_t aMaskTexture) TextureSourceD3D9 *source = maskEffect->mMaskTexture->AsSourceD3D9(); - MOZ_ASSERT(aMaskTexture >= 0); device()->SetTexture(aMaskTexture, source->GetD3D9Texture()); const gfx::Matrix4x4& maskTransform = maskEffect->mMaskTransform; diff --git a/hal/windows/WindowsGamepad.cpp b/hal/windows/WindowsGamepad.cpp index a1266c97a37e..3419971d0906 100644 --- a/hal/windows/WindowsGamepad.cpp +++ b/hal/windows/WindowsGamepad.cpp @@ -50,6 +50,8 @@ const uint32_t kDevicesChangedStableDelay = 200; // poll it periodically. 50ms is arbitrarily chosen. const uint32_t kXInputPollInterval = 50; +const UINT kRawInputError = (UINT)-1; + #ifndef XUSER_MAX_COUNT #define XUSER_MAX_COUNT 4 #endif @@ -178,7 +180,7 @@ bool GetPreparsedData(HANDLE handle, nsTArray& data) { UINT size; - if (GetRawInputDeviceInfo(handle, RIDI_PREPARSEDDATA, nullptr, &size) < 0) { + if (GetRawInputDeviceInfo(handle, RIDI_PREPARSEDDATA, nullptr, &size) == kRawInputError) { return false; } data.SetLength(size); @@ -418,13 +420,13 @@ WindowsGamepadService::ScanForRawInputDevices() UINT numDevices; if (GetRawInputDeviceList(nullptr, &numDevices, sizeof(RAWINPUTDEVICELIST)) - == -1) { + == kRawInputError) { return; } nsTArray devices(numDevices); devices.SetLength(numDevices); if (GetRawInputDeviceList(devices.Elements(), &numDevices, - sizeof(RAWINPUTDEVICELIST)) == -1) { + sizeof(RAWINPUTDEVICELIST)) == kRawInputError) { return; } @@ -631,7 +633,7 @@ WindowsGamepadService::GetRawGamepad(HANDLE handle) RID_DEVICE_INFO rdi = {}; UINT size = rdi.cbSize = sizeof(RID_DEVICE_INFO); - if (GetRawInputDeviceInfo(handle, RIDI_DEVICEINFO, &rdi, &size) < 0) { + if (GetRawInputDeviceInfo(handle, RIDI_DEVICEINFO, &rdi, &size) == kRawInputError) { return false; } // Ensure that this is a device we care about @@ -642,14 +644,13 @@ WindowsGamepadService::GetRawGamepad(HANDLE handle) Gamepad gamepad = {}; // Device name is a mostly-opaque string. - if (GetRawInputDeviceInfo(handle, RIDI_DEVICENAME, nullptr, &size) < 0) { + if (GetRawInputDeviceInfo(handle, RIDI_DEVICENAME, nullptr, &size) == kRawInputError) { return false; } nsTArray devname(size); devname.SetLength(size); - if (GetRawInputDeviceInfo(handle, RIDI_DEVICENAME, devname.Elements(), &size) - <= 0) { + if (GetRawInputDeviceInfo(handle, RIDI_DEVICENAME, devname.Elements(), &size) == kRawInputError) { return false; } @@ -667,7 +668,7 @@ WindowsGamepadService::GetRawGamepad(HANDLE handle) size = sizeof(name); nsTArray gamepad_name; HANDLE hid_handle = CreateFile(devname.Elements(), GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL); + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hid_handle) { if (mHID.mHidD_GetProductString(hid_handle, &name, size)) { int bytes = WideCharToMultiByte(CP_UTF8, 0, name, -1, nullptr, 0, nullptr, @@ -786,7 +787,7 @@ WindowsGamepadService::HandleRawInput(HRAWINPUT handle) nsTArray data(size); data.SetLength(size); if (GetRawInputData(handle, RID_INPUT, data.Elements(), &size, - sizeof(RAWINPUTHEADER)) < 0) { + sizeof(RAWINPUTHEADER)) == kRawInputError) { return false; } PRAWINPUT raw = reinterpret_cast(data.Elements()); diff --git a/ipc/chromium/src/base/waitable_event_win.cc b/ipc/chromium/src/base/waitable_event_win.cc index ac85c5c80d64..21ee0a900140 100644 --- a/ipc/chromium/src/base/waitable_event_win.cc +++ b/ipc/chromium/src/base/waitable_event_win.cc @@ -86,7 +86,7 @@ size_t WaitableEvent::WaitMany(WaitableEvent** events, size_t count) { WaitForMultipleObjects(count, handles, FALSE, // don't wait for all the objects INFINITE); // no timeout - if (result < WAIT_OBJECT_0 || result >= WAIT_OBJECT_0 + count) { + if (result >= WAIT_OBJECT_0 + count) { NOTREACHED() << "WaitForMultipleObjects failed: " << GetLastError(); return 0; } diff --git a/widget/windows/KeyboardLayout.cpp b/widget/windows/KeyboardLayout.cpp index e248235b9c7c..162e4beffc15 100644 --- a/widget/windows/KeyboardLayout.cpp +++ b/widget/windows/KeyboardLayout.cpp @@ -606,7 +606,7 @@ UniCharsAndModifiers VirtualKey::GetNativeUniChars(ShiftState aShiftState) const { #ifdef DEBUG - if (aShiftState < 0 || aShiftState >= ArrayLength(mShiftStates)) { + if (aShiftState >= ArrayLength(mShiftStates)) { nsPrintfCString warning("Shift state is out of range: " "aShiftState=%d, ArrayLength(mShiftState)=%d", aShiftState, ArrayLength(mShiftStates)); @@ -2259,8 +2259,8 @@ KeyboardLayout::LoadLayout(HKL aLayout) static const UINT kMapType = IsVistaOrLater() ? MAPVK_VSC_TO_VK_EX : MAPVK_VSC_TO_VK; PR_LOG(sKeyboardLayoutLogger, PR_LOG_DEBUG, - ("Logging virtual keycode values for scancode (0x%08X)...", - reinterpret_cast(mKeyboardLayout))); + ("Logging virtual keycode values for scancode (0x%p)...", + mKeyboardLayout)); for (uint32_t i = 0; i < ArrayLength(kExtendedScanCode); i++) { for (uint32_t j = 1; j <= 0xFF; j++) { UINT scanCode = kExtendedScanCode[i] + j; diff --git a/widget/windows/WindowHook.cpp b/widget/windows/WindowHook.cpp index 2c3a533f34bf..8e87a3a55efa 100644 --- a/widget/windows/WindowHook.cpp +++ b/widget/windows/WindowHook.cpp @@ -94,7 +94,7 @@ WindowHook::DeleteIfEmpty(MessageData *data) { MessageDataArray::index_type idx; idx = data - mMessageData.Elements(); - NS_ASSERTION(idx >= 0 && idx < mMessageData.Length(), "Attempted to delete MessageData that doesn't belong to this array!"); + NS_ASSERTION(idx < mMessageData.Length(), "Attempted to delete MessageData that doesn't belong to this array!"); mMessageData.RemoveElementAt(idx); } diff --git a/widget/windows/nsDragService.cpp b/widget/windows/nsDragService.cpp index 4d9016d612b8..96c7c1c7a20d 100644 --- a/widget/windows/nsDragService.cpp +++ b/widget/windows/nsDragService.cpp @@ -424,7 +424,7 @@ nsDragService::GetData(nsITransferable * aTransferable, uint32_t anItem) // multiple items, use |anItem| as an index into our collection nsDataObjCollection * dataObjCol = GetDataObjCollection(mDataObject); uint32_t cnt = dataObjCol->GetNumDataObjects(); - if (anItem >= 0 && anItem < cnt) { + if (anItem < cnt) { IDataObject * dataObj = dataObjCol->GetDataObjectAt(anItem); dataFound = nsClipboard::GetDataFromDataObject(dataObj, 0, nullptr, aTransferable);