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
--- 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)) {