Bug 836345: Cast nsCOMArray::Count()'s result to uint32 in nsAutoCompleteController.cpp, to fix signed/unsigned comparison build warnings. r=mounir
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 31 Jan 2013 14:40:04 -0800
changeset 130400 5e57a1b8f7b4f866c99af4ce4316d9e03bfc3896
parent 130399 3e4fc8131668c5f0e77a03fefa1dd4200ba74041
child 130401 0f306bf2d17d4e371544f9ed4dce095201a2e998
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs836345
milestone21.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 836345: Cast nsCOMArray::Count()'s result to uint32 in nsAutoCompleteController.cpp, to fix signed/unsigned comparison build warnings. r=mounir
toolkit/components/autocomplete/nsAutoCompleteController.cpp
--- a/toolkit/components/autocomplete/nsAutoCompleteController.cpp
+++ b/toolkit/components/autocomplete/nsAutoCompleteController.cpp
@@ -1066,17 +1066,19 @@ nsAutoCompleteController::StartSearch(ui
 
   return NS_OK;
 }
 
 void
 nsAutoCompleteController::AfterSearches()
 {
   mResultCache.Clear();
-  if (mSearchesFailed == mSearches.Count())
+  // nsCOMArray::Count() returns a signed value; we have to cast it to unsigned
+  // when comparing it to unsigned, or compilers will complain.
+  if (mSearchesFailed == static_cast<uint32_t>(mSearches.Count()))
     PostSearchCleanup();
 }
 
 NS_IMETHODIMP
 nsAutoCompleteController::StopSearch()
 {
   // Stop the timer if there is one
   ClearSearchTimer();
@@ -1117,17 +1119,19 @@ nsAutoCompleteController::StartSearches(
   }
 
   if (immediateSearchesCount > 0) {
     nsresult rv = BeforeSearches();
     if (NS_FAILED(rv))
       return rv;
     StartSearch(nsIAutoCompleteSearchDescriptor::SEARCH_TYPE_IMMEDIATE);
 
-    if (mSearches.Count() == immediateSearchesCount) {
+    // nsCOMArray::Count() returns a signed value; we have to cast it to
+    // unsigned when comparing it to unsigned, or compilers will complain.
+    if (static_cast<uint32_t>(mSearches.Count()) == immediateSearchesCount) {
       // Either all searches are immediate, or the timeout is 0.  In the
       // latter case we still have to execute the delayed searches, otherwise
       // this will be a no-op.
       StartSearch(nsIAutoCompleteSearchDescriptor::SEARCH_TYPE_DELAYED);
 
       // All the searches have been started, just finish.
       AfterSearches();
       return NS_OK;