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

Side by Side Diff: fusl/src/passwd/getpwent_a.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 "pwf.h" 1 #include "pwf.h"
2 #include <pthread.h> 2 #include <pthread.h>
3 3
4 static unsigned atou(char **s) 4 static unsigned atou(char** s) {
5 { 5 unsigned x;
6 » unsigned x; 6 for (x = 0; **s - '0' < 10U; ++*s)
7 » for (x=0; **s-'0'<10U; ++*s) x=10*x+(**s-'0'); 7 x = 10 * x + (**s - '0');
8 » return x; 8 return x;
9 } 9 }
10 10
11 int __getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *size, struct p asswd **res) 11 int __getpwent_a(FILE* f,
12 { 12 struct passwd* pw,
13 » ssize_t l; 13 char** line,
14 » char *s; 14 size_t* size,
15 » int rv = 0; 15 struct passwd** res) {
16 » int cs; 16 ssize_t l;
17 » pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); 17 char* s;
18 » for (;;) { 18 int rv = 0;
19 » » if ((l=getline(line, size, f)) < 0) { 19 int cs;
20 » » » rv = ferror(f) ? errno : 0; 20 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
21 » » » free(*line); 21 for (;;) {
22 » » » *line = 0; 22 if ((l = getline(line, size, f)) < 0) {
23 » » » pw = 0; 23 rv = ferror(f) ? errno : 0;
24 » » » break; 24 free(*line);
25 » » } 25 *line = 0;
26 » » line[0][l-1] = 0; 26 pw = 0;
27 break;
28 }
29 line[0][l - 1] = 0;
27 30
28 » » s = line[0]; 31 s = line[0];
29 » » pw->pw_name = s++; 32 pw->pw_name = s++;
30 » » if (!(s = strchr(s, ':'))) continue; 33 if (!(s = strchr(s, ':')))
34 continue;
31 35
32 » » *s++ = 0; pw->pw_passwd = s; 36 *s++ = 0;
33 » » if (!(s = strchr(s, ':'))) continue; 37 pw->pw_passwd = s;
38 if (!(s = strchr(s, ':')))
39 continue;
34 40
35 » » *s++ = 0; pw->pw_uid = atou(&s); 41 *s++ = 0;
36 » » if (*s != ':') continue; 42 pw->pw_uid = atou(&s);
43 if (*s != ':')
44 continue;
37 45
38 » » *s++ = 0; pw->pw_gid = atou(&s); 46 *s++ = 0;
39 » » if (*s != ':') continue; 47 pw->pw_gid = atou(&s);
48 if (*s != ':')
49 continue;
40 50
41 » » *s++ = 0; pw->pw_gecos = s; 51 *s++ = 0;
42 » » if (!(s = strchr(s, ':'))) continue; 52 pw->pw_gecos = s;
53 if (!(s = strchr(s, ':')))
54 continue;
43 55
44 » » *s++ = 0; pw->pw_dir = s; 56 *s++ = 0;
45 » » if (!(s = strchr(s, ':'))) continue; 57 pw->pw_dir = s;
58 if (!(s = strchr(s, ':')))
59 continue;
46 60
47 » » *s++ = 0; pw->pw_shell = s; 61 *s++ = 0;
48 » » break; 62 pw->pw_shell = s;
49 » } 63 break;
50 » pthread_setcancelstate(cs, 0); 64 }
51 » *res = pw; 65 pthread_setcancelstate(cs, 0);
52 » if (rv) errno = rv; 66 *res = pw;
53 » return rv; 67 if (rv)
68 errno = rv;
69 return rv;
54 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698