Bug 797316 - Fix -Werror=conversion-null errors in Windows-only code (ipc/ part) r=bent
authorJacek Caban <jacek@codeweavers.com>
Thu, 04 Oct 2012 10:32:45 +0200
changeset 115528 aaefd3bb4dba636fd43ec9cf15fa6cb59c464ccc
parent 115527 65b1536aee04e6949052c021abe213670687f280
child 115529 bd36f348362baf804d4382210b2fa4aa314dcd84
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs797316
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 797316 - Fix -Werror=conversion-null errors in Windows-only code (ipc/ part) r=bent
ipc/chromium/src/base/message_pump_win.cc
ipc/chromium/src/base/platform_thread_win.cc
ipc/glue/CrossProcessMutex_windows.cpp
ipc/glue/SyncChannel.cpp
ipc/glue/WindowsMessageLoop.cpp
--- a/ipc/chromium/src/base/message_pump_win.cc
+++ b/ipc/chromium/src/base/message_pump_win.cc
@@ -96,17 +96,17 @@ void MessagePumpForUI::ScheduleWork() {
   if (InterlockedExchange(&have_work_, 1))
     return;  // Someone else continued the pumping.
 
   // Make sure the MessagePump does some work for us.
   PostMessage(message_hwnd_, kMsgHaveWork, reinterpret_cast<WPARAM>(this), 0);
 
   // In order to wake up any cross-process COM calls which may currently be
   // pending on the main thread, we also have to post a UI message.
-  PostMessage(message_hwnd_, WM_NULL, NULL, 0);
+  PostMessage(message_hwnd_, WM_NULL, 0, 0);
 }
 
 void MessagePumpForUI::ScheduleDelayedWork(const Time& delayed_work_time) {
   //
   // We would *like* to provide high resolution timers.  Windows timers using
   // SetTimer() have a 10ms granularity.  We have to use WM_TIMER as a wakeup
   // mechanism because the application can enter modal windows loops where it
   // is not running our MessageLoop; the only way to have our timers fire in
@@ -411,17 +411,17 @@ bool MessagePumpForUI::ProcessPumpReplac
   ScheduleWork();
   return ProcessMessageHelper(msg);
 }
 
 //-----------------------------------------------------------------------------
 // MessagePumpForIO public:
 
 MessagePumpForIO::MessagePumpForIO() {
-  port_.Set(CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, NULL, 1));
+  port_.Set(CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1));
   DCHECK(port_.IsValid());
 }
 
 void MessagePumpForIO::ScheduleWork() {
   if (InterlockedExchange(&have_work_, 1))
     return;  // Someone else continued the pumping.
 
   // Make sure the MessagePump does some work for us.
@@ -525,17 +525,17 @@ bool MessagePumpForIO::WaitForIOCompleti
     delete item.context;
   }
   return true;
 }
 
 // Asks the OS for another IO completion result.
 bool MessagePumpForIO::GetIOItem(DWORD timeout, IOItem* item) {
   memset(item, 0, sizeof(*item));
-  ULONG_PTR key = NULL;
+  ULONG_PTR key = 0;
   OVERLAPPED* overlapped = NULL;
   if (!GetQueuedCompletionStatus(port_.Get(), &item->bytes_transfered, &key,
                                  &overlapped, timeout)) {
     if (!overlapped)
       return false;  // Nothing in the queue.
     item->error = GetLastError();
     item->bytes_transfered = 0;
   }
--- a/ipc/chromium/src/base/platform_thread_win.cc
+++ b/ipc/chromium/src/base/platform_thread_win.cc
@@ -19,17 +19,17 @@ typedef struct tagTHREADNAME_INFO {
   DWORD dwThreadID;  // Thread ID (-1=caller thread).
   DWORD dwFlags;  // Reserved for future use, must be zero.
 } THREADNAME_INFO;
 
 DWORD __stdcall ThreadFunc(void* closure) {
   PlatformThread::Delegate* delegate =
       static_cast<PlatformThread::Delegate*>(closure);
   delegate->ThreadMain();
-  return NULL;
+  return 0;
 }
 
 }  // namespace
 
 // static
 PlatformThreadId PlatformThread::CurrentId() {
   return GetCurrentThreadId();
 }
--- a/ipc/glue/CrossProcessMutex_windows.cpp
+++ b/ipc/glue/CrossProcessMutex_windows.cpp
@@ -58,17 +58,17 @@ CrossProcessMutex::Unlock()
 }
 
 CrossProcessMutexHandle
 CrossProcessMutex::ShareToProcess(ProcessHandle aHandle)
 {
   HANDLE newHandle;
   bool succeeded = ::DuplicateHandle(GetCurrentProcessHandle(),
                                      mMutex, aHandle, &newHandle,
-                                     NULL, FALSE, DUPLICATE_SAME_ACCESS);
+                                     0, FALSE, DUPLICATE_SAME_ACCESS);
 
   if (!succeeded) {
     return NULL;
   }
 
   return newHandle;
 }
 
--- a/ipc/glue/SyncChannel.cpp
+++ b/ipc/glue/SyncChannel.cpp
@@ -22,24 +22,24 @@ struct RunnableMethodTraits<mozilla::ipc
 
 namespace mozilla {
 namespace ipc {
 
 const int32_t SyncChannel::kNoTimeout = INT32_MIN;
 
 SyncChannel::SyncChannel(SyncListener* aListener)
   : AsyncChannel(aListener)
+#ifdef OS_WIN
+  , mTopFrame(NULL)
+#endif
   , mPendingReply(0)
   , mProcessingSyncMessage(false)
   , mNextSeqno(0)
   , mInTimeoutSecondHalf(false)
   , mTimeoutMs(kNoTimeout)
-#ifdef OS_WIN
-  , mTopFrame(NULL)
-#endif
 {
     MOZ_COUNT_CTOR(SyncChannel);
 #ifdef OS_WIN
     mEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
     NS_ASSERTION(mEvent, "CreateEvent failed! Nothing is going to work!");
 #endif
 }
 
--- a/ipc/glue/WindowsMessageLoop.cpp
+++ b/ipc/glue/WindowsMessageLoop.cpp
@@ -87,17 +87,16 @@ nsTArray<HWND>* gNeuteredWindows = nullp
 
 typedef nsTArray<nsAutoPtr<DeferredMessage> > DeferredMessageArray;
 DeferredMessageArray* gDeferredMessages = nullptr;
 
 HHOOK gDeferredGetMsgHook = NULL;
 HHOOK gDeferredCallWndProcHook = NULL;
 
 DWORD gUIThreadId = 0;
-int gEventLoopDepth = 0;
 static UINT sAppShellGeckoMsgId;
 
 LRESULT CALLBACK
 DeferredMessageHook(int nCode,
                     WPARAM wParam,
                     LPARAM lParam)
 {
   // XXX This function is called for *both* the WH_CALLWNDPROC hook and the
@@ -458,17 +457,17 @@ RestoreWindowProcedure(HWND hWnd)
 {
   NS_ASSERTION(WindowIsDeferredWindow(hWnd),
                "Not a deferred window, this shouldn't be in our list!");
   LONG_PTR oldWndProc = (LONG_PTR)GetProp(hWnd, kOldWndProcProp);
   if (oldWndProc) {
     NS_ASSERTION(oldWndProc != (LONG_PTR)NeuteredWindowProc,
                  "This shouldn't be possible!");
 
-    LONG_PTR currentWndProc =
+    DebugOnly<LONG_PTR> currentWndProc =
       SetWindowLongPtr(hWnd, GWLP_WNDPROC, oldWndProc);
     NS_ASSERTION(currentWndProc == (LONG_PTR)NeuteredWindowProc,
                  "This should never be switched out from under us!");
   }
   RemoveProp(hWnd, kOldWndProcProp);
 }
 
 LRESULT CALLBACK
@@ -705,17 +704,17 @@ SyncChannel::WaitForNotify()
 
   NS_ASSERTION(mTopFrame && !mTopFrame->mRPC,
                "Top frame is not a sync frame!");
 
   MonitorAutoUnlock unlock(*mMonitor);
 
   bool timedout = false;
 
-  UINT_PTR timerId = NULL;
+  UINT_PTR timerId = 0;
   TimeoutData timeoutData = { 0 };
 
   if (mTimeoutMs != kNoTimeout) {
     InitTimeoutData(&timeoutData, mTimeoutMs);
 
     // We only do this to ensure that we won't get stuck in
     // MsgWaitForMultipleObjects below.
     timerId = SetTimer(NULL, 0, mTimeoutMs, NULL);
@@ -832,17 +831,17 @@ RPCChannel::WaitForNotify()
 
   NS_ASSERTION(mTopFrame && mTopFrame->mRPC,
                "Top frame is not a sync frame!");
 
   MonitorAutoUnlock unlock(*mMonitor);
 
   bool timedout = false;
 
-  UINT_PTR timerId = NULL;
+  UINT_PTR timerId = 0;
   TimeoutData timeoutData = { 0 };
 
   // windowHook is used as a flag variable for the loop below: if it is set
   // and we start to spin a nested event loop, we need to clear the hook and
   // process deferred/pending messages.
   // If windowHook is NULL, SyncChannel::IsPumpingMessages should be false.
   HHOOK windowHook = NULL;
 
@@ -852,17 +851,17 @@ RPCChannel::WaitForNotify()
 
     if (mTopFrame->mSpinNestedEvents) {
       if (windowHook) {
         UnhookWindowsHookEx(windowHook);
         windowHook = NULL;
 
         if (timerId) {
           KillTimer(NULL, timerId);
-          timerId = NULL;
+          timerId = 0;
         }
 
         // Used by widget to assert on incoming native events
         SyncChannel::SetIsPumpingMessages(false);
 
         // Unhook any neutered windows procedures so messages can be delievered
         // normally.
         UnhookNeuteredWindows();
@@ -1037,17 +1036,17 @@ DeferredSettingChangeMessage::DeferredSe
 {
   NS_ASSERTION(aMessage == WM_SETTINGCHANGE, "Wrong message type!");
   if (aLParam) {
     lParamString = _wcsdup(reinterpret_cast<const wchar_t*>(aLParam));
     lParam = reinterpret_cast<LPARAM>(lParamString);
   }
   else {
     lParamString = NULL;
-    lParam = NULL;
+    lParam = 0;
   }
 }
 
 DeferredSettingChangeMessage::~DeferredSettingChangeMessage()
 {
   free(lParamString);
 }