Bug 1356843 - Fix -Wcomma warning in extensions/spellcheck/src/mozSpellChecker.cpp. r=masayuki draft
authorChris Peterson <cpeterson@mozilla.com>
Mon, 27 Mar 2017 21:24:35 -0700
changeset 563947 ed9a0bf53f232a887d40918d2ff7d9ca63a45455
parent 563946 5ab03d10f255179f68aeb9559e9a64600c313b42
child 563948 829f756d04a3f3e06669e3700e4e373ca9cf5adc
push id54485
push usercpeterson@mozilla.com
push dateTue, 18 Apr 2017 05:57:33 +0000
reviewersmasayuki
bugs1356843
milestone55.0a1
Bug 1356843 - Fix -Wcomma warning in extensions/spellcheck/src/mozSpellChecker.cpp. r=masayuki clang's -Wcomma warning warns about suspicious use of the comma operator such as calling a function for side effects within an expression. Check NS_SUCCEEDED() to use HasMoreElement() in an expression and confirm that it actually returned a legitimate out parameter. extensions/spellcheck/src/mozSpellChecker.cpp:532:54 [-Wcomma] possible misuse of comma operator here MozReview-Commit-ID: 3GnKVvx8Nu4
extensions/spellcheck/src/mozSpellChecker.cpp
--- a/extensions/spellcheck/src/mozSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozSpellChecker.cpp
@@ -1,14 +1,13 @@
 /* vim: set ts=2 sts=2 sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-
 #include "mozSpellChecker.h"
 #include "nsIServiceManager.h"
 #include "mozISpellI18NManager.h"
 #include "nsIStringEnumerator.h"
 #include "nsICategoryManager.h"
 #include "nsISupportsPrimitives.h"
 #include "nsISimpleEnumerator.h"
 #include "mozilla/PRemoteSpellcheckEngineChild.h"
@@ -547,17 +546,18 @@ mozSpellChecker::GetEngineList(nsCOMArra
   nsCOMPtr<nsISimpleEnumerator> catEntries;
 
   // Get contract IDs of registrated external spell-check engines and
   // append one of HunSpell at the end.
   rv = catMgr->EnumerateCategory("spell-check-engine", getter_AddRefs(catEntries));
   if (NS_FAILED(rv))
     return rv;
 
-  while (catEntries->HasMoreElements(&hasMoreEngines), hasMoreEngines){
+  while (NS_SUCCEEDED(catEntries->HasMoreElements(&hasMoreEngines)) &&
+         hasMoreEngines) {
     nsCOMPtr<nsISupports> elem;
     rv = catEntries->GetNext(getter_AddRefs(elem));
 
     nsCOMPtr<nsISupportsCString> entry = do_QueryInterface(elem, &rv);
     if (NS_FAILED(rv))
       return rv;
 
     nsCString contractId;