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 563344 969ec8a3c8f23d77271f88a0038babbf348024e1
parent 563343 f6a76f264d2f021934bb8eff2b9ecd6a396ceb68
child 563345 cf3e1f896c8a9709cb6115f3cf17f4598d5d7864
push id54258
push usercpeterson@mozilla.com
push dateSun, 16 Apr 2017 05:52:14 +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)) {