[PATCH] D14446: Fallback to getpwuid() in path::home_directory() on Unix.

Paweł Bylica via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 04:59:01 PST 2015


chfast added a comment.

In http://reviews.llvm.org/D14446#296010, @rafael wrote:

> Can you give an overview of when the HOME environment variable is not defined?


E.g. in llvm-lit testing environment.


================
Comment at: lib/Support/Unix/Path.inc:574
@@ +573,3 @@
+    assert(PasswdResult == &Passwd && "getpwuid_r does strange things");
+    auto Dir = Passwd.pw_dir;
+    Result.clear();
----------------
aaron.ballman wrote:
> I'm not certain whether Dir is required here or not, but knowing its type would be good. We only use auto when the type is already spelled out, or when it's difficult to spell out (like some iterators).
I will change that.

================
Comment at: lib/Support/Unix/Path.inc:584
@@ -554,1 +583,3 @@
+bool home_directory(SmallVectorImpl<char> &Result) {
   if (char *RequestedDir = getenv("HOME")) {
+    Result.clear();
----------------
aaron.ballman wrote:
> Is getpwuid() more reliable than reading the environment variable?
I don't understand the question. Are you asking which approach is better?

Checking the environmental variable first allows the user change home directory location visible by the application.


http://reviews.llvm.org/D14446





More information about the llvm-commits mailing list