ash: builtin: Mark more regular built-ins
[oweals/busybox.git] / libbb / getpty.c
index 6a15cff2fb36bcddd0ad2e58ebf119cba8c4660a..9ec6265ad3648b7e1c920e1a36ba1e2cf4619ccf 100644 (file)
@@ -5,7 +5,6 @@
  *
  * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
-
 #include "libbb.h"
 
 #define DEBUG 0
@@ -16,23 +15,25 @@ int FAST_FUNC xgetpty(char *line)
 
 #if ENABLE_FEATURE_DEVPTS
        p = open("/dev/ptmx", O_RDWR);
-       if (p > 0) {
+       if (p >= 0) {
                grantpt(p); /* chmod+chown corresponding slave pty */
                unlockpt(p); /* (what does this do?) */
-#ifndef HAVE_PTSNAME_R
-               const char *name;
-               name = ptsname(p); /* find out the name of slave pty */
-               if (!name) {
-                       bb_perror_msg_and_die("ptsname error (is /dev/pts mounted?)");
+# ifndef HAVE_PTSNAME_R
+               {
+                       const char *name;
+                       name = ptsname(p); /* find out the name of slave pty */
+                       if (!name) {
+                               bb_simple_perror_msg_and_die("ptsname error (is /dev/pts mounted?)");
+                       }
+                       safe_strncpy(line, name, GETPTY_BUFSIZE);
                }
-               safe_strncpy(line, name, GETPTY_BUFSIZE);
-#else
+# else
                /* find out the name of slave pty */
                if (ptsname_r(p, line, GETPTY_BUFSIZE-1) != 0) {
-                       bb_perror_msg_and_die("ptsname error (is /dev/pts mounted?)");
+                       bb_simple_perror_msg_and_die("ptsname error (is /dev/pts mounted?)");
                }
                line[GETPTY_BUFSIZE-1] = '\0';
-#endif
+# endif
                return p;
        }
 #else
@@ -60,5 +61,5 @@ int FAST_FUNC xgetpty(char *line)
                }
        }
 #endif /* FEATURE_DEVPTS */
-       bb_error_msg_and_die("can't find free pty");
+       bb_simple_error_msg_and_die("can't find free pty");
 }