[libcxx-commits] [libcxx] [libcxx] Correct and clean-up filesystem operations error_code paths (PR #88341)

Rodrigo Salazar via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 11 21:44:28 PDT 2024


================
@@ -166,15 +163,15 @@ void __copy(const path& from, const path& to, copy_options options, error_code*
       return;
     }
     error_code m_ec2;
-    for (; it != directory_iterator(); it.increment(m_ec2)) {
-      if (m_ec2) {
-        return err.report(m_ec2);
-      }
+    for (; !m_ec2 && it != directory_iterator(); it.increment(m_ec2)) {
----------------
4-rodrigo-salazar wrote:

It's that we don't check m_ec2 after the call to 'it.increment(m_ec2)'

After the for loops increment we now check m_ec2 as the loop condition, and additionally we make sure now to check the code after the final increment whereas we wouldn't before.

https://github.com/llvm/llvm-project/pull/88341


More information about the libcxx-commits mailing list