Bug 1406380 Fix -Wreorder warnings r=njn, a=IanN CLOSED TREE DONTBUILD SEAMONKEY_2_49_ESR_RELBRANCH
authorTom Ritter <tom@mozilla.com>
Mon, 09 Oct 2017 01:36:36 -0500
branchSEAMONKEY_2_49_ESR_RELBRANCH
changeset 357482 da7709c18e6682fca8db48c207a8aeff77f6c714
parent 357481 76d781cfe6ea057c5042c6ed959cecec8ee59fe1
child 357483 6110ea38bcee80c8089137bb6ea23cc3ecdd5cc3
push id7834
push userfrgrahl@gmx.net
push dateSun, 13 Jan 2019 12:17:02 +0000
treeherdermozilla-esr52@6e4ad8a8f2e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn, IanN
bugs1406380
milestone52.9.1
Bug 1406380 Fix -Wreorder warnings r=njn, a=IanN CLOSED TREE DONTBUILD mozilla-esr52 SEAMONKEY_2_49_ESR_RELBRANCH
dom/gamepad/windows/WindowsGamepad.cpp
dom/media/platforms/wmf/WMFVideoMFTManager.cpp
dom/plugins/ipc/PluginModuleChild.cpp
dom/plugins/ipc/PluginUtilsWin.cpp
--- a/dom/gamepad/windows/WindowsGamepad.cpp
+++ b/dom/gamepad/windows/WindowsGamepad.cpp
@@ -134,38 +134,38 @@ public:
 
   // Used during rescan to find devices that were disconnected.
   bool present;
 
   Gamepad(uint32_t aNumAxes,
           uint32_t aNumButtons,
           bool aHasDpad,
           GamepadType aType) :
+    type(aType),
     numAxes(aNumAxes),
     numButtons(aNumButtons),
     hasDpad(aHasDpad),
-    type(aType),
     present(true)
   {
     buttons.SetLength(numButtons);
     axes.SetLength(numAxes);
   }
 private:
   Gamepad() {}
 };
 
 // Drop this in favor of decltype when we require a new enough SDK.
 typedef void (WINAPI *XInputEnable_func)(BOOL);
 
 // RAII class to wrap loading the XInput DLL
 class XInputLoader {
 public:
   XInputLoader() : module(nullptr),
-                   mXInputEnable(nullptr),
-                   mXInputGetState(nullptr) {
+                   mXInputGetState(nullptr),
+                   mXInputEnable(nullptr) {
     // xinput1_4.dll exists on Windows 8
     // xinput9_1_0.dll exists on Windows 7 and Vista
     // xinput1_3.dll shipped with the DirectX SDK
     const wchar_t* dlls[] = {L"xinput1_4.dll",
                              L"xinput9_1_0.dll",
                              L"xinput1_3.dll"};
     const size_t kNumDLLs = ArrayLength(dlls);
     for (size_t i = 0; i < kNumDLLs; ++i) {
@@ -275,24 +275,24 @@ SupportedUsage(USHORT page, USHORT usage
       return true;
     }
   }
   return false;
 }
 
 class HIDLoader {
 public:
-  HIDLoader() : mModule(LoadLibraryW(L"hid.dll")),
-                mHidD_GetProductString(nullptr),
+  HIDLoader() : mHidD_GetProductString(nullptr),
                 mHidP_GetCaps(nullptr),
                 mHidP_GetButtonCaps(nullptr),
                 mHidP_GetValueCaps(nullptr),
                 mHidP_GetUsages(nullptr),
                 mHidP_GetUsageValue(nullptr),
-                mHidP_GetScaledUsageValue(nullptr)
+                mHidP_GetScaledUsageValue(nullptr),
+                mModule(LoadLibraryW(L"hid.dll"))
   {
     if (mModule) {
       mHidD_GetProductString = reinterpret_cast<decltype(HidD_GetProductString)*>(GetProcAddress(mModule, "HidD_GetProductString"));
       mHidP_GetCaps = reinterpret_cast<decltype(HidP_GetCaps)*>(GetProcAddress(mModule, "HidP_GetCaps"));
       mHidP_GetButtonCaps = reinterpret_cast<decltype(HidP_GetButtonCaps)*>(GetProcAddress(mModule, "HidP_GetButtonCaps"));
       mHidP_GetValueCaps = reinterpret_cast<decltype(HidP_GetValueCaps)*>(GetProcAddress(mModule, "HidP_GetValueCaps"));
       mHidP_GetUsages = reinterpret_cast<decltype(HidP_GetUsages)*>(GetProcAddress(mModule, "HidP_GetUsages"));
       mHidP_GetUsageValue = reinterpret_cast<decltype(HidP_GetUsageValue)*>(GetProcAddress(mModule, "HidP_GetUsageValue"));
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -82,18 +82,18 @@ WMFVideoMFTManager::WMFVideoMFTManager(
                             const VideoInfo& aConfig,
                             layers::KnowsCompositor* aKnowsCompositor,
                             layers::ImageContainer* aImageContainer,
                             bool aDXVAEnabled)
   : mVideoInfo(aConfig)
   , mVideoStride(0)
   , mImageSize(aConfig.mImage)
   , mImageContainer(aImageContainer)
+  , mKnowsCompositor(aKnowsCompositor)
   , mDXVAEnabled(aDXVAEnabled)
-  , mKnowsCompositor(aKnowsCompositor)
   , mNullOutputCount(0)
   , mGotValidOutputAfterNullOutput(false)
   , mGotExcessiveNullOutput(false)
   , mIsValid(true)
   // mVideoStride, mVideoWidth, mVideoHeight, mUseHwAccel are initialized in
   // Init().
 {
   MOZ_COUNT_CTOR(WMFVideoMFTManager);
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -2080,17 +2080,19 @@ SHORT WINAPI PMCGetKeyState(int aVirtKey
 class GetKeyStateTask : public Runnable
 {
     SHORT* mKeyState;
     int mVirtKey;
     HANDLE mSemaphore;
 
 public:
     explicit GetKeyStateTask(int aVirtKey, HANDLE aSemaphore, SHORT* aKeyState) :
-        mVirtKey(aVirtKey), mSemaphore(aSemaphore), mKeyState(aKeyState)
+        mKeyState(aKeyState),
+        mVirtKey(aVirtKey),
+        mSemaphore(aSemaphore)
     {}
 
     NS_IMETHOD Run() override
     {
         PLUGIN_LOG_DEBUG_METHOD;
         AssertPluginThread();
         *mKeyState = PMCGetKeyState(mVirtKey);
         if (!ReleaseSemaphore(mSemaphore, 1, nullptr)) {
--- a/dom/plugins/ipc/PluginUtilsWin.cpp
+++ b/dom/plugins/ipc/PluginUtilsWin.cpp
@@ -1,237 +1,237 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* PluginUtilsWin.cpp - top-level Windows plugin management code */
-
-#include <mmdeviceapi.h>
-#include "PluginUtilsWin.h"
-#include "PluginModuleParent.h"
-#include "mozilla/StaticMutex.h"
-
-namespace mozilla {
-namespace plugins {
-namespace PluginUtilsWin {
-
-typedef nsTHashtable<nsPtrHashKey<PluginModuleParent>> PluginModuleSet;
-StaticMutex sMutex;
-
-class AudioDeviceChangedRunnable : public Runnable
-{
-public:
-  explicit AudioDeviceChangedRunnable(const PluginModuleSet* aAudioNotificationSet,
-                                      NPAudioDeviceChangeDetailsIPC aChangeDetails) :
-      mChangeDetails(aChangeDetails)
-    , mAudioNotificationSet(aAudioNotificationSet)
-  {}
-
-  NS_IMETHOD Run() override
-  {
-    StaticMutexAutoLock lock(sMutex);
-    PLUGIN_LOG_DEBUG(("Notifying %d plugins of audio device change.",
-                                            mAudioNotificationSet->Count()));
-
-    for (auto iter = mAudioNotificationSet->ConstIter(); !iter.Done(); iter.Next()) {
-      PluginModuleParent* pluginModule = iter.Get()->GetKey();
-      pluginModule->SendNPP_SetValue_NPNVaudioDeviceChangeDetails(mChangeDetails);
-    }
-    return NS_OK;
-  }
-
-protected:
-  NPAudioDeviceChangeDetailsIPC mChangeDetails;
-  const PluginModuleSet* mAudioNotificationSet;
-};
-
-class AudioNotification : public IMMNotificationClient
-{
-public:
-  AudioNotification() :
-      mRefCt(1)
-    , mIsRegistered(false)
-  {
-    HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator),
-                                  NULL, CLSCTX_INPROC_SERVER,
-                                  IID_PPV_ARGS(&mDeviceEnum));
-    if (FAILED(hr)) {
-      mDeviceEnum = nullptr;
-      return;
-    }
-
-    hr = mDeviceEnum->RegisterEndpointNotificationCallback(this);
-    if (FAILED(hr)) {
-      mDeviceEnum->Release();
-      mDeviceEnum = nullptr;
-      return;
-    }
-
-    mIsRegistered = true;
-  }
-
-  ~AudioNotification()
-  {
-    MOZ_ASSERT(!mIsRegistered,
-      "Destroying AudioNotification without first calling Unregister");
-    if (mDeviceEnum) {
-      mDeviceEnum->Release();
-    }
-  }
-
-  // IMMNotificationClient Implementation
-  HRESULT STDMETHODCALLTYPE
-  OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR device_id) override
-  {
-    NPAudioDeviceChangeDetailsIPC changeDetails;
-    changeDetails.flow = (int32_t)flow;
-    changeDetails.role = (int32_t)role;
-    changeDetails.defaultDevice = device_id ? std::wstring(device_id) : L"";
-
-    // Make sure that plugin is notified on the main thread.
-    RefPtr<AudioDeviceChangedRunnable> runnable =
-      new AudioDeviceChangedRunnable(&mAudioNotificationSet, changeDetails);
-    NS_DispatchToMainThread(runnable);
-    return S_OK;
-  }
-
-  HRESULT STDMETHODCALLTYPE
-  OnDeviceAdded(LPCWSTR device_id) override
-  {
-    return S_OK;
-  };
-
-  HRESULT STDMETHODCALLTYPE
-  OnDeviceRemoved(LPCWSTR device_id) override
-  {
-    return S_OK;
-  }
-
-  HRESULT STDMETHODCALLTYPE
-  OnDeviceStateChanged(LPCWSTR device_id, DWORD new_state) override
-  {
-    return S_OK;
-  }
-
-  HRESULT STDMETHODCALLTYPE
-  OnPropertyValueChanged(LPCWSTR device_id, const PROPERTYKEY key) override
-  {
-    return S_OK;
-  }
-
-  // IUnknown Implementation
-  ULONG STDMETHODCALLTYPE
-  AddRef() override
-  {
-    return InterlockedIncrement(&mRefCt);
-  }
-
-  ULONG STDMETHODCALLTYPE
-  Release() override
-  {
-    ULONG ulRef = InterlockedDecrement(&mRefCt);
-    if (0 == ulRef) {
-      delete this;
-    }
-    return ulRef;
-  }
-
-  HRESULT STDMETHODCALLTYPE
-  QueryInterface(REFIID riid, VOID **ppvInterface) override
-  {
-    if (__uuidof(IUnknown) == riid) {
-      AddRef();
-      *ppvInterface = (IUnknown*)this;
-    } else if (__uuidof(IMMNotificationClient) == riid) {
-      AddRef();
-      *ppvInterface = (IMMNotificationClient*)this;
-    } else {
-      *ppvInterface = NULL;
-      return E_NOINTERFACE;
-    }
-    return S_OK;
-  }
-
-  /*
-   * A Valid instance must be Unregistered before Releasing it.
-   */
-  void Unregister()
-  {
-    if (mDeviceEnum) {
-      mDeviceEnum->UnregisterEndpointNotificationCallback(this);
-    }
-    mIsRegistered = false;
-  }
-
-  /*
-   * True whenever the notification server is set to report events to this object.
-   */
-  bool IsRegistered() {
-    return mIsRegistered;
-  }
-
-  void AddModule(PluginModuleParent* aModule) {
-    StaticMutexAutoLock lock(sMutex);
-    mAudioNotificationSet.PutEntry(aModule);
-  }
-
-  void RemoveModule(PluginModuleParent* aModule) {
-    StaticMutexAutoLock lock(sMutex);
-    mAudioNotificationSet.RemoveEntry(aModule);
-  }
-
-  /*
-   * Are any modules registered for audio notifications?
-   */
-  bool HasModules() {
-    return !mAudioNotificationSet.IsEmpty();
-  }
-
-private:
-  bool mIsRegistered;   // only used to make sure that Unregister is called before destroying a Valid instance.
-  LONG mRefCt;
-  IMMDeviceEnumerator* mDeviceEnum;
-
-  // Set of plugin modules that have registered to be notified when the audio device
-  // changes.
-  PluginModuleSet mAudioNotificationSet;
-};  // class AudioNotification
-
-// callback that gets notified of audio device events, or NULL
-AudioNotification* sAudioNotification = nullptr;
-
-nsresult
-RegisterForAudioDeviceChanges(PluginModuleParent* aModuleParent, bool aShouldRegister)
-{
-  // Hold the AudioNotification singleton iff there are PluginModuleParents
-  // that are subscribed to it.
-  if (aShouldRegister) {
-    if (!sAudioNotification) {
-      // We are registering the first module.  Create the singleton.
-      sAudioNotification = new AudioNotification();
-      if (!sAudioNotification->IsRegistered()) {
-        PLUGIN_LOG_DEBUG(("Registered for plugin audio device notification failed."));
-        sAudioNotification->Release();
-        sAudioNotification = nullptr;
-        return NS_ERROR_FAILURE;
-      }
-      PLUGIN_LOG_DEBUG(("Registered for plugin audio device notification."));
-    }
-    sAudioNotification->AddModule(aModuleParent);
-  }
-  else if (!aShouldRegister && sAudioNotification) {
-    sAudioNotification->RemoveModule(aModuleParent);
-    if (!sAudioNotification->HasModules()) {
-      // We have removed the last module from the notification mechanism
-      // so we can destroy the singleton.
-      PLUGIN_LOG_DEBUG(("Unregistering for plugin audio device notification."));
-      sAudioNotification->Unregister();
-      sAudioNotification->Release();
-      sAudioNotification = nullptr;
-    }
-  }
-  return NS_OK;
-}
-
-}   // namespace PluginUtilsWin
-}   // namespace plugins
-}   // namespace mozilla
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* PluginUtilsWin.cpp - top-level Windows plugin management code */
+
+#include <mmdeviceapi.h>
+#include "PluginUtilsWin.h"
+#include "PluginModuleParent.h"
+#include "mozilla/StaticMutex.h"
+
+namespace mozilla {
+namespace plugins {
+namespace PluginUtilsWin {
+
+typedef nsTHashtable<nsPtrHashKey<PluginModuleParent>> PluginModuleSet;
+StaticMutex sMutex;
+
+class AudioDeviceChangedRunnable : public Runnable
+{
+public:
+  explicit AudioDeviceChangedRunnable(const PluginModuleSet* aAudioNotificationSet,
+                                      NPAudioDeviceChangeDetailsIPC aChangeDetails) :
+      mChangeDetails(aChangeDetails)
+    , mAudioNotificationSet(aAudioNotificationSet)
+  {}
+
+  NS_IMETHOD Run() override
+  {
+    StaticMutexAutoLock lock(sMutex);
+    PLUGIN_LOG_DEBUG(("Notifying %d plugins of audio device change.",
+                                            mAudioNotificationSet->Count()));
+
+    for (auto iter = mAudioNotificationSet->ConstIter(); !iter.Done(); iter.Next()) {
+      PluginModuleParent* pluginModule = iter.Get()->GetKey();
+      pluginModule->SendNPP_SetValue_NPNVaudioDeviceChangeDetails(mChangeDetails);
+    }
+    return NS_OK;
+  }
+
+protected:
+  NPAudioDeviceChangeDetailsIPC mChangeDetails;
+  const PluginModuleSet* mAudioNotificationSet;
+};
+
+class AudioNotification : public IMMNotificationClient
+{
+public:
+  AudioNotification() :
+      mIsRegistered(false)
+    , mRefCt(1)
+  {
+    HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator),
+                                  NULL, CLSCTX_INPROC_SERVER,
+                                  IID_PPV_ARGS(&mDeviceEnum));
+    if (FAILED(hr)) {
+      mDeviceEnum = nullptr;
+      return;
+    }
+
+    hr = mDeviceEnum->RegisterEndpointNotificationCallback(this);
+    if (FAILED(hr)) {
+      mDeviceEnum->Release();
+      mDeviceEnum = nullptr;
+      return;
+    }
+
+    mIsRegistered = true;
+  }
+
+  ~AudioNotification()
+  {
+    MOZ_ASSERT(!mIsRegistered,
+      "Destroying AudioNotification without first calling Unregister");
+    if (mDeviceEnum) {
+      mDeviceEnum->Release();
+    }
+  }
+
+  // IMMNotificationClient Implementation
+  HRESULT STDMETHODCALLTYPE
+  OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR device_id) override
+  {
+    NPAudioDeviceChangeDetailsIPC changeDetails;
+    changeDetails.flow = (int32_t)flow;
+    changeDetails.role = (int32_t)role;
+    changeDetails.defaultDevice = device_id ? std::wstring(device_id) : L"";
+
+    // Make sure that plugin is notified on the main thread.
+    RefPtr<AudioDeviceChangedRunnable> runnable =
+      new AudioDeviceChangedRunnable(&mAudioNotificationSet, changeDetails);
+    NS_DispatchToMainThread(runnable);
+    return S_OK;
+  }
+
+  HRESULT STDMETHODCALLTYPE
+  OnDeviceAdded(LPCWSTR device_id) override
+  {
+    return S_OK;
+  };
+
+  HRESULT STDMETHODCALLTYPE
+  OnDeviceRemoved(LPCWSTR device_id) override
+  {
+    return S_OK;
+  }
+
+  HRESULT STDMETHODCALLTYPE
+  OnDeviceStateChanged(LPCWSTR device_id, DWORD new_state) override
+  {
+    return S_OK;
+  }
+
+  HRESULT STDMETHODCALLTYPE
+  OnPropertyValueChanged(LPCWSTR device_id, const PROPERTYKEY key) override
+  {
+    return S_OK;
+  }
+
+  // IUnknown Implementation
+  ULONG STDMETHODCALLTYPE
+  AddRef() override
+  {
+    return InterlockedIncrement(&mRefCt);
+  }
+
+  ULONG STDMETHODCALLTYPE
+  Release() override
+  {
+    ULONG ulRef = InterlockedDecrement(&mRefCt);
+    if (0 == ulRef) {
+      delete this;
+    }
+    return ulRef;
+  }
+
+  HRESULT STDMETHODCALLTYPE
+  QueryInterface(REFIID riid, VOID **ppvInterface) override
+  {
+    if (__uuidof(IUnknown) == riid) {
+      AddRef();
+      *ppvInterface = (IUnknown*)this;
+    } else if (__uuidof(IMMNotificationClient) == riid) {
+      AddRef();
+      *ppvInterface = (IMMNotificationClient*)this;
+    } else {
+      *ppvInterface = NULL;
+      return E_NOINTERFACE;
+    }
+    return S_OK;
+  }
+
+  /*
+   * A Valid instance must be Unregistered before Releasing it.
+   */
+  void Unregister()
+  {
+    if (mDeviceEnum) {
+      mDeviceEnum->UnregisterEndpointNotificationCallback(this);
+    }
+    mIsRegistered = false;
+  }
+
+  /*
+   * True whenever the notification server is set to report events to this object.
+   */
+  bool IsRegistered() {
+    return mIsRegistered;
+  }
+
+  void AddModule(PluginModuleParent* aModule) {
+    StaticMutexAutoLock lock(sMutex);
+    mAudioNotificationSet.PutEntry(aModule);
+  }
+
+  void RemoveModule(PluginModuleParent* aModule) {
+    StaticMutexAutoLock lock(sMutex);
+    mAudioNotificationSet.RemoveEntry(aModule);
+  }
+
+  /*
+   * Are any modules registered for audio notifications?
+   */
+  bool HasModules() {
+    return !mAudioNotificationSet.IsEmpty();
+  }
+
+private:
+  bool mIsRegistered;   // only used to make sure that Unregister is called before destroying a Valid instance.
+  LONG mRefCt;
+  IMMDeviceEnumerator* mDeviceEnum;
+
+  // Set of plugin modules that have registered to be notified when the audio device
+  // changes.
+  PluginModuleSet mAudioNotificationSet;
+};  // class AudioNotification
+
+// callback that gets notified of audio device events, or NULL
+AudioNotification* sAudioNotification = nullptr;
+
+nsresult
+RegisterForAudioDeviceChanges(PluginModuleParent* aModuleParent, bool aShouldRegister)
+{
+  // Hold the AudioNotification singleton iff there are PluginModuleParents
+  // that are subscribed to it.
+  if (aShouldRegister) {
+    if (!sAudioNotification) {
+      // We are registering the first module.  Create the singleton.
+      sAudioNotification = new AudioNotification();
+      if (!sAudioNotification->IsRegistered()) {
+        PLUGIN_LOG_DEBUG(("Registered for plugin audio device notification failed."));
+        sAudioNotification->Release();
+        sAudioNotification = nullptr;
+        return NS_ERROR_FAILURE;
+      }
+      PLUGIN_LOG_DEBUG(("Registered for plugin audio device notification."));
+    }
+    sAudioNotification->AddModule(aModuleParent);
+  }
+  else if (!aShouldRegister && sAudioNotification) {
+    sAudioNotification->RemoveModule(aModuleParent);
+    if (!sAudioNotification->HasModules()) {
+      // We have removed the last module from the notification mechanism
+      // so we can destroy the singleton.
+      PLUGIN_LOG_DEBUG(("Unregistering for plugin audio device notification."));
+      sAudioNotification->Unregister();
+      sAudioNotification->Release();
+      sAudioNotification = nullptr;
+    }
+  }
+  return NS_OK;
+}
+
+}   // namespace PluginUtilsWin
+}   // namespace plugins
+}   // namespace mozilla