diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2017-01-18 16:28:15 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2017-01-18 16:28:15 +0100 |
commit | 5d78d1a31658f76f668eb92e367ccd600a7db8a7 (patch) | |
tree | 56eccd35539ea669b551920a21e8a137cf26fe76 | |
parent | 29c03495e63efb155077d51da4445213e4a82e1f (diff) | |
download | hex-5d78d1a31658f76f668eb92e367ccd600a7db8a7.tar.gz hex-5d78d1a31658f76f668eb92e367ccd600a7db8a7.tar.xz hex-5d78d1a31658f76f668eb92e367ccd600a7db8a7.zip |
Fix error checking on input file
-rw-r--r-- | hex.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -1937,13 +1937,13 @@ main (int argc, char *argv[]) if ((input_fd = dup (STDIN_FILENO)) < 0) exit_fatal ("cannot read input: %s", strerror (errno)); close (STDIN_FILENO); - if (open ("/dev/tty", O_RDWR)) + if (open ("/dev/tty", O_RDWR) != STDIN_FILENO) exit_fatal ("cannot open the terminal: %s", strerror (errno)); } else if (argc == 1) { g_ctx.filename = xstrdup (argv[0]); - if (!(input_fd = open (argv[0], O_RDONLY))) + if ((input_fd = open (argv[0], O_RDONLY)) < 0) exit_fatal ("cannot open `%s': %s", argv[0], strerror (errno)); } else |