aboutsummaryrefslogtreecommitdiff
path: root/lib/System/Unix/Path.inc
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-05 20:16:55 +0000
committerDan Gohman <gohman@apple.com>2009-08-05 20:16:55 +0000
commit7b3544ba97a31f21f24a9f923bd2a793df6d46ab (patch)
tree4e5e1431aeaf6fa0f5f1e1494cf5574e5b52d45f /lib/System/Unix/Path.inc
parent058c251d4ac23bb3f9ca66eb0e465fa2c6c66f42 (diff)
Minor code simplification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78239 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix/Path.inc')
-rw-r--r--lib/System/Unix/Path.inc6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc
index 822b0366ba..a54fcfd84b 100644
--- a/lib/System/Unix/Path.inc
+++ b/lib/System/Unix/Path.inc
@@ -344,10 +344,8 @@ Path Path::GetMainExecutable(const char *argv0, void *MainAddr) {
#elif defined(__linux__) || defined(__CYGWIN__)
char exe_path[MAXPATHLEN];
ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path));
- if (len > 0 && len < MAXPATHLEN - 1) {
- exe_path[len] = '\0';
- return Path(std::string(exe_path));
- }
+ if (len >= 0)
+ return Path(std::string(exe_path, len));
#elif defined(HAVE_DLFCN_H)
// Use dladdr to get executable path if available.
Dl_info DLInfo;