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

Side by Side Diff: fusl/src/passwd/getpw_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 "pwf.h" 1 #include "pwf.h"
2 #include <pthread.h> 2 #include <pthread.h>
3 3
4 #define FIX(x) (pw->pw_##x = pw->pw_##x-line+buf) 4 #define FIX(x) (pw->pw_##x = pw->pw_##x - line + buf)
5 5
6 static int getpw_r(const char *name, uid_t uid, struct passwd *pw, char *buf, si ze_t size, struct passwd **res) 6 static int getpw_r(const char* name,
7 { 7 uid_t uid,
8 » char *line = 0; 8 struct passwd* pw,
9 » size_t len = 0; 9 char* buf,
10 » int rv = 0; 10 size_t size,
11 » int cs; 11 struct passwd** res) {
12 char* line = 0;
13 size_t len = 0;
14 int rv = 0;
15 int cs;
12 16
13 » pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); 17 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
14 18
15 » rv = __getpw_a(name, uid, pw, &line, &len, res); 19 rv = __getpw_a(name, uid, pw, &line, &len, res);
16 » if (*res && size < len) { 20 if (*res && size < len) {
17 » » *res = 0; 21 *res = 0;
18 » » rv = ERANGE; 22 rv = ERANGE;
19 » } 23 }
20 » if (*res) { 24 if (*res) {
21 » » memcpy(buf, line, len); 25 memcpy(buf, line, len);
22 » » FIX(name); 26 FIX(name);
23 » » FIX(passwd); 27 FIX(passwd);
24 » » FIX(gecos); 28 FIX(gecos);
25 » » FIX(dir); 29 FIX(dir);
26 » » FIX(shell); 30 FIX(shell);
27 » } 31 }
28 » free(line); 32 free(line);
29 » pthread_setcancelstate(cs, 0); 33 pthread_setcancelstate(cs, 0);
30 » return rv; 34 return rv;
31 } 35 }
32 36
33 int getpwnam_r(const char *name, struct passwd *pw, char *buf, size_t size, stru ct passwd **res) 37 int getpwnam_r(const char* name,
34 { 38 struct passwd* pw,
35 » return getpw_r(name, 0, pw, buf, size, res); 39 char* buf,
40 size_t size,
41 struct passwd** res) {
42 return getpw_r(name, 0, pw, buf, size, res);
36 } 43 }
37 44
38 int getpwuid_r(uid_t uid, struct passwd *pw, char *buf, size_t size, struct pass wd **res) 45 int getpwuid_r(uid_t uid,
39 { 46 struct passwd* pw,
40 » return getpw_r(0, uid, pw, buf, size, res); 47 char* buf,
48 size_t size,
49 struct passwd** res) {
50 return getpw_r(0, uid, pw, buf, size, res);
41 } 51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698