From: 0xAX <0xAX@users.noreply.github.com> Date: Fri, 19 Aug 2016 22:51:54 +0000 (+0300) Subject: terminal-util: remove unnecessary check of result of isatty() (#4000) X-Git-Tag: v232.2~81 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;ds=sidebyside;h=906f94da76802b2aae4dd052018766f5378ae4b8;p=elogind.git terminal-util: remove unnecessary check of result of isatty() (#4000) 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. --- diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 215b76488..efd35cd72 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -347,12 +347,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; }