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

Side by Side Diff: fusl/src/unistd/ttyname_r.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 <unistd.h> 1 #include <unistd.h>
2 #include <errno.h> 2 #include <errno.h>
3 3
4 void __procfdname(char *, unsigned); 4 void __procfdname(char*, unsigned);
5 5
6 int ttyname_r(int fd, char *name, size_t size) 6 int ttyname_r(int fd, char* name, size_t size) {
7 { 7 char procname[sizeof "/proc/self/fd/" + 3 * sizeof(int) + 2];
8 » char procname[sizeof "/proc/self/fd/" + 3*sizeof(int) + 2]; 8 ssize_t l;
9 » ssize_t l;
10 9
11 » if (!isatty(fd)) return ENOTTY; 10 if (!isatty(fd))
11 return ENOTTY;
12 12
13 » __procfdname(procname, fd); 13 __procfdname(procname, fd);
14 » l = readlink(procname, name, size); 14 l = readlink(procname, name, size);
15 15
16 » if (l < 0) return errno; 16 if (l < 0)
17 » else if (l == size) return ERANGE; 17 return errno;
18 » else { 18 else if (l == size)
19 » » name[l] = 0; 19 return ERANGE;
20 » » return 0; 20 else {
21 » } 21 name[l] = 0;
22 return 0;
23 }
22 } 24 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698