From 161443de41904de9fe8ef4bef5a52625dd277d7b Mon Sep 17 00:00:00 2001 From: Edward Lee Date: Wed, 21 Apr 2010 11:28:00 -0700 Subject: [PATCH] Bug 559695 - warning C4700: uninitialized local variable 'rv' used in nsStorageFormHistory.cpp [r=gavin] Hard code return of NS_ERROR_OUT_OF_MEMORY on failure to createInstance. Push down declarations of rv to its first assignment. --- .../satchel/src/nsStorageFormHistory.cpp | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/toolkit/components/satchel/src/nsStorageFormHistory.cpp b/toolkit/components/satchel/src/nsStorageFormHistory.cpp index e9f6dca18e29..d6a5ca68f681 100644 --- a/toolkit/components/satchel/src/nsStorageFormHistory.cpp +++ b/toolkit/components/satchel/src/nsStorageFormHistory.cpp @@ -1032,15 +1032,13 @@ nsresult nsFormHistory::SendNotification(const nsAString &aChangeType, const nsAString &aName) { - nsresult rv; - nsCOMPtr fieldName = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID); if (!fieldName) return NS_ERROR_OUT_OF_MEMORY; fieldName->SetData(aName); - rv = SendNotification(aChangeType, fieldName); + nsresult rv = SendNotification(aChangeType, fieldName); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; @@ -1055,8 +1053,6 @@ nsFormHistory::SendNotification(const nsAString &aChangeType, const nsAString &aValue, const nsAutoString &aGuid) { - nsresult rv; - nsCOMPtr fieldName = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID); if (!fieldName) return NS_ERROR_OUT_OF_MEMORY; @@ -1074,11 +1070,11 @@ nsFormHistory::SendNotification(const nsAString &aChangeType, return NS_ERROR_OUT_OF_MEMORY; guid->SetData(aGuid); - nsCOMPtr notifyData = do_CreateInstance(NS_ARRAY_CONTRACTID); if (!notifyData) - return rv; - rv = notifyData->AppendElement(fieldName, PR_FALSE); + return NS_ERROR_OUT_OF_MEMORY; + + nsresult rv = notifyData->AppendElement(fieldName, PR_FALSE); NS_ENSURE_SUCCESS(rv, rv); rv = notifyData->AppendElement(fieldValue, PR_FALSE); @@ -1100,15 +1096,13 @@ nsresult nsFormHistory::SendNotification(const nsAString &aChangeType, const PRInt64 &aNumber) { - nsresult rv; - nsCOMPtr valOne = do_CreateInstance(NS_SUPPORTS_PRINT64_CONTRACTID); if (!valOne) return NS_ERROR_OUT_OF_MEMORY; valOne->SetData(aNumber); - rv = SendNotification(aChangeType, valOne); + nsresult rv = SendNotification(aChangeType, valOne); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; @@ -1122,8 +1116,6 @@ nsFormHistory::SendNotification(const nsAString &aChangeType, const PRInt64 &aOne, const PRInt64 &aTwo) { - nsresult rv; - nsCOMPtr valOne = do_CreateInstance(NS_SUPPORTS_PRINT64_CONTRACTID); if (!valOne) return NS_ERROR_OUT_OF_MEMORY; @@ -1138,8 +1130,9 @@ nsFormHistory::SendNotification(const nsAString &aChangeType, nsCOMPtr notifyData = do_CreateInstance(NS_ARRAY_CONTRACTID); if (!notifyData) - return rv; - rv = notifyData->AppendElement(valOne, PR_FALSE); + return NS_ERROR_OUT_OF_MEMORY; + + nsresult rv = notifyData->AppendElement(valOne, PR_FALSE); NS_ENSURE_SUCCESS(rv, rv); rv = notifyData->AppendElement(valTwo, PR_FALSE);