Bug 605177 - Fix a number of build warnings in editor/; r=ehsan a=bsmedberg
authorMs2ger <ms2ger@gmail.com>
Thu, 04 Nov 2010 16:44:46 -0400
changeset 56879 8f95ff16a6ba56d9f0ad46de12a4baff45bc9c8d
parent 56878 6ad631b2ec2f195329bd41a3704abe6957cffe85
child 56880 e2bab1fa602e7c52a6c4d88dfece44086d3d10d9
push idunknown
push userunknown
push dateunknown
reviewersehsan, bsmedberg
bugs605177
milestone2.0b8pre
Bug 605177 - Fix a number of build warnings in editor/; r=ehsan a=bsmedberg
editor/composer/src/nsEditingSession.cpp
editor/composer/src/nsEditorSpellCheck.cpp
editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp
editor/libeditor/base/DeleteRangeTxn.cpp
editor/libeditor/base/nsEditor.cpp
editor/libeditor/base/nsEditorUtils.cpp
editor/libeditor/html/nsHTMLEditRules.cpp
editor/libeditor/html/nsWSRunObject.cpp
editor/libeditor/text/nsInternetCiter.cpp
editor/txtsvc/src/nsTextServicesDocument.cpp
--- a/editor/composer/src/nsEditingSession.cpp
+++ b/editor/composer/src/nsEditingSession.cpp
@@ -1021,19 +1021,19 @@ nsEditingSession::EndDocumentLoad(nsIWeb
   {
     PRBool  makeEditable;
     editorDocShell->GetEditable(&makeEditable);
   
     if (makeEditable)
     {
       // To keep pre Gecko 1.9 behavior, setup editor always when
       // mMakeWholeDocumentEditable.
-      PRBool needsSetup;
+      bool needsSetup = false;
       if (mMakeWholeDocumentEditable) {
-        needsSetup = PR_TRUE;
+        needsSetup = true;
       } else {
         // do we already have an editor here?
         nsCOMPtr<nsIEditor> editor;
         rv = editorDocShell->GetEditor(getter_AddRefs(editor));
         NS_ENSURE_SUCCESS(rv, rv);
 
         needsSetup = !editor;
       }
--- a/editor/composer/src/nsEditorSpellCheck.cpp
+++ b/editor/composer/src/nsEditorSpellCheck.cpp
@@ -449,17 +449,20 @@ nsEditorSpellCheck::SetCurrentDictionary
 
 NS_IMETHODIMP    
 nsEditorSpellCheck::UninitSpellChecker()
 {
   NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
 
   // we preserve the last selected language, but ignore errors so we continue
   // to uninitialize
-  nsresult rv = SaveDefaultDictionary();
+#ifdef DEBUG
+  nsresult rv =
+#endif
+  SaveDefaultDictionary();
   NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to set default dictionary");
 
   // Cleanup - kill the spell checker
   DeleteSuggestedWordList();
   mDictionaryList.Clear();
   mDictionaryIndex = 0;
   mSpellChecker = 0;
   return NS_OK;
--- a/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp
+++ b/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp
@@ -261,17 +261,17 @@ NS_IMETHODIMP ChangeCSSInlineStyleTxn::D
 }
 
 nsresult ChangeCSSInlineStyleTxn::SetStyle(PRBool aAttributeWasSet,
                                            nsAString & aValue)
 {
   NS_ASSERTION(mEditor && mElement, "bad state");
   if (!mEditor || !mElement) { return NS_ERROR_NOT_INITIALIZED; }
 
-  nsresult result;
+  nsresult result = NS_OK;
   if (aAttributeWasSet) {
     // the style attribute was set and not empty, let's recreate the declaration
     nsAutoString propertyNameString;
     mProperty->ToString(propertyNameString);
 
     nsCOMPtr<nsIDOMElementCSSInlineStyle> inlineStyles = do_QueryInterface(mElement);
     NS_ENSURE_TRUE(inlineStyles, NS_ERROR_NULL_POINTER);
     nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
--- a/editor/libeditor/base/DeleteRangeTxn.cpp
+++ b/editor/libeditor/base/DeleteRangeTxn.cpp
@@ -248,17 +248,17 @@ NS_IMETHODIMP DeleteRangeTxn::GetTxnDesc
   return NS_OK;
 }
 
 NS_IMETHODIMP 
 DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent, 
                                           PRUint32    aStartOffset, 
                                           PRUint32    aEndOffset)
 {
-  nsresult result;
+  nsresult result = NS_OK;
   // see what kind of node we have
   nsCOMPtr<nsIDOMCharacterData> textNode = do_QueryInterface(aStartParent);
   if (textNode)
   { // if the node is a text node, then delete text content
     nsRefPtr<DeleteTextTxn> txn = new DeleteTextTxn();
     NS_ENSURE_TRUE(txn, NS_ERROR_OUT_OF_MEMORY);
 
     PRInt32 numToDel;
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -219,25 +219,28 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUO
 #pragma mark  nsIEditorMethods 
 #pragma mark -
 #endif
 
 
 NS_IMETHODIMP
 nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags)
 {
-  NS_PRECONDITION(nsnull!=aDoc && nsnull!=aPresShell, "bad arg");
-  if ((nsnull==aDoc) || (nsnull==aPresShell))
+  NS_PRECONDITION(aDoc && aPresShell, "bad arg");
+  if (!aDoc || !aPresShell)
     return NS_ERROR_NULL_POINTER;
 
   // First only set flags, but other stuff shouldn't be initialized now.
   // Don't move this call after initializing mDocWeak and mPresShellWeak.
   // SetFlags() can check whether it's called during initialization or not by
   // them.  Note that SetFlags() will be called by PostCreate().
-  nsresult rv = SetFlags(aFlags);
+#ifdef DEBUG
+  nsresult rv =
+#endif
+  SetFlags(aFlags);
   NS_ASSERTION(NS_SUCCEEDED(rv), "SetFlags() failed");
 
   mDocWeak = do_GetWeakReference(aDoc);  // weak reference to doc
   mPresShellWeak = do_GetWeakReference(aPresShell);   // weak reference to pres shell
   mSelConWeak = do_GetWeakReference(aSelCon);   // weak reference to selectioncontroller
 
   nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
   NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
@@ -2869,17 +2872,17 @@ nsEditor::SplitNodeImpl(nsIDOMNode * aEx
 
 nsresult
 nsEditor::JoinNodesImpl(nsIDOMNode * aNodeToKeep,
                         nsIDOMNode * aNodeToJoin,
                         nsIDOMNode * aParent,
                         PRBool       aNodeToKeepIsFirst)
 {
   NS_ASSERTION(aNodeToKeep && aNodeToJoin && aParent, "null arg");
-  nsresult result;
+  nsresult result = NS_OK;
   if (aNodeToKeep && aNodeToJoin && aParent)
   {
     // get selection
     nsCOMPtr<nsISelection> selection;
     GetSelection(getter_AddRefs(selection));
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
     // remember some selection points
--- a/editor/libeditor/base/nsEditorUtils.cpp
+++ b/editor/libeditor/base/nsEditorUtils.cpp
@@ -266,16 +266,19 @@ nsEditorHookUtils::DoInsertionHook(nsIDO
     nsCOMPtr<nsISupports> isupp;
     if (NS_FAILED(enumerator->GetNext(getter_AddRefs(isupp))))
       break;
 
     nsCOMPtr<nsIClipboardDragDropHooks> override = do_QueryInterface(isupp);
     if (override)
     {
       PRBool doInsert = PR_TRUE;
-      nsresult hookResult = override->OnPasteOrDrop(aDropEvent, aTrans, &doInsert);
+#ifdef DEBUG
+      nsresult hookResult =
+#endif
+      override->OnPasteOrDrop(aDropEvent, aTrans, &doInsert);
       NS_ASSERTION(NS_SUCCEEDED(hookResult), "hook failure in OnPasteOrDrop");
       NS_ENSURE_TRUE(doInsert, PR_FALSE);
     }
   }
 
   return PR_TRUE;
 }
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -5817,17 +5817,17 @@ nsHTMLEditRules::GetNodesForOperation(ns
     nsAutoTArray<nsRangeStore, 16> rangeItemArray;
     if (!rangeItemArray.AppendElements(rangeCount)) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
     NS_ASSERTION(rangeCount == rangeItemArray.Length(), "How did that happen?");
 
     // first register ranges for special editor gravity
-    for (i = 0; i < (PRInt32)rangeCount; i++)
+    for (i = 0; i < rangeCount; i++)
     {
       opRange = inArrayOfRanges[0];
       nsRangeStore *item = rangeItemArray.Elements() + i;
       item->StoreRange(opRange);
       mHTMLEditor->mRangeUpdater.RegisterRangeItem(item);
       inArrayOfRanges.RemoveObjectAt(0);
     }    
     // now bust up inlines.  Safe to start at rangeCount-1, since we
--- a/editor/libeditor/html/nsWSRunObject.cpp
+++ b/editor/libeditor/html/nsWSRunObject.cpp
@@ -1909,18 +1909,18 @@ nsWSRunObject::FindRun(nsIDOMNode *aNode
 }
 
 PRUnichar 
 nsWSRunObject::GetCharAt(nsIContent *aTextNode, PRInt32 aOffset)
 {
   // return 0 if we can't get a char, for whatever reason
   NS_ENSURE_TRUE(aTextNode, 0);
 
-  PRUint32 len = aTextNode->TextLength();
-  if (aOffset < 0 || aOffset >= PRUint32(len)) 
+  PRInt32 len = PRInt32(aTextNode->TextLength());
+  if (aOffset < 0 || aOffset >= len)
     return 0;
     
   return aTextNode->GetText()->CharAt(aOffset);
 }
 
 nsresult 
 nsWSRunObject::GetWSPointAfter(nsIDOMNode *aNode, PRInt32 aOffset, WSPoint *outPoint)
 {
--- a/editor/libeditor/text/nsInternetCiter.cpp
+++ b/editor/libeditor/text/nsInternetCiter.cpp
@@ -349,17 +349,17 @@ nsInternetCiter::Rewrap(const nsAString&
       // If it's already less than our current position,
       // then our line is already too long, so break now.
       if (eol <= (PRInt32)posInString)
       {
         BreakLine(aOutString, outStringCol, citeLevel);
         continue;    // continue inner loop, with outStringCol now at bol
       }
 
-      PRInt32 breakPt;
+      PRInt32 breakPt = 0;
       rv = NS_ERROR_BASE;
       if (lineBreaker)
       {
         breakPt = lineBreaker->Prev(tString.get() + posInString,
                                  length - posInString, eol + 1 - posInString);
         if (breakPt == NS_LINEBREAKER_NEED_MORE_TEXT)
         {
           // if we couldn't find a breakpoint looking backwards,
--- a/editor/txtsvc/src/nsTextServicesDocument.cpp
+++ b/editor/txtsvc/src/nsTextServicesDocument.cpp
@@ -1804,18 +1804,18 @@ nsTextServicesDocument::DidDeleteNode(ns
 
   //**** KDEBUG ****
   // printf("** DeleteNode: 0x%.8x\n", aChild);
   // fflush(stdout);
   //**** KDEBUG ****
 
   LOCK_DOC(this);
 
-  PRInt32 nodeIndex, tcount;
-  PRBool hasEntry;
+  PRInt32 nodeIndex = 0;
+  PRBool hasEntry = PR_FALSE;
   OffsetEntry *entry;
 
   nsresult result = NodeHasOffsetEntry(&mOffsetTable, aChild, &hasEntry, &nodeIndex);
 
   if (NS_FAILED(result))
   {
     UNLOCK_DOC(this);
     return result;
@@ -1839,17 +1839,17 @@ nsTextServicesDocument::DidDeleteNode(ns
     // AdjustContentIterator() should have been called prior
     // to the delete to try and position the iterator on the
     // next valid text node in the offset table, and if there
     // wasn't a next, it would've set mIteratorStatus to eIsDone.
 
     NS_ERROR("DeleteNode called for current iterator node."); 
   }
 
-  tcount = mOffsetTable.Length();
+  PRInt32 tcount = mOffsetTable.Length();
 
   while (nodeIndex < tcount)
   {
     entry = mOffsetTable[nodeIndex];
 
     if (!entry)
     {
       UNLOCK_DOC(this);
@@ -1919,18 +1919,20 @@ nsTextServicesDocument::DidJoinNodes(nsI
   {
     NS_ERROR("JoinNode called with a non-text right node!");
     return NS_ERROR_FAILURE;
   }
 
   // Note: The editor merges the contents of the left node into the
   //       contents of the right.
 
-  PRInt32 leftIndex, rightIndex;
-  PRBool leftHasEntry, rightHasEntry;
+  PRInt32 leftIndex = 0;
+  PRInt32 rightIndex = 0;
+  PRBool leftHasEntry = PR_FALSE;
+  PRBool rightHasEntry = PR_FALSE;
 
   result = NodeHasOffsetEntry(&mOffsetTable, aLeftNode, &leftHasEntry, &leftIndex);
 
   NS_ENSURE_SUCCESS(result, result);
 
   if (!leftHasEntry)
   {
     // It's okay if the node isn't in the offset table, the
@@ -3841,18 +3843,18 @@ nsTextServicesDocument::FindWordBounds(n
     *aWordStartNode = nsnull;
   if (aWordStartOffset)
     *aWordStartOffset = 0;
   if (aWordEndNode)
     *aWordEndNode = nsnull;
   if (aWordEndOffset)
     *aWordEndOffset = 0;
 
-  PRInt32 entryIndex;
-  PRBool hasEntry;
+  PRInt32 entryIndex = 0;
+  PRBool hasEntry = PR_FALSE;
 
   // It's assumed that aNode is a text node. The first thing
   // we do is get it's index in the offset table so we can
   // calculate the dom point's string offset.
 
   nsresult result = NodeHasOffsetEntry(aOffsetTable, aNode, &hasEntry, &entryIndex);
   NS_ENSURE_SUCCESS(result, result);
   NS_ENSURE_TRUE(hasEntry, NS_ERROR_FAILURE);