From f9d0bc22f5ca019f3c517b42ea4a50867fe56700 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 29 Nov 2024 11:41:49 +0900 Subject: [PATCH] Remove a useless check if fd is negative If `slave` is negative, neither `dup2(slave,0)` or `close(slave)` should be executed. I believe this check is completely useless. --- ext/pty/pty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 725589a8ea..7c79f81e33 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -180,7 +180,7 @@ obtain_ctty(int master, int slave, const char *slavename, char *errbuf, size_t e dup2(slave,0); dup2(slave,1); dup2(slave,2); - if (slave < 0 || slave > 2) (void)!close(slave); + if (slave > 2) (void)!close(slave); return 0; }