Bug 1356843 - Fix -Wcomma warnings in toolkit/. r=mossop draft
authorChris Peterson <cpeterson@mozilla.com>
Wed, 05 Apr 2017 01:23:45 -0700
changeset 563952 efd3de3df6e15da9cc3bc6d31417f732f39cbf63
parent 563951 2caaedd75d43b6ce4364d01d75823c43c621e82a
child 563953 be6944854d5110d2f930b1deeb9881b78119f0b8
child 563962 fdb84091f2c2e12932a35918ce1e419c08c36db6
push id54485
push usercpeterson@mozilla.com
push dateTue, 18 Apr 2017 05:57:33 +0000
Bug 1356843 - Fix -Wcomma warnings in toolkit/. r=mossop clang's -Wcomma warning warns about suspicious use of the comma operator such as between two statements or 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. toolkit/components/startup/nsAppStartup.cpp:436:58 [-Wcomma] possible misuse of comma operator here toolkit/components/statusfilter/nsBrowserStatusFilter.cpp:165:66 [-Wcomma] possible misuse of comma operator here toolkit/xre/CreateAppData.cpp:60:51 [-Wcomma] possible misuse of comma operator here MozReview-Commit-ID: HuZRoOjQTGj
--- a/toolkit/components/startup/nsAppStartup.cpp
+++ b/toolkit/components/startup/nsAppStartup.cpp
@@ -428,17 +428,18 @@ nsAppStartup::Quit(uint32_t aMode)
            failed. This could happen for a variety of reasons; in fact it's
            very likely. Perhaps we're being called from JS and the window->Close
            method hasn't had a chance to wrap itself up yet. So give up.
            We'll return (with eConsiderQuit) as the remaining windows are
            closed. */
         mediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator));
         if (windowEnumerator) {
           bool more;
-          while (windowEnumerator->HasMoreElements(&more), more) {
+          while (NS_SUCCEEDED(windowEnumerator->HasMoreElements(&more)) &&
+                 more) {
             /* we can't quit immediately. we'll try again as the last window
                finally closes. */
             ferocity = eAttemptQuit;
             nsCOMPtr<nsISupports> window;
             nsCOMPtr<nsPIDOMWindowOuter> domWindow = do_QueryInterface(window);
             if (domWindow) {
               if (!domWindow->Closed()) {
--- a/toolkit/components/statusfilter/nsBrowserStatusFilter.cpp
+++ b/toolkit/components/statusfilter/nsBrowserStatusFilter.cpp
@@ -157,18 +157,18 @@ nsBrowserStatusFilter::OnStateChange(nsI
     // If we're here, we have either STATE_START or STATE_STOP.  The
     // listener only cares about these in certain conditions.
     bool isLoadingDocument = false;
     if ((aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK ||
          (aStateFlags & nsIWebProgressListener::STATE_IS_REQUEST &&
           mFinishedRequests == mTotalRequests &&
-          (aWebProgress->GetIsLoadingDocument(&isLoadingDocument),
-           !isLoadingDocument)))) {
+          NS_SUCCEEDED(aWebProgress->GetIsLoadingDocument(&isLoadingDocument)) &&
+          !isLoadingDocument))) {
         if (mTimer && (aStateFlags & nsIWebProgressListener::STATE_STOP)) {
         return mListener->OnStateChange(aWebProgress, aRequest, aStateFlags,
--- a/toolkit/xre/CreateAppData.cpp
+++ b/toolkit/xre/CreateAppData.cpp
@@ -52,17 +52,17 @@ XRE_ParseAppData(nsIFile* aINIFile, XREA
   nsresult rv;
   nsINIParser parser;
   rv = parser.Init(aINIFile);
   if (NS_FAILED(rv))
     return rv;
   ReadString(parser, "App", "Vendor", aAppData.vendor);
-  ReadString(parser, "App", "Name", aAppData.name),
+  ReadString(parser, "App", "Name", aAppData.name);
   ReadString(parser, "App", "RemotingName", aAppData.remotingName);
   ReadString(parser, "App", "Version", aAppData.version);
   ReadString(parser, "App", "BuildID", aAppData.buildID);
   ReadString(parser, "App", "ID", aAppData.ID);
   ReadString(parser, "App", "Copyright", aAppData.copyright);
   ReadString(parser, "App", "Profile", aAppData.profile);
   ReadString(parser, "Gecko", "MinVersion", aAppData.minVersion);
   ReadString(parser, "Gecko", "MaxVersion", aAppData.maxVersion);