unbraced-if-fixes.patch
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 108 33529a5c309fd85dad4adb0f672eaeb6493195ad
permissions -rw-r--r--
State as of now

* * *

diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -443,8 +443,6 @@ NS_IMETHODIMP nsDocAccessible::GetWindow
 
   if (!*aDOMWin)
     return NS_ERROR_FAILURE;  // No DOM Window
-
-  NS_ADDREF(*aDOMWin);
 
   return NS_OK;
 }
diff --git a/caps/src/nsScriptSecurityManager.cpp b/caps/src/nsScriptSecurityManager.cpp
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -1782,8 +1782,6 @@ nsScriptSecurityManager::GetSubjectPrinc
 {
     nsresult rv;
     *aSubjectPrincipal = doGetSubjectPrincipal(&rv);
-    if (NS_SUCCEEDED(rv))
-        NS_IF_ADDREF(*aSubjectPrincipal);
     return rv;
 }
 
diff --git a/editor/libeditor/base/TransactionFactory.cpp b/editor/libeditor/base/TransactionFactory.cpp
--- a/editor/libeditor/base/TransactionFactory.cpp
+++ b/editor/libeditor/base/TransactionFactory.cpp
@@ -112,9 +112,6 @@ TransactionFactory::GetNewTransaction(RE
   if (NS_SUCCEEDED(result) && !*aResult)
     result = NS_ERROR_OUT_OF_MEMORY;
 
-  if (NS_SUCCEEDED(result))
-    NS_ADDREF(*aResult);
-
   return result;
 }
 
diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -1470,8 +1470,6 @@ static nsICiter* MakeACiter()
   if (citationType)
     PL_strfree(citationType);
 
-  if (citer)
-    NS_ADDREF(citer);
   return citer;
 }
 
diff --git a/embedding/browser/gtk/src/EmbedGlobalHistory.cpp b/embedding/browser/gtk/src/EmbedGlobalHistory.cpp
--- a/embedding/browser/gtk/src/EmbedGlobalHistory.cpp
+++ b/embedding/browser/gtk/src/EmbedGlobalHistory.cpp
@@ -287,8 +287,6 @@ EmbedGlobalHistory::GetInstance()
       return nsnull;
     }
   }
-  else
-    NS_ADDREF(sEmbedGlobalHistory);   // addref the return result
   return sEmbedGlobalHistory;
 }
 
diff --git a/intl/unicharutil/src/nsEntityConverter.cpp b/intl/unicharutil/src/nsEntityConverter.cpp
--- a/intl/unicharutil/src/nsEntityConverter.cpp
+++ b/intl/unicharutil/src/nsEntityConverter.cpp
@@ -284,7 +284,5 @@ nsresult NS_NewEntityConverter(nsISuppor
    if(!oResult)
       return NS_ERROR_NULL_POINTER;
    *oResult = new nsEntityConverter();
-   if(*oResult)
-      NS_ADDREF(*oResult);
    return (*oResult) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
diff --git a/intl/unicharutil/src/nsHankakuToZenkaku.cpp b/intl/unicharutil/src/nsHankakuToZenkaku.cpp
--- a/intl/unicharutil/src/nsHankakuToZenkaku.cpp
+++ b/intl/unicharutil/src/nsHankakuToZenkaku.cpp
@@ -183,7 +183,5 @@ nsresult NS_NewHankakuToZenkaku(nsISuppo
   if(!oResult)
     return NS_ERROR_NULL_POINTER;
   *oResult = new nsHankakuToZenkaku();
-  if(*oResult)
-     NS_ADDREF(*oResult);
   return (*oResult) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
diff --git a/intl/unicharutil/src/nsSaveAsCharset.cpp b/intl/unicharutil/src/nsSaveAsCharset.cpp
--- a/intl/unicharutil/src/nsSaveAsCharset.cpp
+++ b/intl/unicharutil/src/nsSaveAsCharset.cpp
@@ -408,7 +408,5 @@ NS_NewSaveAsCharset(nsISupports **inst)
   if(nsnull == inst )
     return NS_ERROR_NULL_POINTER;
   *inst = (nsISupports *) new nsSaveAsCharset;
-   if(*inst)
-      NS_ADDREF(*inst);
    return (*inst) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
diff --git a/js/src/xpconnect/src/xpcstack.cpp b/js/src/xpconnect/src/xpcstack.cpp
--- a/js/src/xpconnect/src/xpcstack.cpp
+++ b/js/src/xpconnect/src/xpcstack.cpp
@@ -205,9 +205,7 @@ XPCJSStackFrame::CreateStackFrameLocatio
 {
     JSBool failed = JS_FALSE;
     XPCJSStackFrame* self = new XPCJSStackFrame();
-    if(self)
-        NS_ADDREF(self);
-    else
+    if(!self)
         failed = JS_TRUE;
 
     if(!failed)
@@ -308,8 +306,6 @@ NS_IMETHODIMP XPCJSStackFrame::GetCaller
     if(!aCaller)
         return NS_ERROR_NULL_POINTER;
 
-    if(mCaller)
-        NS_ADDREF(mCaller);
     *aCaller = mCaller;
     return NS_OK;
 }
diff --git a/js/src/xpconnect/src/xpcwrappedjs.cpp b/js/src/xpconnect/src/xpcwrappedjs.cpp
--- a/js/src/xpconnect/src/xpcwrappedjs.cpp
+++ b/js/src/xpconnect/src/xpcwrappedjs.cpp
@@ -260,10 +260,6 @@ nsXPCWrappedJS::nsXPCWrappedJS(XPCCallCo
     NS_ADDREF_THIS();
     NS_ADDREF(aClass);
     NS_IF_ADDREF(mOuter);
-
-    if(mRoot != this)
-        NS_ADDREF(mRoot);
-
 }
 
 nsXPCWrappedJS::~nsXPCWrappedJS()
diff --git a/js/src/xpconnect/tests/components/xpctest_calljs.cpp b/js/src/xpconnect/tests/components/xpctest_calljs.cpp
--- a/js/src/xpconnect/tests/components/xpctest_calljs.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_calljs.cpp
@@ -77,8 +77,6 @@ NS_IMETHODIMP xpcTestCallJS :: SetJSObje
     //if (jsobject)
     //  NS_RELEASE( jsobject );
     jsobject = o;
-    if ( jsobject ) 
-        NS_ADDREF( jsobject );
     return NS_OK;
 }
 
diff --git a/js/src/xpconnect/tests/components/xpctest_echo.cpp b/js/src/xpconnect/tests/components/xpctest_echo.cpp
--- a/js/src/xpconnect/tests/components/xpctest_echo.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_echo.cpp
@@ -313,8 +313,6 @@ xpctestEcho::ReturnInterface(nsISupports
 {
     if(!_retval)
         return NS_ERROR_NULL_POINTER;
-    if(obj)
-        NS_ADDREF(obj);
     *_retval = obj;
     return NS_OK;
 }
@@ -361,8 +359,6 @@ xpctestEcho::SetReceiverReturnOldReceive
 
     nsIEcho* oldReceiver = mReceiver;
     mReceiver = *aReceiver;
-    if(mReceiver)
-        NS_ADDREF(mReceiver);
 
     /* don't release the reference, that is the caller's problem */
     *aReceiver = oldReceiver;
diff --git a/netwerk/base/src/nsSocketTransportService2.cpp b/netwerk/base/src/nsSocketTransportService2.cpp
--- a/netwerk/base/src/nsSocketTransportService2.cpp
+++ b/netwerk/base/src/nsSocketTransportService2.cpp
@@ -165,8 +165,6 @@ nsSocketTransportService::AttachSocket(P
     sock.mElapsedTime = 0;
 
     nsresult rv = AddToIdleList(&sock);
-    if (NS_SUCCEEDED(rv))
-        NS_ADDREF(handler);
     return rv;
 }
 
diff --git a/netwerk/dns/src/nsHostResolver.cpp b/netwerk/dns/src/nsHostResolver.cpp
--- a/netwerk/dns/src/nsHostResolver.cpp
+++ b/netwerk/dns/src/nsHostResolver.cpp
@@ -535,9 +535,7 @@ nsHostResolver::IssueLookup(nsHostRecord
     // add rec to mPendingQ, possibly removing it from mEvictionQ.
     // if rec is on mEvictionQ, then we can just move the owning
     // reference over to mPendingQ.
-    if (rec->next == rec)
-        NS_ADDREF(rec);
-    else {
+    if (rec->next != rec) {
         PR_REMOVE_LINK(rec);
         mEvictionQSize--;
     }
diff --git a/uriloader/exthandler/win/nsOSHelperAppService.cpp b/uriloader/exthandler/win/nsOSHelperAppService.cpp
--- a/uriloader/exthandler/win/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/win/nsOSHelperAppService.cpp
@@ -537,8 +537,6 @@ already_AddRefed<nsMIMEInfoWin> nsOSHelp
   if (!mimeInfo)
     return nsnull; // out of memory
 
-  NS_ADDREF(mimeInfo);
-
   // don't append the '.'
   mimeInfo->AppendExtension(NS_ConvertUTF16toUTF8(Substring(fileExtToUse, 1)));
   mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
diff --git a/widget/src/xpwidgets/nsBaseClipboard.cpp b/widget/src/xpwidgets/nsBaseClipboard.cpp
--- a/widget/src/xpwidgets/nsBaseClipboard.cpp
+++ b/widget/src/xpwidgets/nsBaseClipboard.cpp
@@ -77,8 +77,6 @@ NS_IMETHODIMP nsBaseClipboard::SetData(n
   EmptyClipboard(aWhichClipboard);
 
   mClipboardOwner = anOwner;
-  if ( anOwner )
-    NS_ADDREF(mClipboardOwner);
 
   mTransferable = aTransferable;
   
diff --git a/widget/src/xpwidgets/nsTransferable.cpp b/widget/src/xpwidgets/nsTransferable.cpp
--- a/widget/src/xpwidgets/nsTransferable.cpp
+++ b/widget/src/xpwidgets/nsTransferable.cpp
@@ -166,8 +166,6 @@ DataStruct::GetData ( nsISupports** aDat
   }
   
   *aData = mData;
-  if ( mData )
-    NS_ADDREF(*aData); 
   *aDataLen = mDataLen;
 }
 
diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -476,8 +476,6 @@ PLDHashTableEnumeratorImpl::CurrentItem(
         return NS_ERROR_FAILURE;
 
     *retval = reinterpret_cast<nsISupports *>(mElements[mCurrent]);
-    if (*retval)
-        NS_ADDREF(*retval);
 
     return NS_OK;
 }
diff --git a/xpcom/glue/nsCOMArray.cpp b/xpcom/glue/nsCOMArray.cpp
--- a/xpcom/glue/nsCOMArray.cpp
+++ b/xpcom/glue/nsCOMArray.cpp
@@ -84,8 +84,6 @@ PRBool
 PRBool
 nsCOMArray_base::InsertObjectAt(nsISupports* aObject, PRInt32 aIndex) {
     PRBool result = mArray.InsertElementAt(aObject, aIndex);
-    if (result)
-        NS_IF_ADDREF(aObject);
     return result;
 }
 
diff --git a/xpcom/threads/nsTimerImpl.cpp b/xpcom/threads/nsTimerImpl.cpp
--- a/xpcom/threads/nsTimerImpl.cpp
+++ b/xpcom/threads/nsTimerImpl.cpp
@@ -392,10 +392,6 @@ void nsTimerImpl::Fire()
   // See bug 330128.
   CallbackUnion callback = mCallback;
   PRUintn callbackType = mCallbackType;
-  if (callbackType == CALLBACK_TYPE_INTERFACE)
-    NS_ADDREF(callback.i);
-  else if (callbackType == CALLBACK_TYPE_OBSERVER)
-    NS_ADDREF(callback.o);
   ReleaseCallback();
 
   switch (callbackType) {