Bug 1356843 - Fix -Wcomma warnings in xpcom/io/nsLocalFileUnix.cpp. r=froydnj draft
authorChris Peterson <cpeterson@mozilla.com>
Mon, 03 Apr 2017 11:05:57 -0700
changeset 563963 9200d40aeb5b8314cd4493de5e4abbf9f7d46c08
parent 563962 fdb84091f2c2e12932a35918ce1e419c08c36db6
child 563964 e4e203fbfd6be50b9299851f11c1e87ec048e3ae
push id54487
push usercpeterson@mozilla.com
push dateTue, 18 Apr 2017 06:09:29 +0000
reviewersfroydnj
bugs1356843
milestone55.0a1
Bug 1356843 - Fix -Wcomma warnings in xpcom/io/nsLocalFileUnix.cpp. r=froydnj 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. xpcom/io/nsLocalFileUnix.cpp:725:48 [-Wcomma] possible misuse of comma operator here xpcom/io/nsLocalFileUnix.cpp:1053:39 [-Wcomma] possible misuse of comma operator here MozReview-Commit-ID: aebrgc5Wqk
xpcom/io/nsLocalFileUnix.cpp
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -717,17 +717,17 @@ nsLocalFile::CopyDirectoryTo(nsIFile* aN
   }
 
   nsCOMPtr<nsISimpleEnumerator> dirIterator;
   if (NS_FAILED(rv = GetDirectoryEntries(getter_AddRefs(dirIterator)))) {
     return rv;
   }
 
   bool hasMore = false;
-  while (dirIterator->HasMoreElements(&hasMore), hasMore) {
+  while (NS_SUCCEEDED(dirIterator->HasMoreElements(&hasMore)) && hasMore) {
     nsCOMPtr<nsISupports> supports;
     nsCOMPtr<nsIFile> entry;
     rv = dirIterator->GetNext(getter_AddRefs(supports));
     entry = do_QueryInterface(supports);
     if (NS_FAILED(rv) || !entry) {
       continue;
     }
     if (NS_FAILED(rv = entry->IsSymlink(&isSymlink))) {
@@ -1045,17 +1045,17 @@ nsLocalFile::Remove(bool aRecursive)
     nsCOMPtr<nsISimpleEnumerator> dirRef(dir); // release on exit
 
     rv = dir->Init(this, false);
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     bool more;
-    while (dir->HasMoreElements(&more), more) {
+    while (NS_SUCCEEDED(dir->HasMoreElements(&more)) && more) {
       nsCOMPtr<nsISupports> item;
       rv = dir->GetNext(getter_AddRefs(item));
       if (NS_FAILED(rv)) {
         return NS_ERROR_FAILURE;
       }
 
       nsCOMPtr<nsIFile> file = do_QueryInterface(item, &rv);
       if (NS_FAILED(rv)) {