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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: fusl/src/passwd/getpwent_a.c
diff --git a/fusl/src/passwd/getpwent_a.c b/fusl/src/passwd/getpwent_a.c
index d1b4b53ce2008234ea37a4e5cfe5e78f5456142f..b339ca290e24b01906b86d2505fb30e29bbb4073 100644
--- a/fusl/src/passwd/getpwent_a.c
+++ b/fusl/src/passwd/getpwent_a.c
@@ -1,54 +1,70 @@
#include "pwf.h"
#include <pthread.h>
-static unsigned atou(char **s)
-{
- unsigned x;
- for (x=0; **s-'0'<10U; ++*s) x=10*x+(**s-'0');
- return x;
+static unsigned atou(char** s) {
+ unsigned x;
+ for (x = 0; **s - '0' < 10U; ++*s)
+ x = 10 * x + (**s - '0');
+ return x;
}
-int __getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *size, struct passwd **res)
-{
- ssize_t l;
- char *s;
- int rv = 0;
- int cs;
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- for (;;) {
- if ((l=getline(line, size, f)) < 0) {
- rv = ferror(f) ? errno : 0;
- free(*line);
- *line = 0;
- pw = 0;
- break;
- }
- line[0][l-1] = 0;
-
- s = line[0];
- pw->pw_name = s++;
- if (!(s = strchr(s, ':'))) continue;
-
- *s++ = 0; pw->pw_passwd = s;
- if (!(s = strchr(s, ':'))) continue;
-
- *s++ = 0; pw->pw_uid = atou(&s);
- if (*s != ':') continue;
-
- *s++ = 0; pw->pw_gid = atou(&s);
- if (*s != ':') continue;
-
- *s++ = 0; pw->pw_gecos = s;
- if (!(s = strchr(s, ':'))) continue;
-
- *s++ = 0; pw->pw_dir = s;
- if (!(s = strchr(s, ':'))) continue;
-
- *s++ = 0; pw->pw_shell = s;
- break;
- }
- pthread_setcancelstate(cs, 0);
- *res = pw;
- if (rv) errno = rv;
- return rv;
+int __getpwent_a(FILE* f,
+ struct passwd* pw,
+ char** line,
+ size_t* size,
+ struct passwd** res) {
+ ssize_t l;
+ char* s;
+ int rv = 0;
+ int cs;
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
+ for (;;) {
+ if ((l = getline(line, size, f)) < 0) {
+ rv = ferror(f) ? errno : 0;
+ free(*line);
+ *line = 0;
+ pw = 0;
+ break;
+ }
+ line[0][l - 1] = 0;
+
+ s = line[0];
+ pw->pw_name = s++;
+ if (!(s = strchr(s, ':')))
+ continue;
+
+ *s++ = 0;
+ pw->pw_passwd = s;
+ if (!(s = strchr(s, ':')))
+ continue;
+
+ *s++ = 0;
+ pw->pw_uid = atou(&s);
+ if (*s != ':')
+ continue;
+
+ *s++ = 0;
+ pw->pw_gid = atou(&s);
+ if (*s != ':')
+ continue;
+
+ *s++ = 0;
+ pw->pw_gecos = s;
+ if (!(s = strchr(s, ':')))
+ continue;
+
+ *s++ = 0;
+ pw->pw_dir = s;
+ if (!(s = strchr(s, ':')))
+ continue;
+
+ *s++ = 0;
+ pw->pw_shell = s;
+ break;
+ }
+ pthread_setcancelstate(cs, 0);
+ *res = pw;
+ if (rv)
+ errno = rv;
+ return rv;
}

Powered by Google App Engine
This is Rietveld 408576698