]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
terminal-util: remove unnecessary check of result of isatty() (#4000)
author0xAX <0xAX@users.noreply.github.com>
Fri, 19 Aug 2016 22:51:54 +0000 (01:51 +0300)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 Aug 2016 22:51:54 +0000 (18:51 -0400)
After the call of the isatty() we check its result twice in the
open_terminal(). There are no sense to check result of isatty() that
it is less than zero and return -errno, because as described in
documentation:

isatty() returns 1 if fd is an open file descriptor referring to a
terminal;  otherwise 0 is returned, and errno is set to indicate the
error.

So it can't be less than zero.

src/basic/terminal-util.c

index bfa936bd4e6e591a6c29211d221828b8244bd4bc..eafdea9eb35566d9624956aea944b687f2596126 100644 (file)
@@ -346,12 +346,7 @@ int open_terminal(const char *name, int mode) {
         }
 
         r = isatty(fd);
-        if (r < 0) {
-                safe_close(fd);
-                return -errno;
-        }
-
-        if (!r) {
+        if (r == 0) {
                 safe_close(fd);
                 return -ENOTTY;
         }