Check return values of functions declared with warn_unused_result
attribute in GLIBC 2.8. * cli/cli-cmds.c (pwd_command): Check return value from getcwd. * inflow.c (check_syscall): New function. (new_tty): Use check_syscall to check return values from open and dup. * linux-nat.c (linux_nat_info_proc_cmd): Check return value from fgets. * main.c (captured_main): Call cwd after setting up gdb_stderr; check for errors from getcwd. * mi/mi-cmd-env.c (mi_cmd_env_pwd): Check return value from getcwd. * ui-file.c (stdio_file_write): Ignore return value from fwrite. (stdio_file_fputs): Same. * utils.c (internal_vproblem): abort if last-ditch error message write fails.
This commit is contained in:
parent
fdb7262ae4
commit
bf1d7d9ce0
8 changed files with 68 additions and 21 deletions
14
gdb/utils.c
14
gdb/utils.c
|
@ -862,10 +862,16 @@ internal_vproblem (struct internal_problem *problem,
|
|||
case 1:
|
||||
dejavu = 2;
|
||||
fputs_unfiltered (msg, gdb_stderr);
|
||||
abort (); /* NOTE: GDB has only three calls to abort(). */
|
||||
abort (); /* NOTE: GDB has only four calls to abort(). */
|
||||
default:
|
||||
dejavu = 3;
|
||||
write (STDERR_FILENO, msg, sizeof (msg));
|
||||
/* Newer GLIBC versions put the warn_unused_result attribute
|
||||
on write, but this is one of those rare cases where
|
||||
ignoring the return value is correct. Casting to (void)
|
||||
does not fix this problem. This is the solution suggested
|
||||
at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509. */
|
||||
if (write (STDERR_FILENO, msg, sizeof (msg)) != sizeof (msg))
|
||||
abort (); /* NOTE: GDB has only four calls to abort(). */
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
@ -930,7 +936,7 @@ further debugging may prove unreliable.", file, line, problem->name, msg);
|
|||
if (quit_p)
|
||||
{
|
||||
if (dump_core_p)
|
||||
abort (); /* NOTE: GDB has only three calls to abort(). */
|
||||
abort (); /* NOTE: GDB has only four calls to abort(). */
|
||||
else
|
||||
exit (1);
|
||||
}
|
||||
|
@ -940,7 +946,7 @@ further debugging may prove unreliable.", file, line, problem->name, msg);
|
|||
{
|
||||
#ifdef HAVE_WORKING_FORK
|
||||
if (fork () == 0)
|
||||
abort (); /* NOTE: GDB has only three calls to abort(). */
|
||||
abort (); /* NOTE: GDB has only four calls to abort(). */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue