[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:06 PDT 2024


https://github.com/royitaqi created https://github.com/llvm/llvm-project/pull/104502

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

>From 1e0e766530acffc29fef0b0b2cd909a943a92599 Mon Sep 17 00:00:00 2001
From: Roy Shi <royshi at meta.com>
Date: Thu, 15 Aug 2024 13:34:53 -0700
Subject: [PATCH] (lldb) (minor) Correctly fix a usage of PATH_MAX

---
 lldb/source/Utility/RealpathPrefixes.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

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;



More information about the lldb-commits mailing list