Bug 777292 - Don't use |= on nsresult; r=ehsan
authorAryeh Gregor <ayg@aryeh.name>
Fri, 27 Jul 2012 17:03:08 +0300
changeset 100851 46b6432350242d465936adb1beabb356c2633520
parent 100850 75e5b7133dfd8cd501e39b779cd86941eefb97a6
child 100852 fb231ccb1823f2a3d7ac398e5fe39953dac42df7
push id12705
push userayg@aryeh.name
push dateMon, 30 Jul 2012 10:08:25 +0000
treeherdermozilla-inbound@ae22e27106b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs777292
milestone17.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 777292 - Don't use |= on nsresult; r=ehsan
content/base/src/nsGenericElement.h
content/base/src/nsXMLNameSpaceMap.cpp
content/html/content/src/nsHTMLInputElement.cpp
content/svg/content/src/nsSVGSVGElement.cpp
content/svg/content/src/nsSVGScriptElement.cpp
content/svg/content/src/nsSVGUseElement.cpp
content/xul/content/src/nsXULElement.cpp
content/xul/document/src/nsXULPrototypeCache.cpp
content/xul/document/src/nsXULPrototypeDocument.cpp
docshell/base/nsDocShell.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsJSEnvironment.cpp
embedding/components/find/src/nsFind.cpp
image/src/imgRequest.cpp
layout/base/nsDocumentViewer.cpp
layout/base/nsLayoutUtils.cpp
layout/generic/nsSelection.cpp
netwerk/base/public/nsNetUtil.h
netwerk/base/src/nsURIChecker.cpp
netwerk/cache/nsDiskCacheDeviceSQL.cpp
netwerk/protocol/http/nsHttpDigestAuth.cpp
rdf/datasource/src/nsFileSystemDataSource.cpp
toolkit/xre/nsXREDirProvider.cpp
--- a/content/base/src/nsGenericElement.h
+++ b/content/base/src/nsGenericElement.h
@@ -1016,17 +1016,20 @@ nsresult                                
   nsCOMPtr<nsINodeInfo> ni = aNodeInfo;                                     \
   _elementName *it = new _elementName(ni.forget());                         \
   if (!it) {                                                                \
     return NS_ERROR_OUT_OF_MEMORY;                                          \
   }                                                                         \
                                                                             \
   nsCOMPtr<nsINode> kungFuDeathGrip = it;                                   \
   nsresult rv = it->Init();                                                 \
-  rv |= const_cast<_elementName*>(this)->CopyInnerTo(it);                   \
+  nsresult rv2 = const_cast<_elementName*>(this)->CopyInnerTo(it);          \
+  if (NS_FAILED(rv2)) {                                                     \
+    rv = rv2;                                                               \
+  }                                                                         \
   if (NS_SUCCEEDED(rv)) {                                                   \
     kungFuDeathGrip.swap(*aResult);                                         \
   }                                                                         \
                                                                             \
   return rv;                                                                \
 }
 
 #define DOMCI_NODE_DATA(_interface, _class)                             \
--- a/content/base/src/nsXMLNameSpaceMap.cpp
+++ b/content/base/src/nsXMLNameSpaceMap.cpp
@@ -31,21 +31,21 @@ class nsDefaultComparator <nsNameSpaceEn
 
 /* static */ nsXMLNameSpaceMap*
 nsXMLNameSpaceMap::Create(bool aForXML)
 {
   nsXMLNameSpaceMap *map = new nsXMLNameSpaceMap();
   NS_ENSURE_TRUE(map, nsnull);
 
   if (aForXML) {
-    nsresult rv = map->AddPrefix(nsGkAtoms::xmlns,
-                                 kNameSpaceID_XMLNS);
-    rv |= map->AddPrefix(nsGkAtoms::xml, kNameSpaceID_XML);
+    nsresult rv1 = map->AddPrefix(nsGkAtoms::xmlns,
+                                  kNameSpaceID_XMLNS);
+    nsresult rv2 = map->AddPrefix(nsGkAtoms::xml, kNameSpaceID_XML);
 
-    if (NS_FAILED(rv)) {
+    if (NS_FAILED(rv1) || NS_FAILED(rv2)) {
       delete map;
       map = nsnull;
     }
   }
 
   return map;
 }
 
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -3322,17 +3322,20 @@ nsHTMLInputElement::SaveState()
   if (inputState) {
     rv = GetPrimaryPresState(this, &state);
     if (state) {
       state->SetStateProperty(inputState);
     }
   }
 
   if (mDisabledChanged) {
-    rv |= GetPrimaryPresState(this, &state);
+    nsresult tmp = GetPrimaryPresState(this, &state);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
     if (state) {
       // We do not want to save the real disabled state but the disabled
       // attribute.
       state->SetDisabled(HasAttr(kNameSpaceID_None, nsGkAtoms::disabled));
     }
   }
 
   return rv;
--- a/content/svg/content/src/nsSVGSVGElement.cpp
+++ b/content/svg/content/src/nsSVGSVGElement.cpp
@@ -182,23 +182,23 @@ nsSVGSVGElement::nsSVGSVGElement(already
 nsresult
 nsSVGSVGElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
 {
   *aResult = nsnull;
   nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
   nsSVGSVGElement *it = new nsSVGSVGElement(ni.forget(), NOT_FROM_PARSER);
 
   nsCOMPtr<nsINode> kungFuDeathGrip = it;
-  nsresult rv = it->Init();
-  rv |= const_cast<nsSVGSVGElement*>(this)->CopyInnerTo(it);
-  if (NS_SUCCEEDED(rv)) {
+  nsresult rv1 = it->Init();
+  nsresult rv2 = const_cast<nsSVGSVGElement*>(this)->CopyInnerTo(it);
+  if (NS_SUCCEEDED(rv1) && NS_SUCCEEDED(rv2)) {
     kungFuDeathGrip.swap(*aResult);
   }
 
-  return rv;
+  return NS_FAILED(rv1) ? rv1 : rv2;
 }
 
 
 //----------------------------------------------------------------------
 // nsIDOMSVGSVGElement methods:
 
 /* readonly attribute nsIDOMSVGAnimatedLength x; */
 NS_IMETHODIMP
--- a/content/svg/content/src/nsSVGScriptElement.cpp
+++ b/content/svg/content/src/nsSVGScriptElement.cpp
@@ -123,19 +123,20 @@ nsresult
 nsSVGScriptElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
 {
   *aResult = nsnull;
 
   nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
   nsSVGScriptElement* it = new nsSVGScriptElement(ni.forget(), NOT_FROM_PARSER);
 
   nsCOMPtr<nsINode> kungFuDeathGrip = it;
-  nsresult rv = it->Init();
-  rv |= const_cast<nsSVGScriptElement*>(this)->CopyInnerTo(it);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsresult rv1 = it->Init();
+  nsresult rv2 = const_cast<nsSVGScriptElement*>(this)->CopyInnerTo(it);
+  NS_ENSURE_SUCCESS(rv1, rv1);
+  NS_ENSURE_SUCCESS(rv2, rv2);
 
   // The clone should be marked evaluated if we are.
   it->mAlreadyStarted = mAlreadyStarted;
   it->mLineNumber = mLineNumber;
   it->mMalformed = mMalformed;
 
   kungFuDeathGrip.swap(*aResult);
 
--- a/content/svg/content/src/nsSVGUseElement.cpp
+++ b/content/svg/content/src/nsSVGUseElement.cpp
@@ -102,27 +102,27 @@ nsSVGUseElement::Clone(nsINodeInfo *aNod
   *aResult = nsnull;
   nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
   nsSVGUseElement *it = new nsSVGUseElement(ni.forget());
   if (!it) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   nsCOMPtr<nsINode> kungFuDeathGrip(it);
-  nsresult rv = it->Init();
-  rv |= const_cast<nsSVGUseElement*>(this)->CopyInnerTo(it);
+  nsresult rv1 = it->Init();
+  nsresult rv2 = const_cast<nsSVGUseElement*>(this)->CopyInnerTo(it);
 
   // nsSVGUseElement specific portion - record who we cloned from
   it->mOriginal = const_cast<nsSVGUseElement*>(this);
 
-  if (NS_SUCCEEDED(rv)) {
+  if (NS_SUCCEEDED(rv1) && NS_SUCCEEDED(rv2)) {
     kungFuDeathGrip.swap(*aResult);
   }
 
-  return rv;
+  return NS_FAILED(rv1) ? rv1 : rv2;
 }
 
 //----------------------------------------------------------------------
 // nsIDOMSVGURIReference methods
 
 /* readonly attribute nsIDOMSVGAnimatedString href; */
   NS_IMETHODIMP nsSVGUseElement::GetHref(nsIDOMSVGAnimatedString * *aHref)
 {
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -1930,20 +1930,26 @@ nsXULPrototypeElement::Serialize(nsIObje
     nsresult rv;
 
     // Write basic prototype data
     rv = aStream->Write32(mType);
 
     // Write Node Info
     PRInt32 index = aNodeInfos->IndexOf(mNodeInfo);
     NS_ASSERTION(index >= 0, "unknown nsINodeInfo index");
-    rv |= aStream->Write32(index);
+    nsresult tmp = aStream->Write32(index);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
 
     // Write Attributes
-    rv |= aStream->Write32(mNumAttributes);
+    tmp = aStream->Write32(mNumAttributes);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
 
     nsAutoString attributeValue;
     PRUint32 i;
     for (i = 0; i < mNumAttributes; ++i) {
         nsCOMPtr<nsINodeInfo> ni;
         if (mAttributes[i].mName.IsAtom()) {
             ni = mNodeInfo->NodeInfoManager()->
                 GetNodeInfo(mAttributes[i].mName.Atom(), nsnull,
@@ -1952,51 +1958,78 @@ nsXULPrototypeElement::Serialize(nsIObje
             NS_ASSERTION(ni, "the nodeinfo should already exist");
         }
         else {
             ni = mAttributes[i].mName.NodeInfo();
         }
 
         index = aNodeInfos->IndexOf(ni);
         NS_ASSERTION(index >= 0, "unknown nsINodeInfo index");
-        rv |= aStream->Write32(index);
+        tmp = aStream->Write32(index);
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
 
         mAttributes[i].mValue.ToString(attributeValue);
-        rv |= aStream->WriteWStringZ(attributeValue.get());
+        tmp = aStream->WriteWStringZ(attributeValue.get());
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
     }
 
     // Now write children
-    rv |= aStream->Write32(PRUint32(mChildren.Length()));
+    tmp = aStream->Write32(PRUint32(mChildren.Length()));
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
     for (i = 0; i < mChildren.Length(); i++) {
         nsXULPrototypeNode* child = mChildren[i].get();
         switch (child->mType) {
         case eType_Element:
         case eType_Text:
         case eType_PI:
-            rv |= child->Serialize(aStream, aGlobal, aNodeInfos);
+            tmp = child->Serialize(aStream, aGlobal, aNodeInfos);
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
             break;
         case eType_Script:
-            rv |= aStream->Write32(child->mType);
+            tmp = aStream->Write32(child->mType);
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
             nsXULPrototypeScript* script = static_cast<nsXULPrototypeScript*>(child);
 
-            rv |= aStream->Write8(script->mOutOfLine);
+            tmp = aStream->Write8(script->mOutOfLine);
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
             if (! script->mOutOfLine) {
-                rv |= script->Serialize(aStream, aGlobal, aNodeInfos);
+                tmp = script->Serialize(aStream, aGlobal, aNodeInfos);
+                if (NS_FAILED(tmp)) {
+                  rv = tmp;
+                }
             } else {
-                rv |= aStream->WriteCompoundObject(script->mSrcURI,
+                tmp = aStream->WriteCompoundObject(script->mSrcURI,
                                                    NS_GET_IID(nsIURI),
                                                    true);
+                if (NS_FAILED(tmp)) {
+                  rv = tmp;
+                }
 
                 if (script->mScriptObject.mObject) {
                     // This may return NS_OK without muxing script->mSrcURI's
                     // data into the cache file, in the case where that
                     // muxed document is already there (written by a prior
                     // session, or by an earlier cache episode during this
                     // session).
-                    rv |= script->SerializeOutOfLine(aStream, aGlobal);
+                    tmp = script->SerializeOutOfLine(aStream, aGlobal);
+                    if (NS_FAILED(tmp)) {
+                      rv = tmp;
+                    }
                 }
             }
             break;
         }
     }
 
     return rv;
 }
@@ -2012,96 +2045,135 @@ nsXULPrototypeElement::Deserialize(nsIOb
     // Read Node Info
     PRUint32 number;
     nsresult rv = aStream->Read32(&number);
     mNodeInfo = aNodeInfos->SafeObjectAt(number);
     if (!mNodeInfo)
         return NS_ERROR_UNEXPECTED;
 
     // Read Attributes
-    rv |= aStream->Read32(&number);
+    nsresult tmp = aStream->Read32(&number);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
     mNumAttributes = PRInt32(number);
 
     PRUint32 i;
     if (mNumAttributes > 0) {
         mAttributes = new nsXULPrototypeAttribute[mNumAttributes];
         if (! mAttributes)
             return NS_ERROR_OUT_OF_MEMORY;
 
         nsAutoString attributeValue;
         for (i = 0; i < mNumAttributes; ++i) {
-            rv |= aStream->Read32(&number);
+            tmp = aStream->Read32(&number);
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
             nsINodeInfo* ni = aNodeInfos->SafeObjectAt(number);
             if (!ni)
                 return NS_ERROR_UNEXPECTED;
 
             mAttributes[i].mName.SetTo(ni);
 
-            rv |= aStream->ReadString(attributeValue);
-            rv |= SetAttrAt(i, attributeValue, aDocumentURI);
+            tmp = aStream->ReadString(attributeValue);
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
+            tmp = SetAttrAt(i, attributeValue, aDocumentURI);
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
         }
     }
 
-    rv |= aStream->Read32(&number);
+    tmp = aStream->Read32(&number);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
     PRUint32 numChildren = PRInt32(number);
 
     if (numChildren > 0) {
         if (!mChildren.SetCapacity(numChildren))
             return NS_ERROR_OUT_OF_MEMORY;
 
         for (i = 0; i < numChildren; i++) {
-            rv |= aStream->Read32(&number);
+            tmp = aStream->Read32(&number);
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
             Type childType = (Type)number;
 
             nsRefPtr<nsXULPrototypeNode> child;
 
             switch (childType) {
             case eType_Element:
                 child = new nsXULPrototypeElement();
                 if (! child)
                     return NS_ERROR_OUT_OF_MEMORY;
                 child->mType = childType;
 
-                rv |= child->Deserialize(aStream, aGlobal, aDocumentURI,
+                tmp = child->Deserialize(aStream, aGlobal, aDocumentURI,
                                          aNodeInfos);
+                if (NS_FAILED(tmp)) {
+                  rv = tmp;
+                }
                 break;
             case eType_Text:
                 child = new nsXULPrototypeText();
                 if (! child)
                     return NS_ERROR_OUT_OF_MEMORY;
                 child->mType = childType;
 
-                rv |= child->Deserialize(aStream, aGlobal, aDocumentURI,
+                tmp = child->Deserialize(aStream, aGlobal, aDocumentURI,
                                          aNodeInfos);
+                if (NS_FAILED(tmp)) {
+                  rv = tmp;
+                }
                 break;
             case eType_PI:
                 child = new nsXULPrototypePI();
                 if (! child)
                     return NS_ERROR_OUT_OF_MEMORY;
                 child->mType = childType;
 
-                rv |= child->Deserialize(aStream, aGlobal, aDocumentURI,
+                tmp = child->Deserialize(aStream, aGlobal, aDocumentURI,
                                          aNodeInfos);
+                if (NS_FAILED(tmp)) {
+                  rv = tmp;
+                }
                 break;
             case eType_Script: {
                 // language version/options obtained during deserialization.
                 nsXULPrototypeScript* script = new nsXULPrototypeScript(0, 0);
                 if (! script)
                     return NS_ERROR_OUT_OF_MEMORY;
                 child = script;
                 child->mType = childType;
 
-                rv |= aStream->ReadBoolean(&script->mOutOfLine);
+                tmp = aStream->ReadBoolean(&script->mOutOfLine);
+                if (NS_FAILED(tmp)) {
+                  rv = tmp;
+                }
                 if (! script->mOutOfLine) {
-                    rv |= script->Deserialize(aStream, aGlobal, aDocumentURI,
+                    tmp = script->Deserialize(aStream, aGlobal, aDocumentURI,
                                               aNodeInfos);
+                    if (NS_FAILED(tmp)) {
+                      rv = tmp;
+                    }
                 } else {
-                    rv |= aStream->ReadObject(true, getter_AddRefs(script->mSrcURI));
+                    tmp = aStream->ReadObject(true, getter_AddRefs(script->mSrcURI));
+                    if (NS_FAILED(tmp)) {
+                      rv = tmp;
+                    }
 
-                    rv |= script->DeserializeOutOfLine(aStream, aGlobal);
+                    tmp = script->DeserializeOutOfLine(aStream, aGlobal);
+                    if (NS_FAILED(tmp)) {
+                      rv = tmp;
+                    }
                 }
                 // If we failed to deserialize, consider deleting 'script'?
                 break;
             }
             default:
                 NS_NOTREACHED("Unexpected child type!");
                 rv = NS_ERROR_UNEXPECTED;
             }
@@ -2267,18 +2339,24 @@ nsXULPrototypeScript::SerializeOutOfLine
      */
     if (exists)
         return NS_OK;
 
     nsCOMPtr<nsIObjectOutputStream> oos;
     rv = cache->GetOutputStream(mSrcURI, getter_AddRefs(oos));
     NS_ENSURE_SUCCESS(rv, rv);
     
-    rv |= Serialize(oos, aGlobal, nsnull);
-    rv |= cache->FinishOutputStream(mSrcURI);
+    nsresult tmp = Serialize(oos, aGlobal, nsnull);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = cache->FinishOutputStream(mSrcURI);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
 
     if (NS_FAILED(rv))
         cache->AbortCaching();
     return rv;
 }
 
 
 nsresult
@@ -2485,17 +2563,20 @@ nsXULPrototypeText::Serialize(nsIObjectO
                               nsIScriptGlobalObject* aGlobal,
                               const nsCOMArray<nsINodeInfo> *aNodeInfos)
 {
     nsresult rv;
 
     // Write basic prototype data
     rv = aStream->Write32(mType);
 
-    rv |= aStream->WriteWStringZ(mValue.get());
+    nsresult tmp = aStream->WriteWStringZ(mValue.get());
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
 
     return rv;
 }
 
 nsresult
 nsXULPrototypeText::Deserialize(nsIObjectInputStream* aStream,
                                 nsIScriptGlobalObject* aGlobal,
                                 nsIURI* aDocumentURI,
@@ -2518,27 +2599,36 @@ nsXULPrototypePI::Serialize(nsIObjectOut
                             nsIScriptGlobalObject* aGlobal,
                             const nsCOMArray<nsINodeInfo> *aNodeInfos)
 {
     nsresult rv;
 
     // Write basic prototype data
     rv = aStream->Write32(mType);
 
-    rv |= aStream->WriteWStringZ(mTarget.get());
-    rv |= aStream->WriteWStringZ(mData.get());
+    nsresult tmp = aStream->WriteWStringZ(mTarget.get());
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = aStream->WriteWStringZ(mData.get());
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
 
     return rv;
 }
 
 nsresult
 nsXULPrototypePI::Deserialize(nsIObjectInputStream* aStream,
                               nsIScriptGlobalObject* aGlobal,
                               nsIURI* aDocumentURI,
                               const nsCOMArray<nsINodeInfo> *aNodeInfos)
 {
     nsresult rv;
 
     rv = aStream->ReadString(mTarget);
-    rv |= aStream->ReadString(mData);
+    nsresult tmp = aStream->ReadString(mData);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
 
     return rv;
 }
--- a/content/xul/document/src/nsXULPrototypeCache.cpp
+++ b/content/xul/document/src/nsXULPrototypeCache.cpp
@@ -528,17 +528,17 @@ CachePrefChangedCallback(const char* aPr
             cache->AbortCaching();
     }
     return 0;
 }
 
 nsresult
 nsXULPrototypeCache::BeginCaching(nsIURI* aURI)
 {
-    nsresult rv;
+    nsresult rv, tmp;
 
     nsCAutoString path;
     aURI->GetPath(path);
     if (!StringEndsWith(path, NS_LITERAL_CSTRING(".xul")))
         return NS_ERROR_NOT_AVAILABLE;
 
     // Test gStartupCache to decide whether this is the first nsXULDocument
     // participating in the serialization.  If gStartupCache is non-null, this document
@@ -601,17 +601,20 @@ nsXULPrototypeCache::BeginCaching(nsIURI
     rv = startupCache->GetBuffer(kXULCacheInfoKey, getter_Transfers(buf), 
                                  &len);
     if (NS_SUCCEEDED(rv))
         rv = NewObjectInputStreamFromBuffer(buf, len, getter_AddRefs(objectInput));
     
     if (NS_SUCCEEDED(rv)) {
         buf.forget();
         rv = objectInput->ReadCString(fileLocale);
-        rv |= objectInput->ReadCString(fileChromePath);
+        tmp = objectInput->ReadCString(fileChromePath);
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
         if (NS_FAILED(rv) ||
             (!fileChromePath.Equals(chromePath) ||
              !fileLocale.Equals(locale))) {
             // Our cache won't be valid in this case, we'll need to rewrite.
             // XXX This blows away work that other consumers (like
             // mozJSComponentLoader) have done, need more fine-grained control.
             startupCache->InvalidateCache();
             rv = NS_ERROR_UNEXPECTED;
@@ -625,19 +628,28 @@ nsXULPrototypeCache::BeginCaching(nsIURI
         nsCOMPtr<nsIObjectOutputStream> objectOutput;
         nsCOMPtr<nsIInputStream> inputStream;
         nsCOMPtr<nsIStorageStream> storageStream;
         rv = NewObjectOutputWrappedStorageStream(getter_AddRefs(objectOutput),
                                                  getter_AddRefs(storageStream),
                                                  false);
         if (NS_SUCCEEDED(rv)) {
             rv = objectOutput->WriteStringZ(locale.get());
-            rv |= objectOutput->WriteStringZ(chromePath.get());
-            rv |= objectOutput->Close();
-            rv |= storageStream->NewInputStream(0, getter_AddRefs(inputStream));
+            tmp = objectOutput->WriteStringZ(chromePath.get());
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
+            tmp = objectOutput->Close();
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
+            tmp = storageStream->NewInputStream(0, getter_AddRefs(inputStream));
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
         }
         if (NS_SUCCEEDED(rv))
             rv = inputStream->Available(&len);
         
         if (NS_SUCCEEDED(rv)) {
             buf = new char[len];
             rv = inputStream->Read(buf, len, &amtRead);
             if (NS_SUCCEEDED(rv) && len == amtRead)
--- a/content/xul/document/src/nsXULPrototypeDocument.cpp
+++ b/content/xul/document/src/nsXULPrototypeDocument.cpp
@@ -246,94 +246,138 @@ nsXULPrototypeDocument::Read(nsIObjectIn
     NS_TIME_FUNCTION;
     nsresult rv;
 
     rv = aStream->ReadObject(true, getter_AddRefs(mURI));
 
     PRUint32 count, i;
     nsCOMPtr<nsIURI> styleOverlayURI;
 
-    rv |= aStream->Read32(&count);
-    if (NS_FAILED(rv)) return rv;
+    nsresult tmp = aStream->Read32(&count);
+    if (NS_FAILED(tmp)) {
+      return tmp;
+    }
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
 
     for (i = 0; i < count; ++i) {
-        rv |= aStream->ReadObject(true, getter_AddRefs(styleOverlayURI));
+        tmp = aStream->ReadObject(true, getter_AddRefs(styleOverlayURI));
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
         mStyleSheetReferences.AppendObject(styleOverlayURI);
     }
 
 
     // nsIPrincipal mNodeInfoManager->mPrincipal
     nsCOMPtr<nsIPrincipal> principal;
-    rv |= aStream->ReadObject(true, getter_AddRefs(principal));
+    tmp = aStream->ReadObject(true, getter_AddRefs(principal));
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
     // Better safe than sorry....
     mNodeInfoManager->SetDocumentPrincipal(principal);
 
 
     // nsIScriptGlobalObject mGlobalObject
     mGlobalObject = NewXULPDGlobalObject();
     if (! mGlobalObject)
         return NS_ERROR_OUT_OF_MEMORY;
 
     mRoot = new nsXULPrototypeElement();
     if (! mRoot)
        return NS_ERROR_OUT_OF_MEMORY;
 
     // nsINodeInfo table
     nsCOMArray<nsINodeInfo> nodeInfos;
 
-    rv |= aStream->Read32(&count);
+    tmp = aStream->Read32(&count);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
     nsAutoString namespaceURI, prefixStr, localName;
     bool prefixIsNull;
     nsCOMPtr<nsIAtom> prefix;
     for (i = 0; i < count; ++i) {
-        rv |= aStream->ReadString(namespaceURI);
-        rv |= aStream->ReadBoolean(&prefixIsNull);
+        tmp = aStream->ReadString(namespaceURI);
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
+        tmp = aStream->ReadBoolean(&prefixIsNull);
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
         if (prefixIsNull) {
             prefix = nsnull;
         } else {
-            rv |= aStream->ReadString(prefixStr);
+            tmp = aStream->ReadString(prefixStr);
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
             prefix = do_GetAtom(prefixStr);
         }
-        rv |= aStream->ReadString(localName);
+        tmp = aStream->ReadString(localName);
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
 
         nsCOMPtr<nsINodeInfo> nodeInfo;
         // Using PR_UINT16_MAX here as we don't know which nodeinfos will be
         // used for attributes and which for elements. And that doesn't really
         // matter.
-        rv |= mNodeInfoManager->GetNodeInfo(localName, prefix, namespaceURI,
+        tmp = mNodeInfoManager->GetNodeInfo(localName, prefix, namespaceURI,
                                             PR_UINT16_MAX,
                                             getter_AddRefs(nodeInfo));
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
         if (!nodeInfos.AppendObject(nodeInfo))
-            rv |= NS_ERROR_OUT_OF_MEMORY;
+          rv = NS_ERROR_OUT_OF_MEMORY;
     }
 
     // Document contents
     PRUint32 type;
     while (NS_SUCCEEDED(rv)) {
-        rv |= aStream->Read32(&type);
+        tmp = aStream->Read32(&type);
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
 
         if ((nsXULPrototypeNode::Type)type == nsXULPrototypeNode::eType_PI) {
             nsRefPtr<nsXULPrototypePI> pi = new nsXULPrototypePI();
             if (! pi) {
-               rv |= NS_ERROR_OUT_OF_MEMORY;
+               rv = NS_ERROR_OUT_OF_MEMORY;
                break;
             }
 
-            rv |= pi->Deserialize(aStream, mGlobalObject, mURI, &nodeInfos);
-            rv |= AddProcessingInstruction(pi);
+            tmp = pi->Deserialize(aStream, mGlobalObject, mURI, &nodeInfos);
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
+            tmp = AddProcessingInstruction(pi);
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
         } else if ((nsXULPrototypeNode::Type)type == nsXULPrototypeNode::eType_Element) {
-            rv |= mRoot->Deserialize(aStream, mGlobalObject, mURI, &nodeInfos);
+            tmp = mRoot->Deserialize(aStream, mGlobalObject, mURI, &nodeInfos);
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
             break;
         } else {
             NS_NOTREACHED("Unexpected prototype node type");
-            rv |= NS_ERROR_FAILURE;
+            rv = NS_ERROR_FAILURE;
             break;
         }
     }
-    rv |= NotifyLoadDone();
+    tmp = NotifyLoadDone();
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
 
     return rv;
 }
 
 static nsresult
 GetNodeInfos(nsXULPrototypeElement* aPrototype,
              nsCOMArray<nsINodeInfo>& aArray)
 {
@@ -384,75 +428,113 @@ nsXULPrototypeDocument::Write(nsIObjectO
 {
     nsresult rv;
 
     rv = aStream->WriteCompoundObject(mURI, NS_GET_IID(nsIURI), true);
     
     PRUint32 count;
 
     count = mStyleSheetReferences.Count();
-    rv |= aStream->Write32(count);
+    nsresult tmp = aStream->Write32(count);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
 
     PRUint32 i;
     for (i = 0; i < count; ++i) {
-        rv |= aStream->WriteCompoundObject(mStyleSheetReferences[i],
+        tmp = aStream->WriteCompoundObject(mStyleSheetReferences[i],
                                            NS_GET_IID(nsIURI), true);
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
     }
 
     // nsIPrincipal mNodeInfoManager->mPrincipal
-    rv |= aStream->WriteObject(mNodeInfoManager->DocumentPrincipal(),
+    tmp = aStream->WriteObject(mNodeInfoManager->DocumentPrincipal(),
                                true);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
     
 #ifdef DEBUG
     // XXX Worrisome if we're caching things without system principal.
     if (!nsContentUtils::IsSystemPrincipal(mNodeInfoManager->DocumentPrincipal())) {
         NS_WARNING("Serializing document without system principal");
     }
 #endif
 
     // nsINodeInfo table
     nsCOMArray<nsINodeInfo> nodeInfos;
-    if (mRoot)
-        rv |= GetNodeInfos(mRoot, nodeInfos);
+    if (mRoot) {
+      tmp = GetNodeInfos(mRoot, nodeInfos);
+      if (NS_FAILED(tmp)) {
+        rv = tmp;
+      }
+    }
 
     PRUint32 nodeInfoCount = nodeInfos.Count();
-    rv |= aStream->Write32(nodeInfoCount);
+    tmp = aStream->Write32(nodeInfoCount);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
     for (i = 0; i < nodeInfoCount; ++i) {
         nsINodeInfo *nodeInfo = nodeInfos[i];
         NS_ENSURE_TRUE(nodeInfo, NS_ERROR_FAILURE);
 
         nsAutoString namespaceURI;
-        rv |= nodeInfo->GetNamespaceURI(namespaceURI);
-        rv |= aStream->WriteWStringZ(namespaceURI.get());
+        tmp = nodeInfo->GetNamespaceURI(namespaceURI);
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
+        tmp = aStream->WriteWStringZ(namespaceURI.get());
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
 
         nsAutoString prefix;
         nodeInfo->GetPrefix(prefix);
         bool nullPrefix = DOMStringIsNull(prefix);
-        rv |= aStream->WriteBoolean(nullPrefix);
+        tmp = aStream->WriteBoolean(nullPrefix);
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
         if (!nullPrefix) {
-            rv |= aStream->WriteWStringZ(prefix.get());
+            tmp = aStream->WriteWStringZ(prefix.get());
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
         }
 
         nsAutoString localName;
         nodeInfo->GetName(localName);
-        rv |= aStream->WriteWStringZ(localName.get());
+        tmp = aStream->WriteWStringZ(localName.get());
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
     }
 
     // Now serialize the document contents
     nsIScriptGlobalObject* globalObject = GetScriptGlobalObject();
     NS_ENSURE_TRUE(globalObject, NS_ERROR_UNEXPECTED);
 
     count = mProcessingInstructions.Length();
     for (i = 0; i < count; ++i) {
         nsXULPrototypePI* pi = mProcessingInstructions[i];
-        rv |= pi->Serialize(aStream, globalObject, &nodeInfos);
+        tmp = pi->Serialize(aStream, globalObject, &nodeInfos);
+        if (NS_FAILED(tmp)) {
+          rv = tmp;
+        }
     }
 
-    if (mRoot)
-        rv |= mRoot->Serialize(aStream, globalObject, &nodeInfos);
+    if (mRoot) {
+      tmp = mRoot->Serialize(aStream, globalObject, &nodeInfos);
+      if (NS_FAILED(tmp)) {
+        rv = tmp;
+      }
+    }
  
     return rv;
 }
 
 
 //----------------------------------------------------------------------
 //
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -4265,17 +4265,18 @@ nsDocShell::LoadErrorPage(nsIURI *aURI, 
         mLSHE->AbandonBFCacheEntry();
     }
 
     nsCAutoString url;
     nsCAutoString charset;
     if (aURI)
     {
         nsresult rv = aURI->GetSpec(url);
-        rv |= aURI->GetOriginCharset(charset);
+        NS_ENSURE_SUCCESS(rv, rv);
+        rv = aURI->GetOriginCharset(charset);
         NS_ENSURE_SUCCESS(rv, rv);
     }
     else if (aURL)
     {
         // We need a URI object to store a session history entry, so make up a URI
         nsresult rv = NS_NewURI(getter_AddRefs(mFailedURI), "about:blank");
         NS_ENSURE_SUCCESS(rv, rv);
 
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -8791,23 +8791,26 @@ nsHTMLDocumentSH::GetDocumentAllNodeList
       }
     }
   } else {
     // No node list for this document.all yet, create one...
 
     nsRefPtr<nsContentList> list =
       domdoc->GetElementsByTagName(NS_LITERAL_STRING("*"));
     if (!list) {
-      rv |= NS_ERROR_OUT_OF_MEMORY;
+      rv = NS_ERROR_OUT_OF_MEMORY;
     }
 
     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
-    rv |= WrapNative(cx, JS_GetGlobalForScopeChain(cx),
-                     static_cast<nsINodeList*>(list), list, false,
-                     &collection, getter_AddRefs(holder));
+    nsresult tmp = WrapNative(cx, JS_GetGlobalForScopeChain(cx),
+                              static_cast<nsINodeList*>(list), list, false,
+                              &collection, getter_AddRefs(holder));
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
 
     list.forget(nodeList);
 
     // ... and store it in our reserved slot.
     JS_SetReservedSlot(obj, 0, collection);
   }
 
   if (NS_FAILED(rv)) {
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -751,42 +751,60 @@ nsJSContext::DOMOperationCallback(JSCont
 
   // Get localizable strings
   nsXPIDLString title, msg, stopButton, waitButton, debugButton, neverShowDlg;
 
   rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                           "KillScriptTitle",
                                           title);
 
-  rv |= nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
+  nsresult tmp = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                            "StopScriptButton",
                                            stopButton);
-
-  rv |= nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+
+  tmp = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                            "WaitForScriptButton",
                                            waitButton);
-
-  rv |= nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+
+  tmp = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                            "DontAskAgain",
                                            neverShowDlg);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
 
 
   if (debugPossible) {
-    rv |= nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
+    tmp = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                              "DebugScriptButton",
                                              debugButton);
-
-    rv |= nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+
+    tmp = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                              "KillScriptWithDebugMessage",
                                              msg);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
   }
   else {
-    rv |= nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
+    tmp = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                              "KillScriptMessage",
                                              msg);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
   }
 
   //GetStringFromName can return NS_OK and still give NULL string
   if (NS_FAILED(rv) || !title || !msg || !stopButton || !waitButton ||
       (!debugButton && debugPossible) || !neverShowDlg) {
     NS_ERROR("Failed to get localized strings.");
     return JS_TRUE;
   }
--- a/embedding/components/find/src/nsFind.cpp
+++ b/embedding/components/find/src/nsFind.cpp
@@ -374,29 +374,29 @@ nsFindContentIterator::SetupInnerIterato
     if (aContent == mEndOuterContent) {
       innerRange->SetEnd(mEndNode, mEndOffset);
     }
     // Note: we just init here. We do First() or Last() later. 
     mInnerIterator->Init(innerRange);
 
     // make sure to place the outer-iterator outside
     // the text control so that we don't go there again.
-    nsresult res;
+    nsresult res1, res2;
     nsCOMPtr<nsIDOMNode> outerNode(do_QueryInterface(aContent));
     if (!mFindBackward) { // find forward
       // cut the outer-iterator after the current node
-      res = outerRange->SetEnd(mEndNode, mEndOffset);
-      res |= outerRange->SetStartAfter(outerNode);
+      res1 = outerRange->SetEnd(mEndNode, mEndOffset);
+      res2 = outerRange->SetStartAfter(outerNode);
     }
     else { // find backward
       // cut the outer-iterator before the current node
-      res = outerRange->SetStart(mStartNode, mStartOffset);
-      res |= outerRange->SetEndBefore(outerNode);
+      res1 = outerRange->SetStart(mStartNode, mStartOffset);
+      res2 = outerRange->SetEndBefore(outerNode);
     }
-    if (NS_FAILED(res)) {
+    if (NS_FAILED(res1) || NS_FAILED(res2)) {
       // we are done with the outer-iterator, the 
       // inner-iterator will traverse what we want
       outerRange->Collapse(true);
     }
 
     // Note: we just re-init here, using the segment of our search range that
     // is yet to be visited. Thus when we later do mOuterIterator->First() [or
     // mOuterIterator->Last()], we will effectively be on the next node [or
--- a/image/src/imgRequest.cpp
+++ b/image/src/imgRequest.cpp
@@ -1039,19 +1039,19 @@ NS_IMETHODIMP imgRequest::OnDataAvailabl
           if (len > 0) {
             PRUint32 sizeHint = (PRUint32) len;
             sizeHint = NS_MIN<PRUint32>(sizeHint, 20000000); /* Bound by something reasonable */
             RasterImage* rasterImage = static_cast<RasterImage*>(mImage.get());
             rv = rasterImage->SetSourceSizeHint(sizeHint);
             if (NS_FAILED(rv)) {
               // Flush memory, try to get some back, and try again
               rv = nsMemory::HeapMinimize(true);
-              rv |= rasterImage->SetSourceSizeHint(sizeHint);
+              nsresult rv2 = rasterImage->SetSourceSizeHint(sizeHint);
               // If we've still failed at this point, things are going downhill
-              if (NS_FAILED(rv)) {
+              if (NS_FAILED(rv) || NS_FAILED(rv2)) {
                 NS_WARNING("About to hit OOM in imagelib!");
               }
             }
           }
         }
       }
     }
 
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1134,25 +1134,34 @@ DocumentViewerImpl::PermitUnload(bool aC
 
     nsCOMPtr<nsIPrompt> prompt = do_GetInterface(docShellNode);
 
     if (prompt) {
       nsXPIDLString title, message, stayLabel, leaveLabel;
       rv  = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                                "OnBeforeUnloadTitle",
                                                title);
-      rv |= nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
+      nsresult tmp = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                                "OnBeforeUnloadMessage",
                                                message);
-      rv |= nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
+      if (NS_FAILED(tmp)) {
+        rv = tmp;
+      }
+      tmp = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                                "OnBeforeUnloadLeaveButton",
                                                leaveLabel);
-      rv |= nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
+      if (NS_FAILED(tmp)) {
+        rv = tmp;
+      }
+      tmp = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                                "OnBeforeUnloadStayButton",
                                                stayLabel);
+      if (NS_FAILED(tmp)) {
+        rv = tmp;
+      }
 
       if (NS_FAILED(rv) || !title || !message || !stayLabel || !leaveLabel) {
         NS_ERROR("Failed to get strings from dom.properties!");
         return NS_OK;
       }
 
       // Although the exact value is ignored, we must not pass invalid
       // bool values through XPConnect.
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -4217,18 +4217,18 @@ nsLayoutUtils::SurfaceFromElement(nsIIma
   rv = imgContainer->GetFrame(whichFrame,
                               frameFlags,
                               getter_AddRefs(framesurf));
   if (NS_FAILED(rv))
     return result;
 
   PRInt32 imgWidth, imgHeight;
   rv = imgContainer->GetWidth(&imgWidth);
-  rv |= imgContainer->GetHeight(&imgHeight);
-  if (NS_FAILED(rv))
+  nsresult rv2 = imgContainer->GetHeight(&imgHeight);
+  if (NS_FAILED(rv) || NS_FAILED(rv2))
     return result;
 
   if (wantImageSurface && framesurf->GetType() != gfxASurface::SurfaceTypeImage) {
     forceCopy = true;
   }
 
   nsRefPtr<gfxASurface> gfxsurf = framesurf;
   if (forceCopy) {
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -4823,17 +4823,20 @@ Selection::Extend(nsINode* aParentNode, 
   nsRefPtr<nsRange> difRange = new nsRange();
   if ((result1 == 0 && result3 < 0) || (result1 <= 0 && result2 < 0)){//a1,2  a,1,2
     //select from 1 to 2 unless they are collapsed
     res = range->SetEnd(aParentNode, aOffset);
     if (NS_FAILED(res))
       return res;
     dir = eDirNext;
     res = difRange->SetEnd(range->GetEndParent(), range->EndOffset());
-    res |= difRange->SetStart(focusNode, focusOffset);
+    nsresult tmp = difRange->SetStart(focusNode, focusOffset);
+    if (NS_FAILED(tmp)) {
+      res = tmp;
+    }
     if (NS_FAILED(res))
       return res;
     selectFrames(presContext, difRange , true);
     res = SetAnchorFocusToRange(range);
     if (NS_FAILED(res))
       return res;
   }
   else if (result1 == 0 && result3 > 0){//2, a1
@@ -4845,17 +4848,20 @@ Selection::Extend(nsINode* aParentNode, 
     selectFrames(presContext, range, true);
     res = SetAnchorFocusToRange(range);
     if (NS_FAILED(res))
       return res;
   }
   else if (result3 <= 0 && result2 >= 0) {//a,2,1 or a2,1 or a,21 or a21
     //deselect from 2 to 1
     res = difRange->SetEnd(focusNode, focusOffset);
-    res |= difRange->SetStart(aParentNode, aOffset);
+    nsresult tmp = difRange->SetStart(aParentNode, aOffset);
+    if (NS_FAILED(tmp)) {
+      res = tmp;
+    }
     if (NS_FAILED(res))
       return res;
 
     res = range->SetEnd(aParentNode, aOffset);
     if (NS_FAILED(res))
       return res;
     res = SetAnchorFocusToRange(range);
     if (NS_FAILED(res))
@@ -4871,17 +4877,20 @@ Selection::Extend(nsINode* aParentNode, 
         return res;
     }
     dir = eDirNext;
     res = range->SetEnd(aParentNode, aOffset);
     if (NS_FAILED(res))
       return res;
     if (focusNode != anchorNode || focusOffset != anchorOffset) {//if collapsed diff dont do anything
       res = difRange->SetStart(focusNode, focusOffset);
-      res |= difRange->SetEnd(anchorNode, anchorOffset);
+      nsresult tmp = difRange->SetEnd(anchorNode, anchorOffset);
+      if (NS_FAILED(tmp)) {
+        res = tmp;
+      }
       if (NS_FAILED(res))
         return res;
       res = SetAnchorFocusToRange(range);
       if (NS_FAILED(res))
         return res;
       //deselect from 1 to a
       selectFrames(presContext, difRange , false);
     }
@@ -4892,17 +4901,20 @@ Selection::Extend(nsINode* aParentNode, 
         return res;
     }
     //select from a to 2
     selectFrames(presContext, range , true);
   }
   else if (result2 <= 0 && result3 >= 0) {//1,2,a or 12,a or 1,2a or 12a
     //deselect from 1 to 2
     res = difRange->SetEnd(aParentNode, aOffset);
-    res |= difRange->SetStart(focusNode, focusOffset);
+    nsresult tmp = difRange->SetStart(focusNode, focusOffset);
+    if (NS_FAILED(tmp)) {
+      res = tmp;
+    }
     if (NS_FAILED(res))
       return res;
     dir = eDirPrevious;
     res = range->SetStart(aParentNode, aOffset);
     if (NS_FAILED(res))
       return res;
 
     res = SetAnchorFocusToRange(range);
@@ -4918,18 +4930,24 @@ Selection::Extend(nsINode* aParentNode, 
     }
     dir = eDirPrevious;
     res = range->SetStart(aParentNode, aOffset);
     if (NS_FAILED(res))
       return res;
     //deselect from a to 1
     if (focusNode != anchorNode || focusOffset!= anchorOffset) {//if collapsed diff dont do anything
       res = difRange->SetStart(anchorNode, anchorOffset);
-      res |= difRange->SetEnd(focusNode, focusOffset);
-      res |= SetAnchorFocusToRange(range);
+      nsresult tmp = difRange->SetEnd(focusNode, focusOffset);
+      if (NS_FAILED(tmp)) {
+        res = tmp;
+      }
+      tmp = SetAnchorFocusToRange(range);
+      if (NS_FAILED(tmp)) {
+        res = tmp;
+      }
       if (NS_FAILED(res))
         return res;
       selectFrames(presContext, difRange, false);
     }
     else
     {
       res = SetAnchorFocusToRange(range);
       if (NS_FAILED(res))
@@ -4940,17 +4958,20 @@ Selection::Extend(nsINode* aParentNode, 
   }
   else if (result2 >= 0 && result1 >= 0) {//2,1,a or 21,a or 2,1a or 21a
     //select from 2 to 1
     res = range->SetStart(aParentNode, aOffset);
     if (NS_FAILED(res))
       return res;
     dir = eDirPrevious;
     res = difRange->SetEnd(focusNode, focusOffset);
-    res |= difRange->SetStart(range->GetStartParent(), range->StartOffset());
+    nsresult tmp = difRange->SetStart(range->GetStartParent(), range->StartOffset());
+    if (NS_FAILED(tmp)) {
+      res = tmp;
+    }
     if (NS_FAILED(res))
       return res;
 
     selectFrames(presContext, difRange, true);
     res = SetAnchorFocusToRange(range);
     if (NS_FAILED(res))
       return res;
   }
--- a/netwerk/base/public/nsNetUtil.h
+++ b/netwerk/base/public/nsNetUtil.h
@@ -186,27 +186,35 @@ NS_NewChannel(nsIChannel           **res
 {
     nsresult rv;
     nsCOMPtr<nsIIOService> grip;
     rv = net_EnsureIOService(&ioService, grip);
     if (ioService) {
         nsCOMPtr<nsIChannel> chan;
         rv = ioService->NewChannelFromURI(uri, getter_AddRefs(chan));
         if (NS_SUCCEEDED(rv)) {
-            if (loadGroup)
-                rv |= chan->SetLoadGroup(loadGroup);
-            if (callbacks)
-                rv |= chan->SetNotificationCallbacks(callbacks);
+            if (loadGroup) {
+                rv = chan->SetLoadGroup(loadGroup);
+            }
+            if (callbacks) {
+                nsresult tmp = chan->SetNotificationCallbacks(callbacks);
+                if (NS_FAILED(tmp)) {
+                    rv = tmp;
+                }
+            }
             if (loadFlags != nsIRequest::LOAD_NORMAL) {
                 // Retain the LOAD_REPLACE load flag if set.
                 nsLoadFlags normalLoadFlags = 0;
                 chan->GetLoadFlags(&normalLoadFlags);
-                rv |= chan->SetLoadFlags(loadFlags | 
-                                         (normalLoadFlags & 
-                                          nsIChannel::LOAD_REPLACE));
+                nsresult tmp = chan->SetLoadFlags(loadFlags |
+                                                  (normalLoadFlags &
+                                                   nsIChannel::LOAD_REPLACE));
+                if (NS_FAILED(tmp)) {
+                    rv = tmp;
+                }
             }
             if (channelPolicy) {
                 nsCOMPtr<nsIWritablePropertyBag2> props = do_QueryInterface(chan);
                 if (props) {
                     props->SetPropertyAsInterface(NS_CHANNEL_PROP_CHANNEL_POLICY,
                                                   channelPolicy);
                 }
             }
@@ -401,27 +409,34 @@ NS_NewInputStreamChannel(nsIChannel     
                          const nsACString &contentType,
                          const nsACString *contentCharset)
 {
     nsresult rv;
     nsCOMPtr<nsIInputStreamChannel> isc =
         do_CreateInstance(NS_INPUTSTREAMCHANNEL_CONTRACTID, &rv);
     if (NS_FAILED(rv))
         return rv;
-    rv |= isc->SetURI(uri);
-    rv |= isc->SetContentStream(stream);
+    rv = isc->SetURI(uri);
+    nsresult tmp = isc->SetContentStream(stream);
+    if (NS_FAILED(tmp)) {
+        rv = tmp;
+    }
     if (NS_FAILED(rv))
         return rv;
     nsCOMPtr<nsIChannel> chan = do_QueryInterface(isc, &rv);
     if (NS_FAILED(rv))
         return rv;
     if (!contentType.IsEmpty())
-        rv |= chan->SetContentType(contentType);
-    if (contentCharset && !contentCharset->IsEmpty())
-        rv |= chan->SetContentCharset(*contentCharset);
+        rv = chan->SetContentType(contentType);
+    if (contentCharset && !contentCharset->IsEmpty()) {
+        tmp = chan->SetContentCharset(*contentCharset);
+        if (NS_FAILED(tmp)) {
+            rv = tmp;
+        }
+    }
     if (NS_SUCCEEDED(rv)) {
         *result = nsnull;
         chan.swap(*result);
     }
     return rv;
 }
 
 inline nsresult
--- a/netwerk/base/src/nsURIChecker.cpp
+++ b/netwerk/base/src/nsURIChecker.cpp
@@ -93,17 +93,20 @@ nsURIChecker::CheckStatus()
             // save the current value of mChannel in case we can't issue
             // the new request for some reason.
             nsCOMPtr<nsIChannel> lastChannel = mChannel;
 
             nsCOMPtr<nsIURI> uri;
             PRUint32 loadFlags;
 
             rv  = lastChannel->GetOriginalURI(getter_AddRefs(uri));
-            rv |= lastChannel->GetLoadFlags(&loadFlags);
+            nsresult tmp = lastChannel->GetLoadFlags(&loadFlags);
+            if (NS_FAILED(tmp)) {
+              rv = tmp;
+            }
 
             // XXX we are carrying over the load flags, but what about other
             // parameters that may have been set on lastChannel??
 
             if (NS_SUCCEEDED(rv)) {
                 rv = Init(uri);
                 if (NS_SUCCEEDED(rv)) {
                     rv = mChannel->SetLoadFlags(loadFlags);
--- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp
+++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp
@@ -920,24 +920,45 @@ nsOfflineCacheDevice::UpdateEntry(nsCach
   rec.fetchCount = entry->FetchCount();
   rec.lastFetched = PRTimeFromSeconds(entry->LastFetched());
   rec.lastModified = PRTimeFromSeconds(entry->LastModified());
   rec.expirationTime = PRTimeFromSeconds(entry->ExpirationTime());
 
   AutoResetStatement statement(mStatement_UpdateEntry);
 
   nsresult rv;
-  rv  = statement->BindBlobByIndex(0, rec.metaData, rec.metaDataLen);
-  rv |= statement->BindInt32ByIndex(1, rec.dataSize);
-  rv |= statement->BindInt32ByIndex(2, rec.fetchCount);
-  rv |= statement->BindInt64ByIndex(3, rec.lastFetched);
-  rv |= statement->BindInt64ByIndex(4, rec.lastModified);
-  rv |= statement->BindInt64ByIndex(5, rec.expirationTime);
-  rv |= statement->BindUTF8StringByIndex(6, nsDependentCString(cid));
-  rv |= statement->BindUTF8StringByIndex(7, nsDependentCString(key));
+  rv = statement->BindBlobByIndex(0, rec.metaData, rec.metaDataLen);
+  nsresult tmp = statement->BindInt32ByIndex(1, rec.dataSize);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindInt32ByIndex(2, rec.fetchCount);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindInt64ByIndex(3, rec.lastFetched);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindInt64ByIndex(4, rec.lastModified);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindInt64ByIndex(5, rec.expirationTime);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindUTF8StringByIndex(6, nsDependentCString(cid));
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindUTF8StringByIndex(7, nsDependentCString(key));
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool hasRows;
   rv = statement->ExecuteStep(&hasRows);
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ASSERTION(!hasRows, "UPDATE should not result in output");
   return rv;
@@ -949,20 +970,25 @@ nsOfflineCacheDevice::UpdateEntrySize(ns
   // Decompose the key into "ClientID" and "Key"
   nsCAutoString keyBuf;
   const char *cid, *key;
   if (!DecomposeCacheEntryKey(entry->Key(), &cid, &key, keyBuf))
     return NS_ERROR_UNEXPECTED;
 
   AutoResetStatement statement(mStatement_UpdateEntrySize);
 
-  nsresult rv;
-  rv  = statement->BindInt32ByIndex(0, newSize);
-  rv |= statement->BindUTF8StringByIndex(1, nsDependentCString(cid));
-  rv |= statement->BindUTF8StringByIndex(2, nsDependentCString(key));
+  nsresult rv = statement->BindInt32ByIndex(0, newSize);
+  nsresult tmp = statement->BindUTF8StringByIndex(1, nsDependentCString(cid));
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindUTF8StringByIndex(2, nsDependentCString(key));
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool hasRows;
   rv = statement->ExecuteStep(&hasRows);
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ASSERTION(!hasRows, "UPDATE should not result in output");
   return rv;
@@ -981,20 +1007,20 @@ nsOfflineCacheDevice::DeleteEntry(nsCach
   // Decompose the key into "ClientID" and "Key"
   nsCAutoString keyBuf;
   const char *cid, *key;
   if (!DecomposeCacheEntryKey(entry->Key(), &cid, &key, keyBuf))
     return NS_ERROR_UNEXPECTED;
 
   AutoResetStatement statement(mStatement_DeleteEntry);
 
-  nsresult rv;
-  rv  = statement->BindUTF8StringByIndex(0, nsDependentCString(cid));
-  rv |= statement->BindUTF8StringByIndex(1, nsDependentCString(key));
+  nsresult rv = statement->BindUTF8StringByIndex(0, nsDependentCString(cid));
+  nsresult rv2 = statement->BindUTF8StringByIndex(1, nsDependentCString(key));
   NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_SUCCESS(rv2, rv2);
 
   bool hasRows;
   rv = statement->ExecuteStep(&hasRows);
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ASSERTION(!hasRows, "DELETE should not result in output");
   return rv;
 }
@@ -1346,20 +1372,20 @@ nsOfflineCacheDevice::FindEntry(nsCStrin
   // Decompose the key into "ClientID" and "Key"
   nsCAutoString keyBuf;
   const char *cid, *key;
   if (!DecomposeCacheEntryKey(fullKey, &cid, &key, keyBuf))
     return nsnull;
 
   AutoResetStatement statement(mStatement_FindEntry);
 
-  nsresult rv;
-  rv  = statement->BindUTF8StringByIndex(0, nsDependentCString(cid));
-  rv |= statement->BindUTF8StringByIndex(1, nsDependentCString(key));
+  nsresult rv = statement->BindUTF8StringByIndex(0, nsDependentCString(cid));
+  nsresult rv2 = statement->BindUTF8StringByIndex(1, nsDependentCString(key));
   NS_ENSURE_SUCCESS(rv, nsnull);
+  NS_ENSURE_SUCCESS(rv2, nsnull);
 
   bool hasRows;
   rv = statement->ExecuteStep(&hasRows);
   if (NS_FAILED(rv) || !hasRows)
     return nsnull; // entry not found
 
   nsOfflineCacheRecord rec;
   statement->GetSharedBlob(0, &rec.metaDataLen,
@@ -1483,26 +1509,49 @@ nsOfflineCacheDevice::BindEntry(nsCacheE
   rec.dataSize = 0;
   rec.fetchCount = entry->FetchCount();
   rec.lastFetched = PRTimeFromSeconds(entry->LastFetched());
   rec.lastModified = PRTimeFromSeconds(entry->LastModified());
   rec.expirationTime = PRTimeFromSeconds(entry->ExpirationTime());
 
   AutoResetStatement statement(mStatement_BindEntry);
 
-  nsresult rv;
-  rv  = statement->BindUTF8StringByIndex(0, nsDependentCString(rec.clientID));
-  rv |= statement->BindUTF8StringByIndex(1, nsDependentCString(rec.key));
-  rv |= statement->BindBlobByIndex(2, rec.metaData, rec.metaDataLen);
-  rv |= statement->BindInt32ByIndex(3, rec.generation);
-  rv |= statement->BindInt32ByIndex(4, rec.dataSize);
-  rv |= statement->BindInt32ByIndex(5, rec.fetchCount);
-  rv |= statement->BindInt64ByIndex(6, rec.lastFetched);
-  rv |= statement->BindInt64ByIndex(7, rec.lastModified);
-  rv |= statement->BindInt64ByIndex(8, rec.expirationTime);
+  nsresult rv = statement->BindUTF8StringByIndex(0, nsDependentCString(rec.clientID));
+  nsresult tmp = statement->BindUTF8StringByIndex(1, nsDependentCString(rec.key));
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindBlobByIndex(2, rec.metaData, rec.metaDataLen);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindInt32ByIndex(3, rec.generation);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindInt32ByIndex(4, rec.dataSize);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindInt32ByIndex(5, rec.fetchCount);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindInt64ByIndex(6, rec.lastFetched);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindInt64ByIndex(7, rec.lastModified);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
+  tmp = statement->BindInt64ByIndex(8, rec.expirationTime);
+  if (NS_FAILED(tmp)) {
+    rv = tmp;
+  }
   NS_ENSURE_SUCCESS(rv, rv);
   
   bool hasRows;
   rv = statement->ExecuteStep(&hasRows);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ASSERTION(!hasRows, "INSERT should not result in output");
 
   entry->SetData(binding);
--- a/netwerk/protocol/http/nsHttpDigestAuth.cpp
+++ b/netwerk/protocol/http/nsHttpDigestAuth.cpp
@@ -74,42 +74,42 @@ nsHttpDigestAuth::MD5Hash(const char *bu
 }
 
 nsresult
 nsHttpDigestAuth::GetMethodAndPath(nsIHttpAuthenticableChannel *authChannel,
                                    bool                         isProxyAuth,
                                    nsCString                   &httpMethod,
                                    nsCString                   &path)
 {
-  nsresult rv;
+  nsresult rv, rv2;
   nsCOMPtr<nsIURI> uri;
   rv = authChannel->GetURI(getter_AddRefs(uri));
   if (NS_SUCCEEDED(rv)) {
     bool proxyMethodIsConnect;
     rv = authChannel->GetProxyMethodIsConnect(&proxyMethodIsConnect);
     if (NS_SUCCEEDED(rv)) {
       if (proxyMethodIsConnect && isProxyAuth) {
         httpMethod.AssignLiteral("CONNECT");
         //
         // generate hostname:port string. (unfortunately uri->GetHostPort
         // leaves out the port if it matches the default value, so we can't
         // just call it.)
         //
         PRInt32 port;
-        rv  = uri->GetAsciiHost(path);
-        rv |= uri->GetPort(&port);
-        if (NS_SUCCEEDED(rv)) {
+        rv = uri->GetAsciiHost(path);
+        rv2 = uri->GetPort(&port);
+        if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(rv2)) {
           path.Append(':');
           path.AppendInt(port < 0 ? NS_HTTPS_DEFAULT_PORT : port);
         }
       }
       else { 
-        rv  = authChannel->GetRequestMethod(httpMethod);
-        rv |= uri->GetPath(path);
-        if (NS_SUCCEEDED(rv)) {
+        rv = authChannel->GetRequestMethod(httpMethod);
+        rv2 = uri->GetPath(path);
+        if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(rv2)) {
           //
           // strip any fragment identifier from the URL path.
           //
           PRInt32 ref = path.RFindChar('#');
           if (ref != kNotFound)
             path.Truncate(ref);
           //
           // make sure we escape any UTF-8 characters in the URI path.  the
--- a/rdf/datasource/src/nsFileSystemDataSource.cpp
+++ b/rdf/datasource/src/nsFileSystemDataSource.cpp
@@ -100,57 +100,96 @@ FileSystemDataSource::Init()
 {
     nsresult rv;
 
     mRDFService = do_GetService("@mozilla.org/rdf/rdf-service;1");
     NS_ENSURE_TRUE(mRDFService, NS_ERROR_FAILURE);
 
     rv =  mRDFService->GetResource(NS_LITERAL_CSTRING("NC:FilesRoot"),
                                    getter_AddRefs(mNC_FileSystemRoot));
-    rv |= mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "child"),
+    nsresult tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "child"),
                                    getter_AddRefs(mNC_Child));
-    rv |= mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "Name"),
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "Name"),
                                    getter_AddRefs(mNC_Name));
-    rv |= mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "URL"),
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "URL"),
                                    getter_AddRefs(mNC_URL));
-    rv |= mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "Icon"),
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "Icon"),
                                    getter_AddRefs(mNC_Icon));
-    rv |= mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "Content-Length"),
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "Content-Length"),
                                    getter_AddRefs(mNC_Length));
-    rv |= mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "IsDirectory"),
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "IsDirectory"),
                                    getter_AddRefs(mNC_IsDirectory));
-    rv |= mRDFService->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastModifiedDate"),
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(WEB_NAMESPACE_URI "LastModifiedDate"),
                                    getter_AddRefs(mWEB_LastMod));
-    rv |= mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "FileSystemObject"),
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "FileSystemObject"),
                                    getter_AddRefs(mNC_FileSystemObject));
-    rv |= mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "pulse"),
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI  "pulse"),
                                    getter_AddRefs(mNC_pulse));
-    rv |= mRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "instanceOf"),
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "instanceOf"),
                                    getter_AddRefs(mRDF_InstanceOf));
-    rv |= mRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"),
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"),
                                    getter_AddRefs(mRDF_type));
 
     static const PRUnichar kTrue[] = {'t','r','u','e','\0'};
     static const PRUnichar kFalse[] = {'f','a','l','s','e','\0'};
 
-    rv |= mRDFService->GetLiteral(kTrue, getter_AddRefs(mLiteralTrue));
-    rv |= mRDFService->GetLiteral(kFalse, getter_AddRefs(mLiteralFalse));
+    tmp = mRDFService->GetLiteral(kTrue, getter_AddRefs(mLiteralTrue));
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
+    tmp = mRDFService->GetLiteral(kFalse, getter_AddRefs(mLiteralFalse));
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
     NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
 #ifdef USE_NC_EXTENSION
     rv = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "extension"),
                                   getter_AddRefs(mNC_extension));
     NS_ENSURE_SUCCESS(rv, rv);
 #endif
 
 #ifdef XP_WIN
     rv =  mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "IEFavorite"),
                                   getter_AddRefs(mNC_IEFavoriteObject));
-    rv |= mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "IEFavoriteFolder"),
+    tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(NC_NAMESPACE_URI "IEFavoriteFolder"),
                                    getter_AddRefs(mNC_IEFavoriteFolder));
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
     NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
     nsCOMPtr<nsIFile> file;
     NS_GetSpecialDirectory(NS_WIN_FAVORITES_DIR, getter_AddRefs(file));
     if (file)
     {
         nsCOMPtr<nsIURI> furi;
         NS_NewFileURI(getter_AddRefs(furi), file);
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -165,17 +165,20 @@ nsXREDirProvider::GetUserProfilesRootDir
                                      false,
                                      aProfileName, aAppName, aVendorName);
 
   if (NS_SUCCEEDED(rv)) {
 #if !defined(XP_UNIX) || defined(XP_MACOSX)
     rv = file->AppendNative(NS_LITERAL_CSTRING("Profiles"));
 #endif
     // We must create the profile directory here if it does not exist.
-    rv |= EnsureDirectoryExists(file);
+    nsresult tmp = EnsureDirectoryExists(file);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
   }
   file.swap(*aResult);
   return rv;
 }
 
 nsresult
 nsXREDirProvider::GetUserProfilesLocalDir(nsIFile** aResult,
                                           const nsACString* aProfileName,
@@ -187,17 +190,20 @@ nsXREDirProvider::GetUserProfilesLocalDi
                                      true,
                                      aProfileName, aAppName, aVendorName);
 
   if (NS_SUCCEEDED(rv)) {
 #if !defined(XP_UNIX) || defined(XP_MACOSX)
     rv = file->AppendNative(NS_LITERAL_CSTRING("Profiles"));
 #endif
     // We must create the profile directory here if it does not exist.
-    rv |= EnsureDirectoryExists(file);
+    nsresult tmp = EnsureDirectoryExists(file);
+    if (NS_FAILED(tmp)) {
+      rv = tmp;
+    }
   }
   file.swap(*aResult);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent,
 			  nsIFile** aFile)
@@ -390,18 +396,24 @@ nsXREDirProvider::GetFile(const char* aP
     else if (!strcmp(aProperty, NS_APP_STORAGE_50_FILE)) {
       rv = file->AppendNative(NS_LITERAL_CSTRING("storage.sdb"));
     }
     else if (!strcmp(aProperty, NS_APP_DOWNLOADS_50_FILE)) {
       rv = file->AppendNative(NS_LITERAL_CSTRING("downloads.rdf"));
     }
     else if (!strcmp(aProperty, NS_APP_PREFS_OVERRIDE_DIR)) {
       rv = mProfileDir->Clone(getter_AddRefs(file));
-      rv |= file->AppendNative(NS_LITERAL_CSTRING(PREF_OVERRIDE_DIRNAME));
-      rv |= EnsureDirectoryExists(file);
+      nsresult tmp = file->AppendNative(NS_LITERAL_CSTRING(PREF_OVERRIDE_DIRNAME));
+      if (NS_FAILED(tmp)) {
+        rv = tmp;
+      }
+      tmp = EnsureDirectoryExists(file);
+      if (NS_FAILED(tmp)) {
+        rv = tmp;
+      }
     }
   }
   if (NS_FAILED(rv) || !file)
     return NS_ERROR_FAILURE;
 
   if (ensureFilePermissions) {
     bool fileToEnsureExists;
     bool isWritable;