[libcxx-commits] [libcxx] [libc++][test] try to directly create socket file in /tmp when filepath is too long (PR #77058)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 5 01:03:08 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff a157e79dd207d72aea1d42953c61f14790d847c1 c4102bd48b799a88c46066071cb85c6bbe2b1607 -- libcxx/test/support/filesystem_test_helper.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/test/support/filesystem_test_helper.h b/libcxx/test/support/filesystem_test_helper.h
index 948af08bc94..0cd5b4e3c2f 100644
--- a/libcxx/test/support/filesystem_test_helper.h
+++ b/libcxx/test/support/filesystem_test_helper.h
@@ -319,13 +319,13 @@ struct scoped_test_env
         // If file.size() is too big, try to create a file directly inside
         // /tmp to make sure file path is short enough.
         if (file.size() <= sizeof(address.sun_path) && utils::exists("/tmp")) {
-            fs::path const tmp = "/tmp";
-            std::size_t i      = std::hash<std::string>()(std::to_string(std::time(nullptr)));
-            fs::path p         = tmp / ("libcxx-socket-" + file + "-" + std::to_string(i));
-            while (utils::exists(p.string())) {
-              p = tmp / ("libcxx-socket-" + file + "-" + std::to_string(++i));
-            }
-            file = p.string();
+          fs::path const tmp = "/tmp";
+          std::size_t i      = std::hash<std::string>()(std::to_string(std::time(nullptr)));
+          fs::path p         = tmp / ("libcxx-socket-" + file + "-" + std::to_string(i));
+          while (utils::exists(p.string())) {
+            p = tmp / ("libcxx-socket-" + file + "-" + std::to_string(++i));
+          }
+          file = p.string();
         }
         assert(file.size() <= sizeof(address.sun_path));
         ::strncpy(address.sun_path, file.c_str(), sizeof(address.sun_path));

``````````

</details>


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


More information about the libcxx-commits mailing list