incorrect check for open failure in openpty function
authorRich Felker <dalias@aerifal.cx>
Fri, 22 Jul 2011 04:23:36 +0000 (00:23 -0400)
committerRich Felker <dalias@aerifal.cx>
Fri, 22 Jul 2011 04:23:36 +0000 (00:23 -0400)
-1, not 0, indicates failure

src/misc/openpty.c

index 0b4eb22..1020247 100644 (file)
@@ -12,7 +12,7 @@ int openpty(int *m, int *s, char *name, const struct termios *tio, const struct
        char buf[20];
 
        *m = open("/dev/ptmx", O_RDWR|O_NOCTTY);
        char buf[20];
 
        *m = open("/dev/ptmx", O_RDWR|O_NOCTTY);
-       if (!*m) return -1;
+       if (*m < 0) return -1;
 
        if (ioctl(*m, TIOCSPTLCK, &n) || ioctl (*m, TIOCGPTN, &n)) {
                close(*m);
 
        if (ioctl(*m, TIOCSPTLCK, &n) || ioctl (*m, TIOCGPTN, &n)) {
                close(*m);