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

Side by Side Diff: fusl/src/passwd/getgr_a.c

Issue 1575153003: Remove -Wno-logical-op-parentheses for fusl build (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 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 <pthread.h> 1 #include <pthread.h>
2 #include <byteswap.h> 2 #include <byteswap.h>
3 #include <string.h> 3 #include <string.h>
4 #include <unistd.h> 4 #include <unistd.h>
5 #include "pwf.h" 5 #include "pwf.h"
6 #include "nscd.h" 6 #include "nscd.h"
7 7
8 static char *itoa(char *p, uint32_t x) 8 static char *itoa(char *p, uint32_t x)
9 { 9 {
10 // number of digits in a uint32_t + NUL 10 // number of digits in a uint32_t + NUL
(...skipping 15 matching lines...) Expand all
26 *res = 0; 26 *res = 0;
27 27
28 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); 28 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
29 f = fopen("/etc/group", "rbe"); 29 f = fopen("/etc/group", "rbe");
30 if (!f) { 30 if (!f) {
31 rv = errno; 31 rv = errno;
32 goto done; 32 goto done;
33 } 33 }
34 34
35 while (!(rv = __getgrent_a(f, gr, buf, size, mem, nmem, res)) && *res) { 35 while (!(rv = __getgrent_a(f, gr, buf, size, mem, nmem, res)) && *res) {
36 » » if (name && !strcmp(name, (*res)->gr_name) 36 » » if ((name && !strcmp(name, (*res)->gr_name))
37 » » || !name && (*res)->gr_gid == gid) { 37 » » || (!name && (*res)->gr_gid == gid)) {
38 break; 38 break;
39 } 39 }
40 } 40 }
41 fclose(f); 41 fclose(f);
42 42
43 if (!*res && (rv == 0 || rv == ENOENT || rv == ENOTDIR)) { 43 if (!*res && (rv == 0 || rv == ENOENT || rv == ENOTDIR)) {
44 int32_t req = name ? GETGRBYNAME : GETGRBYGID; 44 int32_t req = name ? GETGRBYNAME : GETGRBYGID;
45 int32_t i; 45 int32_t i;
46 const char *key; 46 const char *key;
47 int32_t groupbuf[GR_LEN] = {0}; 47 int32_t groupbuf[GR_LEN] = {0};
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 gr->gr_passwd = gr->gr_name + groupbuf[GRNAMELEN]; 142 gr->gr_passwd = gr->gr_name + groupbuf[GRNAMELEN];
143 gr->gr_gid = groupbuf[GRGID]; 143 gr->gr_gid = groupbuf[GRGID];
144 gr->gr_mem = *mem; 144 gr->gr_mem = *mem;
145 145
146 if (gr->gr_passwd[-1] 146 if (gr->gr_passwd[-1]
147 || gr->gr_passwd[groupbuf[GRPASSWDLEN]-1]) { 147 || gr->gr_passwd[groupbuf[GRPASSWDLEN]-1]) {
148 rv = EIO; 148 rv = EIO;
149 goto cleanup_f; 149 goto cleanup_f;
150 } 150 }
151 151
152 » » if (name && strcmp(name, gr->gr_name) 152 » » if ((name && strcmp(name, gr->gr_name))
153 » » || !name && gid != gr->gr_gid) { 153 » » || (!name && gid != gr->gr_gid)) {
154 rv = EIO; 154 rv = EIO;
155 goto cleanup_f; 155 goto cleanup_f;
156 } 156 }
157 157
158 *res = gr; 158 *res = gr;
159 159
160 cleanup_f: 160 cleanup_f:
161 fclose(f); 161 fclose(f);
162 goto done; 162 goto done;
163 } 163 }
164 164
165 done: 165 done:
166 pthread_setcancelstate(cs, 0); 166 pthread_setcancelstate(cs, 0);
167 if (rv) errno = rv; 167 if (rv) errno = rv;
168 return rv; 168 return rv;
169 } 169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698