Rewrite to allow omitting initialization of global variables.
[kopensolaris-gnu/glibc.git] / misc / ttyslot.c
index 794cada..7dc9b27 100644 (file)
@@ -59,12 +59,12 @@ ttyslot()
 
        setttyent();
        for (cnt = 0; cnt < 3; ++cnt)
-               if (__ttyname_r (cnt, name, buflen) >= 0) {
-                       if (p = rindex(name, '/'))
+               if (__ttyname_r (cnt, name, buflen) == 0) {
+                       if ((p = rindex(name, '/')))
                                ++p;
                        else
                                p = name;
-                       for (slot = 1; ttyp = getttyent(); ++slot)
+                       for (slot = 1; (ttyp = getttyent()); ++slot)
                                if (!strcmp(ttyp->ty_name, p)) {
                                        endttyent();
                                        return(slot);