[PATCH] Support: Provide a function to get the home directory of an arbitrary user

Reid Kleckner rnk at google.com
Fri Aug 1 10:19:42 PDT 2014


lgtm

================
Comment at: lib/Support/Unix/Path.inc:683
@@ +682,3 @@
+  result.clear();
+  struct passwd *user_entry = ::getpwnam (user.c_str());
+  if (user_entry == nullptr)
----------------
David Majnemer wrote:
> Reid Kleckner wrote:
> > StringRef doesn't have a c_str() method, but you can do .str().c_str() to convert to std::string first.  *yawn*, excessive copies in C++. :(
> This doesn't follow LLVM's coding style.
> 
> Variables should be CamelCase and there is no space between the identifier and the parenthesis.
Yeah, but we're in the sys::filesystem API.  The STL-like function names usually come with hacker_style_underscore variable names.  This is consistent with the code around it, too.

================
Comment at: lib/Support/Windows/Path.inc:887-888
@@ +886,4 @@
+
+  result.resize(cch_referenced_domain);
+  if (!::LookupAccountName(nullptr, user.data(), sid, &sid_size, &result[0],
+                           &cch_referenced_domain, &sid_name_use))
----------------
I guess this can be .reserve() instead of .resize() and .data() instead of &result[0].

================
Comment at: lib/Support/Windows/Path.inc:907
@@ +906,3 @@
+
+  result.resize(cbData);
+  uint8_t *buf_data = reinterpret_cast<uint8_t *>(result.data());
----------------
ditto

================
Comment at: lib/Support/Windows/Path.inc:890
@@ +889,3 @@
+
+  domain_buffer.resize(cch_referenced_domain);
+  if (!::LookupAccountName(nullptr, user.data(), sid, &sid_size, &domain_buffer[0], &cch_referenced_domain, &sid_name_use))
----------------
David Majnemer wrote:
> Can we get away with using `reserve` instead of `resize`?
+1

http://reviews.llvm.org/D4749






More information about the llvm-commits mailing list