diff --git a/mozilla/editor/libeditor/html/TextEditorTest.cpp b/mozilla/editor/libeditor/html/TextEditorTest.cpp
index 0106091883e..d5ffc17ef2e 100644
--- a/mozilla/editor/libeditor/html/TextEditorTest.cpp
+++ b/mozilla/editor/libeditor/html/TextEditorTest.cpp
@@ -90,23 +90,27 @@ nsresult TextEditorTest::RunUnitTest(PRInt32 *outNumTests, PRInt32 *outNumTestsF
result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890"));
TEST_RESULT(result);
(*outNumTests)++;
- (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK);
+ if (NS_FAILED(result))
+ ++(*outNumTestsFailed);
// insert some more text
result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states. I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham. Injustice anywhere is a threat to justice everywhere"));
TEST_RESULT(result);
(*outNumTests)++;
- (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK);
+ if (NS_FAILED(result))
+ ++(*outNumTestsFailed);
result = TestInsertBreak();
TEST_RESULT(result);
(*outNumTests)++;
- (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK);
+ if (NS_FAILED(result))
+ ++(*outNumTestsFailed);
result = TestTextProperties();
TEST_RESULT(result);
(*outNumTests)++;
- (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK);
+ if (NS_FAILED(result))
+ ++(*outNumTestsFailed);
// get us back to the original document
result = mEditor->Undo(12);
diff --git a/mozilla/modules/libpref/src/nsPrefService.cpp b/mozilla/modules/libpref/src/nsPrefService.cpp
index 550170954be..cd9531ae9c7 100644
--- a/mozilla/modules/libpref/src/nsPrefService.cpp
+++ b/mozilla/modules/libpref/src/nsPrefService.cpp
@@ -85,10 +85,6 @@ static nsresult pref_InitInitialObjects(void);
*/
nsPrefService::nsPrefService()
-: mErrorOpeningUserPrefs(PR_FALSE)
-#if MOZ_PROFILESHARING
- , mErrorOpeningSharedUserPrefs(PR_FALSE)
-#endif
{
}
@@ -368,11 +364,7 @@ nsresult nsPrefService::ReadAndOwnUserPrefFile(nsIFile *aFile)
gSharedPrefHandler->ReadingUserPrefs(PR_TRUE);
#endif
- // We need to track errors in reading the shared and the
- // non-shared files independently.
- // Set the appropriate member variable from it after reading.
nsresult rv = openPrefFile(mCurrentFile);
- mErrorOpeningUserPrefs = NS_FAILED(rv);
#ifdef MOZ_PROFILESHARING
gSharedPrefHandler->ReadingUserPrefs(PR_FALSE);
@@ -395,11 +387,7 @@ nsresult nsPrefService::ReadAndOwnSharedUserPrefFile(nsIFile *aFile)
gSharedPrefHandler->ReadingUserPrefs(PR_TRUE);
#endif
- // We need to track errors in reading the shared and the
- // non-shared files independently.
- // Set the appropriate member variable from it after reading.
nsresult rv = openPrefFile(mCurrentSharedFile);
- mErrorOpeningSharedUserPrefs = NS_FAILED(rv);
#ifdef MOZ_PROFILESHARING
gSharedPrefHandler->ReadingUserPrefs(PR_FALSE);
@@ -468,14 +456,6 @@ nsresult nsPrefService::WritePrefFile(nsIFile* aFile)
if (!gHashTable.ops)
return NS_ERROR_NOT_INITIALIZED;
- /* ?! Don't save (blank) user prefs if there was an error reading them */
- if (aFile == mCurrentFile && mErrorOpeningUserPrefs)
- return NS_OK;
-#if MOZ_PROFILESHARING
- if (aFile == mCurrentSharedFile && mErrorOpeningSharedUserPrefs)
- return NS_OK;
-#endif
-
// execute a "safe" save by saving through a tempfile
rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(outStreamSink),
aFile,
@@ -782,4 +762,3 @@ static nsresult pref_InitInitialObjects()
return NS_OK;
}
-
diff --git a/mozilla/modules/libpref/src/nsPrefService.h b/mozilla/modules/libpref/src/nsPrefService.h
index f648cd9f994..d9b46b60552 100644
--- a/mozilla/modules/libpref/src/nsPrefService.h
+++ b/mozilla/modules/libpref/src/nsPrefService.h
@@ -79,9 +79,6 @@ protected:
private:
nsCOMPtr mRootBranch;
nsCOMPtr mCurrentFile;
- PRPackedBool mErrorOpeningUserPrefs;
-
- PRPackedBool mErrorOpeningSharedUserPrefs;
nsCOMPtr mCurrentSharedFile;
};
diff --git a/mozilla/xpcom/base/nsError.h b/mozilla/xpcom/base/nsError.h
index 4b05ad663a9..bbed8a3bf03 100644
--- a/mozilla/xpcom/base/nsError.h
+++ b/mozilla/xpcom/base/nsError.h
@@ -108,6 +108,7 @@
/**
* @name Standard Error Handling Macros
+ * @return 0 or 1
*/
#define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) & 0x80000000))
diff --git a/mozilla/xpcom/base/nscore.h b/mozilla/xpcom/base/nscore.h
index 9d3e71a42e2..5b8b469cc57 100644
--- a/mozilla/xpcom/base/nscore.h
+++ b/mozilla/xpcom/base/nscore.h
@@ -456,14 +456,17 @@ typedef PRUint32 nsrefcnt;
* ... non-expected code path ...
* }
*
+ * These macros are guaranteed to always return 0 or 1.
+ * The NS_FAILED/NS_SUCCEEDED macros depends on this.
+ * @return 0 or 1
*/
#if defined(__GNUC__) && (__GNUC__ > 2)
-#define NS_LIKELY(x) (__builtin_expect((x), 1))
-#define NS_UNLIKELY(x) (__builtin_expect((x), 0))
+#define NS_LIKELY(x) (__builtin_expect(!!(x), 1))
+#define NS_UNLIKELY(x) (__builtin_expect(!!(x), 0))
#else
-#define NS_LIKELY(x) (x)
-#define NS_UNLIKELY(x) (x)
+#define NS_LIKELY(x) (!!(x))
+#define NS_UNLIKELY(x) (!!(x))
#endif
#endif /* nscore_h___ */