@@ -1159,16 +1159,18 @@ String OS_Unix::get_executable_path() const {
11591159 kinfo_file *kif = nullptr ;
11601160 bool error = false ;
11611161 kd = kvm_openfiles (nullptr , nullptr , nullptr , KVM_NO_FILES, nullptr );
1162- if (!kd) return res;
1162+ if (!kd) {
1163+ return res;
1164+ }
11631165 if ((kif = kvm_getfiles (kd, KERN_FILE_BYPID, getpid (), sizeof (struct kinfo_file ), &cntp))) {
11641166 for (int i = 0 ; i < cntp && kif[i].fd_fd < 0 ; i++) {
11651167 if (kif[i].fd_fd == KERN_FILE_TEXT) {
11661168 struct stat st;
1167- fallback:
1169+ fallback:
11681170 char buffer[PATH_MAX];
11691171 if (!stat (exe.c_str (), &st) && (st.st_mode & S_IXUSR) &&
1170- (st.st_mode & S_IFREG) && realpath (exe.c_str (), buffer) &&
1171- st.st_dev == (dev_t )kif[i].va_fsid && st.st_ino == (ino_t )kif[i].va_fileid ) {
1172+ (st.st_mode & S_IFREG) && realpath (exe.c_str (), buffer) &&
1173+ st.st_dev == (dev_t )kif[i].va_fsid && st.st_ino == (ino_t )kif[i].va_fileid ) {
11721174 res = buffer;
11731175 }
11741176 if (res.empty () && !error) {
@@ -1213,26 +1215,30 @@ String OS_Unix::get_executable_path() const {
12131215 if (!buffer.empty ()) {
12141216 std::string argv0;
12151217 if (!buffer[0 ].empty ()) {
1216- fallback:
1218+ fallback:
12171219 std::size_t slash_pos = buffer[0 ].find (' /' );
12181220 std::size_t colon_pos = buffer[0 ].find (' :' );
12191221 if (slash_pos == 0 ) {
12201222 argv0 = buffer[0 ];
12211223 path = is_exe (argv0);
1222- } else if (slash_pos == std::string::npos || slash_pos > colon_pos) {
1224+ } else if (slash_pos == std::string::npos || slash_pos > colon_pos) {
12231225 std::string penv = cppstr_getenv (" PATH" );
12241226 if (!penv.empty ()) {
1225- retry:
1227+ retry:
12261228 std::string tmp;
12271229 std::stringstream sstr (penv);
12281230 while (std::getline (sstr, tmp, ' :' )) {
12291231 argv0 = tmp + " /" + buffer[0 ];
12301232 path = is_exe (argv0);
1231- if (!path.empty ()) break ;
1233+ if (!path.empty ()) {
1234+ break ;
1235+ }
12321236 if (slash_pos > colon_pos) {
12331237 argv0 = tmp + " /" + buffer[0 ].substr (0 , colon_pos);
12341238 path = is_exe (argv0);
1235- if (!path.empty ()) break ;
1239+ if (!path.empty ()) {
1240+ break ;
1241+ }
12361242 }
12371243 }
12381244 }
0 commit comments