Bug 1252839 - Remove some if stmt after allocation with 'new' - patch 2, r=bz
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 02 Mar 2016 18:51:33 +0100
changeset 322833 32e49c1e3a0609c136af0c855675848b53049de2
parent 322832 307f62ff2fc9283c592f32a042760d80293b7c30
child 322834 f2990a314e2312d2f6bf4e5b4632083815f85f7d
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1252839
milestone47.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 1252839 - Remove some if stmt after allocation with 'new' - patch 2, r=bz
xpfe/appshell/nsAppShellService.cpp
xpfe/appshell/nsChromeTreeOwner.cpp
xpfe/appshell/nsWindowMediator.cpp
xpfe/appshell/nsXULWindow.cpp
xpfe/components/directory/nsDirectoryViewer.cpp
--- a/xpfe/appshell/nsAppShellService.cpp
+++ b/xpfe/appshell/nsAppShellService.cpp
@@ -507,20 +507,16 @@ nsAppShellService::CreateWindowlessBrows
   }
 
   /* Next, we set the container window for our instance of nsWebBrowser. Since
    * we don't actually have a window, we instead set the container window to be
    * an instance of WebBrowserChrome2Stub, which provides a stub implementation
    * of nsIWebBrowserChrome2.
    */
   RefPtr<WebBrowserChrome2Stub> stub = new WebBrowserChrome2Stub();
-  if (!stub) {
-    NS_ERROR("Couldn't create instance of WebBrowserChrome2Stub!");
-    return NS_ERROR_FAILURE;
-  }
   browser->SetContainerWindow(stub);
 
   nsCOMPtr<nsIWebNavigation> navigation = do_QueryInterface(browser);
 
   nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(navigation);
   item->SetItemType(aIsChrome ? nsIDocShellTreeItem::typeChromeWrapper
                               : nsIDocShellTreeItem::typeContentWrapper);
 
@@ -637,17 +633,16 @@ nsAppShellService::JustCreateTopWindow(n
   *aResult = nullptr;
   NS_ENSURE_STATE(!mXPCOMWillShutDown);
 
   nsCOMPtr<nsIXULWindow> parent;
   if (aChromeMask & nsIWebBrowserChrome::CHROME_DEPENDENT)
     parent = aParent;
 
   RefPtr<nsWebShellWindow> window = new nsWebShellWindow(aChromeMask);
-  NS_ENSURE_TRUE(window, NS_ERROR_OUT_OF_MEMORY);
 
 #ifdef XP_WIN
   // If the parent is currently fullscreen, tell the child to ignore persisted
   // full screen states. This way new browser windows open on top of fullscreen
   // windows normally.
   if (window && CheckForFullscreenWindow())
     window->IgnoreXULSizeMode(true);
 #endif
--- a/xpfe/appshell/nsChromeTreeOwner.cpp
+++ b/xpfe/appshell/nsChromeTreeOwner.cpp
@@ -58,18 +58,16 @@ struct nsChromeTreeOwnerLiterals
 
 static nsChromeTreeOwnerLiterals *gLiterals;
 
 nsresult
 nsChromeTreeOwner::InitGlobals()
 {
   NS_ASSERTION(gLiterals == nullptr, "already initialized");
   gLiterals = new nsChromeTreeOwnerLiterals();
-  if (!gLiterals)
-    return NS_ERROR_OUT_OF_MEMORY;
   return NS_OK;
 }
 
 void
 nsChromeTreeOwner::FreeGlobals()
 {
   delete gLiterals;
   gLiterals = nullptr;
--- a/xpfe/appshell/nsWindowMediator.cpp
+++ b/xpfe/appshell/nsWindowMediator.cpp
@@ -85,18 +85,16 @@ NS_IMETHODIMP nsWindowMediator::Register
     NS_ERROR("multiple window registration");
     return NS_ERROR_FAILURE;
   }
 
   mTimeStamp++;
 
   // Create window info struct and add to list of windows
   nsWindowInfo* windowInfo = new nsWindowInfo(inWindow, mTimeStamp);
-  if (!windowInfo)
-    return NS_ERROR_OUT_OF_MEMORY;
 
   WindowTitleData winData = { inWindow, nullptr };
   mListeners.EnumerateForwards(notifyOpenWindow, &winData);
   
   if (mOldestWindow)
     windowInfo->InsertAfter(mOldestWindow->mOlder, nullptr);
   else
     mOldestWindow = windowInfo;
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -963,46 +963,40 @@ NS_IMETHODIMP nsXULWindow::SetTitle(cons
 //*****************************************************************************   
 
 NS_IMETHODIMP nsXULWindow::EnsureChromeTreeOwner()
 {
   if (mChromeTreeOwner)
     return NS_OK;
 
   mChromeTreeOwner = new nsChromeTreeOwner();
-  NS_ENSURE_TRUE(mChromeTreeOwner, NS_ERROR_OUT_OF_MEMORY);
-
   NS_ADDREF(mChromeTreeOwner);
   mChromeTreeOwner->XULWindow(this);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsXULWindow::EnsureContentTreeOwner()
 {
   if (mContentTreeOwner)
     return NS_OK;
 
   mContentTreeOwner = new nsContentTreeOwner(false);
-  NS_ENSURE_TRUE(mContentTreeOwner, NS_ERROR_FAILURE);
-
   NS_ADDREF(mContentTreeOwner);
   mContentTreeOwner->XULWindow(this);
    
   return NS_OK;
 }
 
 NS_IMETHODIMP nsXULWindow::EnsurePrimaryContentTreeOwner()
 {
   if (mPrimaryContentTreeOwner)
     return NS_OK;
 
   mPrimaryContentTreeOwner = new nsContentTreeOwner(true);
-  NS_ENSURE_TRUE(mPrimaryContentTreeOwner, NS_ERROR_FAILURE);
-
   NS_ADDREF(mPrimaryContentTreeOwner);
   mPrimaryContentTreeOwner->XULWindow(this);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsXULWindow::EnsurePrompter()
 {
--- a/xpfe/components/directory/nsDirectoryViewer.cpp
+++ b/xpfe/components/directory/nsDirectoryViewer.cpp
@@ -646,19 +646,16 @@ nsHTTPIndex::Init(nsIURI* aBaseURL)
 
 nsresult
 nsHTTPIndex::Create(nsIURI* aBaseURL, nsIInterfaceRequestor* aRequestor,
                     nsIHTTPIndex** aResult)
 {
   *aResult = nullptr;
 
   nsHTTPIndex* result = new nsHTTPIndex(aRequestor);
-  if (! result)
-    return NS_ERROR_OUT_OF_MEMORY;
-
   nsresult rv = result->Init(aBaseURL);
   if (NS_SUCCEEDED(rv))
   {
     NS_ADDREF(result);
     *aResult = result;
   }
   else
   {