diff options
author | Hans Wennborg <hans@hanshq.net> | 2015-10-06 23:24:35 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2015-10-06 23:24:35 +0000 |
commit | 083ca9bb3233fb4df575bfb8c4198e3f9d6e3acd (patch) | |
tree | 81cfb3fc70e644d0ab252b18b9fabf6b764da86a /llvm/lib/Support/Unix/Path.inc | |
parent | 44780acd913643391779768c0b1d9259e294dbe8 (diff) | |
download | bcm5719-llvm-083ca9bb3233fb4df575bfb8c4198e3f9d6e3acd.tar.gz bcm5719-llvm-083ca9bb3233fb4df575bfb8c4198e3f9d6e3acd.zip |
Fix Clang-tidy modernize-use-nullptr warnings in source directories and generated files; other minor cleanups.
Patch by Eugene Zelenko!
Differential Revision: http://reviews.llvm.org/D13321
llvm-svn: 249482
Diffstat (limited to 'llvm/lib/Support/Unix/Path.inc')
-rw-r--r-- | llvm/lib/Support/Unix/Path.inc | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index 93e5654f284..042f639d835 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -75,12 +75,12 @@ test_dir(char ret[PATH_MAX], const char *dir, const char *bin) char fullpath[PATH_MAX]; snprintf(fullpath, PATH_MAX, "%s/%s", dir, bin); - if (realpath(fullpath, ret) == NULL) - return (1); + if (!realpath(fullpath, ret)) + return 1; if (stat(fullpath, &sb) != 0) - return (1); + return 1; - return (0); + return 0; } static char * @@ -91,34 +91,34 @@ getprogpath(char ret[PATH_MAX], const char *bin) /* First approach: absolute path. */ if (bin[0] == '/') { if (test_dir(ret, "/", bin) == 0) - return (ret); - return (NULL); + return ret; + return nullptr; } /* Second approach: relative path. */ - if (strchr(bin, '/') != NULL) { + if (strchr(bin, '/')) { char cwd[PATH_MAX]; - if (getcwd(cwd, PATH_MAX) == NULL) - return (NULL); + if (!getcwd(cwd, PATH_MAX)) + return nullptr; if (test_dir(ret, cwd, bin) == 0) - return (ret); - return (NULL); + return ret; + return nullptr; } /* Third approach: $PATH */ - if ((pv = getenv("PATH")) == NULL) - return (NULL); + if ((pv = getenv("PATH")) == nullptr) + return nullptr; s = pv = strdup(pv); - if (pv == NULL) - return (NULL); - while ((t = strsep(&s, ":")) != NULL) { + if (!pv) + return nullptr; + while ((t = strsep(&s, ":")) != nullptr) { if (test_dir(ret, t, bin) == 0) { free(pv); - return (ret); + return ret; } } free(pv); - return (NULL); + return nullptr; } #endif // __FreeBSD__ || __NetBSD__ || __FreeBSD_kernel__ @@ -153,8 +153,8 @@ std::string getMainExecutable(const char *argv0, void *MainAddr) { return std::string(exe_path, len); } else { // Fall back to the classical detection. - if (getprogpath(exe_path, argv0) != NULL) - return exe_path; + if (getprogpath(exe_path, argv0)) + return exe_path; } #elif defined(HAVE_DLFCN_H) // Use dladdr to get executable path if available. |