}
# if defined(LINUX) && !defined(SMALL_CONFIG)
/* Try for a line number. */
- {
+ do {
FILE *pipe;
# define EXE_SZ 100
static char exe_name[EXE_SZ];
char preload_buf[PRELOAD_SZ];
static GC_bool found_exe_name = FALSE;
static GC_bool will_fail = FALSE;
- int ret_code;
+
/* Try to get it via a hairy and expensive scheme. */
/* First we get the name of the executable: */
- if (will_fail) goto out;
+ if (will_fail)
+ break;
if (!found_exe_name) {
- ret_code = readlink("/proc/self/exe", exe_name, EXE_SZ);
+ int ret_code = readlink("/proc/self/exe", exe_name, EXE_SZ);
+
if (ret_code < 0 || ret_code >= EXE_SZ
|| exe_name[0] != '/') {
will_fail = TRUE; /* Don't try again. */
- goto out;
+ break;
}
exe_name[ret_code] = '\0';
found_exe_name = TRUE;
size_t old_len = strlen(old_preload);
if (old_len >= PRELOAD_SZ) {
will_fail = TRUE;
- goto out;
+ break;
}
BCOPY(old_preload, preload_buf, old_len + 1);
unsetenv ("LD_PRELOAD");
&& 0 != setenv ("LD_PRELOAD", preload_buf, 0)) {
WARN("Failed to reset LD_PRELOAD\n", 0);
}
- if (pipe == NULL
- || (result_len = fread(result_buf, 1,
- RESULT_SZ - 1, pipe)) == 0) {
- if (pipe != NULL) pclose(pipe);
+ if (NULL == pipe) {
will_fail = TRUE;
- goto out;
+ break;
+ }
+ result_len = fread(result_buf, 1, RESULT_SZ - 1, pipe);
+ (void)pclose(pipe);
+ if (0 == result_len) {
+ will_fail = TRUE;
+ break;
}
if (result_buf[result_len - 1] == '\n') --result_len;
result_buf[result_len] = 0;
if (result_buf[0] == '?'
|| (result_buf[result_len-2] == ':'
- && result_buf[result_len-1] == '0')) {
- pclose(pipe);
- goto out;
- }
+ && result_buf[result_len-1] == '0'))
+ break;
/* Get rid of embedded newline, if any. Test for "main" */
{
char * nl = strchr(result_buf, '\n');
/* name computed previously is discarded */
# endif
name = result_buf;
- pclose(pipe);
- out:;
- }
+ } while (0);
# endif /* LINUX */
GC_err_printf("\t\t%s\n", name);
# if defined(GC_HAVE_BUILTIN_BACKTRACE) \