Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: fusl/src/misc/pty.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include <stdlib.h> 1 #include <stdlib.h>
2 #include <sys/ioctl.h> 2 #include <sys/ioctl.h>
3 #include <stdio.h> 3 #include <stdio.h>
4 #include <fcntl.h> 4 #include <fcntl.h>
5 #include <errno.h> 5 #include <errno.h>
6 #include "libc.h" 6 #include "libc.h"
7 #include "syscall.h" 7 #include "syscall.h"
8 8
9 int posix_openpt(int flags) 9 int posix_openpt(int flags) {
10 { 10 return open("/dev/ptmx", flags);
11 » return open("/dev/ptmx", flags);
12 } 11 }
13 12
14 int grantpt(int fd) 13 int grantpt(int fd) {
15 { 14 return 0;
16 » return 0;
17 } 15 }
18 16
19 int unlockpt(int fd) 17 int unlockpt(int fd) {
20 { 18 int unlock = 0;
21 » int unlock = 0; 19 return ioctl(fd, TIOCSPTLCK, &unlock);
22 » return ioctl(fd, TIOCSPTLCK, &unlock);
23 } 20 }
24 21
25 int __ptsname_r(int fd, char *buf, size_t len) 22 int __ptsname_r(int fd, char* buf, size_t len) {
26 { 23 int pty, err;
27 » int pty, err; 24 if (!buf)
28 » if (!buf) len = 0; 25 len = 0;
29 » if ((err = __syscall(SYS_ioctl, fd, TIOCGPTN, &pty))) return -err; 26 if ((err = __syscall(SYS_ioctl, fd, TIOCGPTN, &pty)))
30 » if (snprintf(buf, len, "/dev/pts/%d", pty) >= len) return ERANGE; 27 return -err;
31 » return 0; 28 if (snprintf(buf, len, "/dev/pts/%d", pty) >= len)
29 return ERANGE;
30 return 0;
32 } 31 }
33 32
34 weak_alias(__ptsname_r, ptsname_r); 33 weak_alias(__ptsname_r, ptsname_r);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698