From cb1511645170ec23036631790398d8143a832265 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Sun, 23 May 2021 22:55:45 +0200 Subject: [PATCH] [libc++] use more early returns for consistency Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D96983 --- libcxx/src/filesystem/operations.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp index e604cc6..99001a0 100644 --- a/libcxx/src/filesystem/operations.cpp +++ b/libcxx/src/filesystem/operations.cpp @@ -1031,16 +1031,13 @@ bool __create_directory(const path& p, error_code* ec) { if (detail::mkdir(p.c_str(), static_cast(perms::all)) == 0) return true; - if (errno == EEXIST) { - error_code mec = capture_errno(); - error_code ignored_ec; - const file_status st = status(p, ignored_ec); - if (!is_directory(st)) { - err.report(mec); - } - } else { - err.report(capture_errno()); - } + if (errno != EEXIST) + return err.report(capture_errno()); + error_code mec = capture_errno(); + error_code ignored_ec; + const file_status st = status(p, ignored_ec); + if (!is_directory(st)) + return err.report(mec); return false; } -- 2.7.4