@@ -667,24 +667,23 @@ static char proc_self_exe_cache_str[kMaxPathLength];
667
667
static uptr proc_self_exe_cache_len = 0 ;
668
668
669
669
uptr ReadBinaryName (/* out*/ char *buf, uptr buf_len) {
670
+ if (proc_self_exe_cache_len > 0 ) {
671
+ // If available, use the cached module name.
672
+ uptr module_name_len =
673
+ internal_snprintf (buf, buf_len, " %s" , proc_self_exe_cache_str);
674
+ CHECK_LT (module_name_len, buf_len);
675
+ return module_name_len;
676
+ }
670
677
uptr module_name_len = internal_readlink (
671
678
" /proc/self/exe" , buf, buf_len);
672
679
int readlink_error;
673
680
if (internal_iserror (module_name_len, &readlink_error)) {
674
- if (proc_self_exe_cache_len) {
675
- // If available, use the cached module name.
676
- CHECK_LE (proc_self_exe_cache_len, buf_len);
677
- internal_strncpy (buf, proc_self_exe_cache_str, buf_len);
678
- module_name_len = internal_strlen (proc_self_exe_cache_str);
679
- } else {
680
- // We can't read /proc/self/exe for some reason, assume the name of the
681
- // binary is unknown.
682
- Report (" WARNING: readlink(\" /proc/self/exe\" ) failed with errno %d, "
683
- " some stack frames may not be symbolized\n " , readlink_error);
684
- module_name_len = internal_snprintf (buf, buf_len, " /proc/self/exe" );
685
- }
681
+ // We can't read /proc/self/exe for some reason, assume the name of the
682
+ // binary is unknown.
683
+ Report (" WARNING: readlink(\" /proc/self/exe\" ) failed with errno %d, "
684
+ " some stack frames may not be symbolized\n " , readlink_error);
685
+ module_name_len = internal_snprintf (buf, buf_len, " /proc/self/exe" );
686
686
CHECK_LT (module_name_len, buf_len);
687
- buf[module_name_len] = ' \0 ' ;
688
687
}
689
688
return module_name_len;
690
689
}
0 commit comments