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
--- 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;