Bug 1508848: Remove operator bool from WindowsError and replace with IsSuccess and IsFailure methods; r=mhowell
authorAaron Klotz <aklotz@mozilla.com>
Tue, 20 Nov 2018 22:59:51 +0000
changeset 447429 8b1b35582dd7f986619174828bae634511718de9
parent 447428 99433995b7cd8d51e9a4759cb3b658a00e5ad9e0
child 447440 7488645b27ac9b273d6785db04204684673b3657
child 447441 5cc584ca5b00aedefb17360ae2d5c8068850f54b
push id35078
push userbtara@mozilla.com
push dateWed, 21 Nov 2018 09:38:45 +0000
treeherdermozilla-central@8b1b35582dd7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhowell
bugs1508848
milestone65.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 1508848: Remove operator bool from WindowsError and replace with IsSuccess and IsFailure methods; r=mhowell Differential Revision: https://phabricator.services.mozilla.com/D12485
browser/app/winlauncher/DllBlocklistWin.cpp
widget/windows/WinHeaderOnlyUtils.h
--- a/browser/app/winlauncher/DllBlocklistWin.cpp
+++ b/browser/app/winlauncher/DllBlocklistWin.cpp
@@ -336,27 +336,27 @@ public:
     if (!::VirtualProtectEx(aTargetProcess, aAddress, aLength, aProtFlags,
                             &mPrevProt)) {
       mError = WindowsError::FromLastError();
     }
   }
 
   ~AutoVirtualProtect()
   {
-    if (!mError) {
+    if (mError.IsFailure()) {
       return;
     }
 
     ::VirtualProtectEx(mTargetProcess, mAddress, mLength, mPrevProt,
                        &mPrevProt);
   }
 
   explicit operator bool() const
   {
-    return !!mError;
+    return mError.IsSuccess();
   }
 
   WindowsError GetError() const
   {
     return mError;
   }
 
   AutoVirtualProtect(const AutoVirtualProtect&) = delete;
--- a/widget/windows/WinHeaderOnlyUtils.h
+++ b/widget/windows/WinHeaderOnlyUtils.h
@@ -91,21 +91,26 @@ public:
     return WindowsError(S_OK);
   }
 
   static WindowsError CreateGeneric()
   {
     return FromWin32Error(ERROR_UNIDENTIFIED_ERROR);
   }
 
-  explicit operator bool() const
+  bool IsSuccess() const
   {
     return SUCCEEDED(mHResult);
   }
 
+  bool IsFailure() const
+  {
+    return FAILED(mHResult);
+  }
+
   bool IsAvailableAsWin32Error() const
   {
     return IsAvailableAsNtStatus() ||
            HRESULT_FACILITY(mHResult) == FACILITY_WIN32;
   }
 
   bool IsAvailableAsNtStatus() const
   {