diff options
author | 2002-07-06 03:07:41 +0000 | |
---|---|---|
committer | 2002-07-06 03:07:41 +0000 | |
commit | 2e3ad22a6447e08c32423d9e84e01e86dd7f6aec (patch) | |
tree | 8716f81b3789d937f39342cb02a34f835b0b3cc0 /lib/libc | |
parent | KNF, realloc fix, and clean usage (diff) | |
download | wireguard-openbsd-2e3ad22a6447e08c32423d9e84e01e86dd7f6aec.tar.xz wireguard-openbsd-2e3ad22a6447e08c32423d9e84e01e86dd7f6aec.zip |
KNF
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/getgrent.c | 61 | ||||
-rw-r--r-- | lib/libc/gen/getnetgrent.c | 30 | ||||
-rw-r--r-- | lib/libc/gen/getpwent.c | 40 |
3 files changed, 67 insertions, 64 deletions
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index e977e7a8d52..a4f43435258 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -33,7 +33,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: getgrent.c,v 1.16 2002/05/24 21:22:37 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: getgrent.c,v 1.17 2002/07/06 03:08:13 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -86,8 +86,9 @@ static int __ypcurrentlen; struct group * getgrent() { - struct group *p_gr = (struct group*)_THREAD_PRIVATE(gr,_gr_group,NULL); - struct group_storage *gs = (struct group_storage *)_THREAD_PRIVATE(gr_storage,gr_storage,NULL); + struct group *p_gr = (struct group*)_THREAD_PRIVATE(gr, _gr_group, NULL); + struct group_storage *gs = (struct group_storage *)_THREAD_PRIVATE(gr_storage, + gr_storage, NULL); _THREAD_PRIVATE_MUTEX_LOCK(gr); if ((!_gr_fp && !start_gr()) || !grscan(0, 0, NULL, p_gr, gs)) @@ -121,7 +122,8 @@ getgrnam(name) const char *name; { struct group *p_gr = (struct group*)_THREAD_PRIVATE(gr,_gr_group,NULL); - struct group_storage *gs = (struct group_storage *)_THREAD_PRIVATE(gr_storage,gr_storage,NULL); + struct group_storage *gs = (struct group_storage *)_THREAD_PRIVATE(gr_storage, + gr_storage, NULL); return getgrnam_gs(name, p_gr, gs); } @@ -173,8 +175,9 @@ struct group * getgrgid(gid) gid_t gid; { - struct group *p_gr = (struct group*)_THREAD_PRIVATE(gr,_gr_group,NULL); - struct group_storage *gs = (struct group_storage *)_THREAD_PRIVATE(gr_storage,gr_storage,NULL); + struct group *p_gr = (struct group*)_THREAD_PRIVATE(gr, _gr_group, NULL); + struct group_storage *gs = (struct group_storage *)_THREAD_PRIVATE(gr_storage, + gr_storage, NULL); return getgrgid_gs(gid, p_gr, gs); } @@ -209,7 +212,7 @@ start_gr() rewind(_gr_fp); #ifdef YP __ypmode = YPMODE_NONE; - if(__ypcurrent) + if (__ypcurrent) free(__ypcurrent); __ypcurrent = NULL; #endif @@ -250,7 +253,7 @@ endgrent_basic() _gr_fp = NULL; #ifdef YP __ypmode = YPMODE_NONE; - if(__ypcurrent) + if (__ypcurrent) free(__ypcurrent); __ypcurrent = NULL; #endif @@ -292,26 +295,26 @@ grscan(search, gid, name, p_gr, gs) for (;;) { #ifdef YP - if(__ypmode != YPMODE_NONE) { + if (__ypmode != YPMODE_NONE) { - if(!__ypdomain) { - if(yp_get_default_domain(&__ypdomain)) { + if (!__ypdomain) { + if (yp_get_default_domain(&__ypdomain)) { __ypmode = YPMODE_NONE; - if(grname != (char *)NULL) { + if (grname != (char *)NULL) { free(grname); grname = (char *)NULL; } continue; } } - switch(__ypmode) { + switch (__ypmode) { case YPMODE_FULL: - if(__ypcurrent) { + if (__ypcurrent) { r = yp_next(__ypdomain, "group.byname", - __ypcurrent, __ypcurrentlen, - &key, &keylen, &data, &datalen); + __ypcurrent, __ypcurrentlen, + &key, &keylen, &data, &datalen); free(__ypcurrent); - if(r != 0) { + if (r != 0) { __ypcurrent = NULL; __ypmode = YPMODE_NONE; free(data); @@ -323,9 +326,9 @@ grscan(search, gid, name, p_gr, gs) free(data); } else { r = yp_first(__ypdomain, "group.byname", - &__ypcurrent, &__ypcurrentlen, - &data, &datalen); - if(r != 0) { + &__ypcurrent, &__ypcurrentlen, + &data, &datalen); + if (r != 0) { __ypmode = YPMODE_NONE; free(data); continue; @@ -335,14 +338,14 @@ grscan(search, gid, name, p_gr, gs) } break; case YPMODE_NAME: - if(grname != (char *)NULL) { + if (grname != (char *)NULL) { r = yp_match(__ypdomain, "group.byname", - grname, strlen(grname), - &data, &datalen); + grname, strlen(grname), + &data, &datalen); __ypmode = YPMODE_NONE; free(grname); grname = (char *)NULL; - if(r != 0) { + if (r != 0) { free(data); continue; } @@ -372,17 +375,17 @@ grscan(search, gid, name, p_gr, gs) } #ifdef YP if (line[0] == '+') { - switch(line[1]) { + switch (line[1]) { case ':': case '\0': case '\n': - if(_yp_check(NULL)) { + if (_yp_check(NULL)) { if (!search) { __ypmode = YPMODE_FULL; continue; } - if(!__ypdomain && - yp_get_default_domain(&__ypdomain)) + if (!__ypdomain && + yp_get_default_domain(&__ypdomain)) continue; if (name) { r = yp_match(__ypdomain, @@ -422,7 +425,7 @@ grscan(search, gid, name, p_gr, gs) } break; default: - if(_yp_check(NULL)) { + if (_yp_check(NULL)) { register char *tptr; tptr = strsep(&bp, ":\n"); diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index 235cba4d130..aec19041911 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getnetgrent.c,v 1.12 2002/02/17 19:42:22 millert Exp $ */ +/* $OpenBSD: getnetgrent.c,v 1.13 2002/07/06 03:07:41 deraadt Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: getnetgrent.c,v 1.12 2002/02/17 19:42:22 millert Exp $"; +static char *rcsid = "$OpenBSD: getnetgrent.c,v 1.13 2002/07/06 03:07:41 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -262,8 +262,8 @@ lookup(ypdom, name, line, bywhat) int bywhat; { #ifdef YP - int i; - char *map = NULL; + int i; + char *map = NULL; #endif if (_ng_db) { @@ -324,7 +324,7 @@ lookup(ypdom, name, line, bywhat) * _ng_parse(): Parse a line and return: _NG_ERROR: Syntax Error _NG_NONE: * line was empty or a comment _NG_GROUP: line had a netgroup definition, * returned in ng _NG_NAME: line had a netgroup name, returned in name - * + * * Public since used by netgroup_mkdb */ int @@ -349,8 +349,8 @@ _ng_parse(p, name, ng) } return _NG_GROUP; } else { - char *np; - int i; + char *np; + int i; for (np = *p; **p && !_NG_ISSPACE(**p); (*p)++) continue; @@ -435,16 +435,16 @@ in_check(host, user, domain, ng) const char *domain; struct netgroup *ng; { - if ((host != NULL) && (ng->ng_host != NULL) - && strcmp(ng->ng_host, host) != 0) + if ((host != NULL) && (ng->ng_host != NULL) && + strcmp(ng->ng_host, host) != 0) return 0; - if ((user != NULL) && (ng->ng_user != NULL) - && strcmp(ng->ng_user, user) != 0) + if ((user != NULL) && (ng->ng_user != NULL) && + strcmp(ng->ng_user, user) != 0) return 0; - if ((domain != NULL) && (ng->ng_domain != NULL) - && strcmp(ng->ng_domain, domain) != 0) + if ((domain != NULL) && (ng->ng_domain != NULL) && + strcmp(ng->ng_domain, domain) != 0) return 0; return 1; @@ -592,11 +592,11 @@ in_lookup(ypdom, group, key, domain, map) /* Domain specified; look in "group.domain" and "*.domain" */ if ((line = in_lookup1(ypdom, key, domain, map)) == NULL) line = in_lookup1(ypdom, NULL, domain, map); - } else + } else line = NULL; if (line == NULL) { - /* + /* * domain not specified or domain lookup failed; look in * "group.*" and "*.*" */ diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 036a35c7f4b..77c689fa8f5 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -33,7 +33,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: getpwent.c,v 1.26 2002/07/06 00:10:36 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: getpwent.c,v 1.27 2002/07/06 03:10:23 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -68,8 +68,8 @@ static int __initdb(void); enum _ypmode { YPMODE_NONE, YPMODE_FULL, YPMODE_USER, YPMODE_NETGRP }; static enum _ypmode __ypmode; -static char *__ypcurrent, *__ypdomain; -static int __ypcurrentlen; +static char *__ypcurrent, *__ypdomain; +static int __ypcurrentlen; static struct passwd *__ypproto = (struct passwd *)NULL; static int __ypflags; static char __ypline[1024]; @@ -109,7 +109,7 @@ __ypexclude_add(name) return (0); new = (struct _ypexclude *)malloc(sizeof(struct _ypexclude)); - if (new == (struct _ypexclude *)NULL) + if (new == NULL) return (1); new->name = strdup(name); if (new->name == (char *)NULL) { @@ -130,7 +130,7 @@ __ypexclude_is(name) struct _ypexclude *curr; for (curr = __ypexclude; curr != (struct _ypexclude *)NULL; - curr = curr->next) { + curr = curr->next) { if (strcmp(curr->name, name) == 0) return (1); /* excluded */ } @@ -143,7 +143,7 @@ __ypexclude_free() struct _ypexclude *curr, *next; for (curr = __ypexclude; curr != (struct _ypexclude *)NULL; - curr = next) { + curr = next) { next = curr->next; free((void *)curr->name); @@ -173,7 +173,7 @@ __ypproto_set() ptr += (strlen(pw->pw_name) + 1); } else __ypproto->pw_name = (char *)NULL; - + /* password */ if (pw->pw_passwd && (pw->pw_passwd)[0]) { ptr = (char *)ALIGN(ptr); @@ -203,7 +203,7 @@ __ypproto_set() ptr += (strlen(pw->pw_gecos) + 1); } else __ypproto->pw_gecos = (char *)NULL; - + /* dir */ if (pw->pw_dir && (pw->pw_dir)[0]) { ptr = (char *)ALIGN(ptr); @@ -263,7 +263,7 @@ char *s; pw->pw_gid = (gid_t)ul; if (count == 9) { long l; - + /* If the ypserv gave us all the fields, use them. */ pw->pw_class = strsep(&bp, ":\n"); if (!(cp = strsep(&bp, ":\n"))) @@ -344,8 +344,8 @@ again: case YPMODE_FULL: if (__ypcurrent) { r = yp_next(__ypdomain, (PASSWD_BYNAME), - __ypcurrent, __ypcurrentlen, - &key, &keylen, &data, &datalen); + __ypcurrent, __ypcurrentlen, + &key, &keylen, &data, &datalen); free(__ypcurrent); if (r != 0) { __ypcurrent = NULL; @@ -362,8 +362,8 @@ again: data = NULL; } else { r = yp_first(__ypdomain, (PASSWD_BYNAME), - &__ypcurrent, &__ypcurrentlen, - &data, &datalen); + &__ypcurrent, &__ypcurrentlen, + &data, &datalen); if (r != 0) { __ypmode = YPMODE_NONE; if (data) @@ -384,8 +384,8 @@ again: } if (user && *user) { r = yp_match(__ypdomain, (PASSWD_BYNAME), - user, strlen(user), - &data, &datalen); + user, strlen(user), + &data, &datalen); } else goto again; if (r != 0) { @@ -404,8 +404,8 @@ again: case YPMODE_USER: if (name != (char *)NULL) { r = yp_match(__ypdomain, (PASSWD_BYNAME), - name, strlen(name), - &data, &datalen); + name, strlen(name), + &data, &datalen); __ypmode = YPMODE_NONE; free(name); name = (char *)NULL; @@ -509,8 +509,8 @@ __has_yppw() pkey.data = (u_char *)bf; pkey.size = MIN(len, _PW_NAME_LEN) + 1; - if ((_pw_db->get)(_pw_db, &key, &data, 0) - && (_pw_db->get)(_pw_db, &pkey, &pdata, 0)) + if ((_pw_db->get)(_pw_db, &key, &data, 0) && + (_pw_db->get)(_pw_db, &pkey, &pdata, 0)) return (0); /* No YP. */ return (1); } @@ -555,7 +555,7 @@ __has_ypmaster() &key, &keylen, &result, &resultlen)) { saved_uid = uid; saved_euid = euid; - checked = 0; + checked = 0; return (checked); } free (result); |