[hackers] [st] dup() -> dup2() || FRIGN

From: <git_AT_suckless.org>
Date: Tue, 22 Sep 2015 14:15:35 +0200 (CEST)

commit 20d53cebc122829449524ef339ce44e13c6e85ec
Author: FRIGN <dev_AT_frign.de>
AuthorDate: Tue Sep 22 13:13:25 2015 +0200
Commit: FRIGN <dev_AT_frign.de>
CommitDate: Tue Sep 22 14:15:24 2015 +0200

    dup() -> dup2()
    
    gcc would warn about an unused result. We know it is 0 and dup()
    can't fail in these circumstances, as we closed fd0 previously.
    Using dup2() to do the same saves one line and shuts gcc up, bringing
    us a clean build back.

diff --git a/st.c b/st.c
index bd8b815..bcf74b3 100644
--- a/st.c
+++ b/st.c
_AT_@ -1430,8 +1430,7 @@ ttynew(void)
         if (opt_line) {
                 if ((cmdfd = open(opt_line, O_RDWR)) < 0)
                         die("open line failed: %s\n", strerror(errno));
- close(0);
- dup(cmdfd);
+ dup2(cmdfd, 0);
                 stty();
                 return;
         }
Received on Tue Sep 22 2015 - 14:15:35 CEST

This archive was generated by hypermail 2.3.0 : Tue Sep 22 2015 - 14:24:11 CEST