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

Aaron Ballman via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 24 12:47:22 PST 2015


aaron.ballman added inline comments.

================
Comment at: lib/Support/Unix/Path.inc:558
@@ +557,3 @@
+#ifdef HAVE_PWD_H
+  static const size_t InitialBufSize = 1024;
+  SmallString<InitialBufSize> Buf;
----------------
Why 1024?

================
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();
----------------
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).

================
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();
----------------
Is getpwuid() more reliable than reading the environment variable?


http://reviews.llvm.org/D14446





More information about the llvm-commits mailing list