libiproute: fix buggy open check: s/if (fd)/if (fd >= 0)/
authorDenis Vlasenko <vda.linux@googlemail.com>
Wed, 10 Dec 2008 14:14:09 +0000 (14:14 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Wed, 10 Dec 2008 14:14:09 +0000 (14:14 -0000)
less: small optimization -15 bytes

miscutils/less.c
networking/libiproute/ll_map.c

index 36d451271e42a7ac548cc11f74a7e5452feab126..27855bbe8b7bc548973948f3bbe6c5d517e6eb55 100644 (file)
@@ -774,9 +774,7 @@ static void buffer_line(int linenum)
 static void open_file_and_read_lines(void)
 {
        if (filename) {
-               int fd = xopen(filename, O_RDONLY);
-               dup2(fd, 0);
-               if (fd) close(fd);
+               xmove_fd(xopen(filename, O_RDONLY), STDIN_FILENO);
        } else {
                /* "less" with no arguments in argv[] */
                /* For status line only */
index 3412dc7632a64d7247dad2ef0016c7ad9048901f..2ed7fbbb39b83bfe02693014027ef3f72e40a851 100644 (file)
@@ -172,7 +172,7 @@ int xll_name_to_index(const char *const name)
 #endif
 
        sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
-       if (sock_fd) {
+       if (sock_fd >= 0) {
                struct ifreq ifr;
                int tmp;