[Lldb-commits] [lldb] (lldb) (minor) Correctly fix a usage of `PATH_MAX` (PR #104502)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 15 13:41:34 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: None (royitaqi)
<details>
<summary>Changes</summary>
https://github.com/llvm/llvm-project/pull/102223 broke Windows build by using `PATH_MAX` without defining it.
https://github.com/llvm/llvm-project/pull/104493 fixed it by including a header file which defines it.
However, **in general, we want to avoid using `PATH_MAX`**. While the above fixed the build, after a closer look at the code, we realized that we don't even need to use `PATH_MAX`. This is because we are using `SmallString<>`, which uses the parameter as a *initial* size, not *max* size. So here we can just put a reasonable small size (i.e. 1024).
---
Full diff: https://github.com/llvm/llvm-project/pull/104502.diff
1 Files Affected:
- (modified) lldb/source/Utility/RealpathPrefixes.cpp (+1-2)
``````````diff
diff --git a/lldb/source/Utility/RealpathPrefixes.cpp b/lldb/source/Utility/RealpathPrefixes.cpp
index ee1c404c89967..78ba6ee655864 100644
--- a/lldb/source/Utility/RealpathPrefixes.cpp
+++ b/lldb/source/Utility/RealpathPrefixes.cpp
@@ -8,7 +8,6 @@
#include "lldb/Utility/RealpathPrefixes.h"
-#include "lldb/Host/PosixApi.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/FileSpecList.h"
#include "lldb/Utility/LLDBLog.h"
@@ -54,7 +53,7 @@ RealpathPrefixes::ResolveSymlinks(const FileSpec &file_spec) {
LLDB_LOGF(log, "Realpath'ing support file %s", file_spec_path.c_str());
// One prefix matched. Try to realpath.
- llvm::SmallString<PATH_MAX> buff;
+ llvm::SmallString<1024> buff;
std::error_code ec = m_fs->getRealPath(file_spec_path, buff);
if (ec)
return std::nullopt;
``````````
</details>
https://github.com/llvm/llvm-project/pull/104502
More information about the lldb-commits
mailing list