diff options
author | Jim Blandy <jimb@codesourcery.com> | 2009-01-06 18:31:59 +0000 |
---|---|---|
committer | Jim Blandy <jimb@codesourcery.com> | 2009-01-06 18:31:59 +0000 |
commit | bf1d7d9ce0e35cfa01400e2da11f0d84ea89e481 (patch) | |
tree | 14141ae5495ade474ca69afa2dbe85a60e302989 /gdb/inflow.c | |
parent | fdb7262ae487eccebfaf84f3a5cbecbdeae2c5c7 (diff) | |
download | fsf-binutils-gdb-bf1d7d9ce0e35cfa01400e2da11f0d84ea89e481.zip fsf-binutils-gdb-bf1d7d9ce0e35cfa01400e2da11f0d84ea89e481.tar.gz fsf-binutils-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/inflow.c')
-rw-r--r-- | gdb/inflow.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/gdb/inflow.c b/gdb/inflow.c index a7cb25f..972b52e 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -523,6 +523,20 @@ new_tty_prefork (const char *ttyname) inferior_thisrun_terminal = ttyname; } + +/* If RESULT, assumed to be the return value from a system call, is + negative, print the error message indicated by errno and exit. + MSG should identify the operation that failed. */ +static void +check_syscall (const char *msg, int result) +{ + if (result < 0) + { + print_sys_errmsg (msg, errno); + _exit (1); + } +} + void new_tty (void) { @@ -549,27 +563,23 @@ new_tty (void) /* Now open the specified new terminal. */ tty = open (inferior_thisrun_terminal, O_RDWR | O_NOCTTY); - if (tty == -1) - { - print_sys_errmsg (inferior_thisrun_terminal, errno); - _exit (1); - } + check_syscall (inferior_thisrun_terminal, tty); /* Avoid use of dup2; doesn't exist on all systems. */ if (tty != 0) { close (0); - dup (tty); + check_syscall ("dup'ing tty into fd 0", dup (tty)); } if (tty != 1) { close (1); - dup (tty); + check_syscall ("dup'ing tty into fd 1", dup (tty)); } if (tty != 2) { close (2); - dup (tty); + check_syscall ("dup'ing tty into fd 2", dup (tty)); } #ifdef TIOCSCTTY |