diff options
author | Jim Blandy <jimb@codesourcery.com> | 2009-01-06 18:31:58 +0000 |
---|---|---|
committer | Jim Blandy <jimb@codesourcery.com> | 2009-01-06 18:31:58 +0000 |
commit | 3bdc07d2a6f44070a5ef57b305a2e4c816b0a820 (patch) | |
tree | faa165907390d42b9c1e5511f52580d111839444 /gdb/inflow.c | |
parent | 0bd695e5a4e79c240a67ea794cb83a7324584a8d (diff) | |
download | gdb-3bdc07d2a6f44070a5ef57b305a2e4c816b0a820.tar.gz |
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 a7cb25f3c82..972b52ef733 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 |