aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>2009-01-06 18:31:59 +0000
committerJim Blandy <jimb@codesourcery.com>2009-01-06 18:31:59 +0000
commitbf1d7d9ce0e35cfa01400e2da11f0d84ea89e481 (patch)
tree14141ae5495ade474ca69afa2dbe85a60e302989 /gdb/utils.c
parentfdb7262ae487eccebfaf84f3a5cbecbdeae2c5c7 (diff)
downloadgdb-bf1d7d9ce0e35cfa01400e2da11f0d84ea89e481.zip
gdb-bf1d7d9ce0e35cfa01400e2da11f0d84ea89e481.tar.gz
gdb-bf1d7d9ce0e35cfa01400e2da11f0d84ea89e481.tar.bz2
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.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index 4740a48..5ceb7ae 100644
--- a/gdb/utils.c
+++ b/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
}
}