diff options
-rw-r--r-- | usr.sbin/config/config.h | 3 | ||||
-rw-r--r-- | usr.sbin/config/gram.y | 5 | ||||
-rw-r--r-- | usr.sbin/config/hash.c | 38 | ||||
-rw-r--r-- | usr.sbin/config/mkmakefile.c | 3 | ||||
-rw-r--r-- | usr.sbin/config/mkswap.c | 8 | ||||
-rw-r--r-- | usr.sbin/config/sem.c | 17 |
6 files changed, 22 insertions, 52 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 75b3ed92373..3f99b0d4acd 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.31 2021/01/26 18:23:49 deraadt Exp $ */ +/* $OpenBSD: config.h,v 1.32 2021/11/28 19:26:03 deraadt Exp $ */ /* $NetBSD: config.h,v 1.30 1997/02/02 21:12:30 thorpej Exp $ */ /* @@ -353,6 +353,7 @@ int mkioconf(void); int mkmakefile(void); /* mkswap.c */ +extern dev_t nodev; int mkswap(void); /* pack.c */ diff --git a/usr.sbin/config/gram.y b/usr.sbin/config/gram.y index b4229937176..d95c6d96282 100644 --- a/usr.sbin/config/gram.y +++ b/usr.sbin/config/gram.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: gram.y,v 1.24 2015/01/16 06:40:16 deraadt Exp $ */ +/* $OpenBSD: gram.y,v 1.25 2021/11/28 19:26:03 deraadt Exp $ */ /* $NetBSD: gram.y,v 1.14 1997/02/02 21:12:32 thorpej Exp $ */ /* @@ -42,7 +42,6 @@ * from: @(#)gram.y 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> /* NODEV */ #include <sys/types.h> #include <ctype.h> #include <stdio.h> @@ -387,7 +386,7 @@ swapdev_list: dev_spec { $$ = $1; }; dev_spec: - WORD { $$ = new_si($1, NODEV); } | + WORD { $$ = new_si($1, nodev); } | major_minor { $$ = new_si(NULL, $1); }; major_minor: diff --git a/usr.sbin/config/hash.c b/usr.sbin/config/hash.c index 9a4101458f3..67dac5af5ef 100644 --- a/usr.sbin/config/hash.c +++ b/usr.sbin/config/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.18 2015/01/17 07:37:14 deraadt Exp $ */ +/* $OpenBSD: hash.c,v 1.19 2021/11/28 19:26:03 deraadt Exp $ */ /* $NetBSD: hash.c,v 1.4 1996/11/07 22:59:43 gwr Exp $ */ /* @@ -41,7 +41,7 @@ * from: @(#)hash.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> /* ALIGNBYTES */ +#include <sys/types.h> #include <stdlib.h> #include <string.h> @@ -77,36 +77,8 @@ static struct hashtab strings; /* round up to next multiple of y, where y is a power of 2 */ #define ROUND(x, y) (((x) + (y) - 1) & ~((y) - 1)) -static void *poolalloc(size_t); static void ht_init(struct hashtab *, size_t); static void ht_expand(struct hashtab *); -/* - * Allocate space that will never be freed. - */ -static void * -poolalloc(size_t size) -{ - char *p; - size_t alloc; - static char *pool; - static size_t nleft; - - if (nleft < size) { - /* - * Compute a `good' size to allocate via malloc. - * 16384 is a guess at a good page size for malloc; - * 32 is a guess at malloc's overhead. - */ - alloc = ROUND(size + 32, 16384) - 32; - p = emalloc(alloc); - nleft = alloc - size; - } else { - p = pool; - nleft -= size; - } - pool = p + size; - return (p); -} /* * Initialize a new hash table. The size must be a power of 2. @@ -161,10 +133,8 @@ static __inline struct hashent * newhashent(const char *name, u_int h) { struct hashent *hp; - char *m; - m = poolalloc(sizeof(*hp) + ALIGNBYTES); - hp = (struct hashent *)ALIGN(m); + hp = emalloc(sizeof(*hp)); hp->h_name = name; hp->h_hash = h; hp->h_next = NULL; @@ -211,7 +181,7 @@ intern(const char *s) if (hp->h_hash == h && strcmp(hp->h_name, s) == 0) return (hp->h_name); l = strlen(s) + 1; - p = poolalloc(l); + p = malloc(l); bcopy(s, p, l); *hpp = newhashent(p, h); if (++ht->ht_used > ht->ht_lim) diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index 47e26257e15..f98d34dff41 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkmakefile.c,v 1.47 2019/06/28 13:33:55 deraadt Exp $ */ +/* $OpenBSD: mkmakefile.c,v 1.48 2021/11/28 19:26:03 deraadt Exp $ */ /* $NetBSD: mkmakefile.c,v 1.34 1997/02/02 21:12:36 thorpej Exp $ */ /* @@ -211,7 +211,6 @@ srcpath(struct files *fi) expand = expandname(nv->nv_name); source = sourcepath(expand ? expand : nv->nv_name); if (access(source, R_OK) == 0) { - /* XXX poolalloc() prevents freeing old nv_name */ if (expand) nv->nv_name = intern(expand); break; diff --git a/usr.sbin/config/mkswap.c b/usr.sbin/config/mkswap.c index d16f632bd91..f4a726fbb5d 100644 --- a/usr.sbin/config/mkswap.c +++ b/usr.sbin/config/mkswap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkswap.c,v 1.18 2019/06/28 13:33:55 deraadt Exp $ */ +/* $OpenBSD: mkswap.c,v 1.19 2021/11/28 19:26:03 deraadt Exp $ */ /* $NetBSD: mkswap.c,v 1.5 1996/08/31 20:58:27 mycroft Exp $ */ /* @@ -41,7 +41,7 @@ * from: @(#)mkswap.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> /* NODEV */ +#include <sys/types.h> #include <err.h> #include <errno.h> @@ -52,6 +52,8 @@ #include "config.h" #include "sem.h" +dev_t nodev = (dev_t)-1; + static int mkoneswap(struct config *); /* @@ -73,7 +75,7 @@ mkdevstr(dev_t d) { static char buf[32]; - if (d == NODEV) + if (d == nodev) (void)snprintf(buf, sizeof buf, "NODEV"); else (void)snprintf(buf, sizeof buf, "makedev(%u, %u)", diff --git a/usr.sbin/config/sem.c b/usr.sbin/config/sem.c index a6c6611e531..b8b4b676c62 100644 --- a/usr.sbin/config/sem.c +++ b/usr.sbin/config/sem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sem.c,v 1.37 2019/02/05 02:17:32 deraadt Exp $ */ +/* $OpenBSD: sem.c,v 1.38 2021/11/28 19:26:03 deraadt Exp $ */ /* $NetBSD: sem.c,v 1.10 1996/11/11 23:40:11 gwr Exp $ */ /* @@ -41,8 +41,7 @@ * from: @(#)sem.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> /* NODEV */ - +#include <sys/types.h> #include <ctype.h> #include <err.h> #include <stdio.h> @@ -320,7 +319,7 @@ badname: dev->d_name = name; dev->d_next = NULL; dev->d_isdef = 0; - dev->d_major = NODEV; + dev->d_major = nodev; dev->d_attrs = NULL; dev->d_ihead = NULL; dev->d_ipp = &dev->d_ihead; @@ -489,7 +488,7 @@ void setmajor(struct devbase *d, int n) { - if (d != &errdev && d->d_major != NODEV) + if (d != &errdev && d->d_major != nodev) error("device `%s' is already major %d", d->d_name, d->d_major); else @@ -527,19 +526,19 @@ resolve(struct nvlist **nvp, const char *name, const char *what, if ((part >= maxpartitions) || (part < 0)) panic("resolve"); if ((nv = *nvp) == NULL) { - dev_t d = NODEV; + dev_t d = nodev; /* * Apply default. Easiest to do this by number. * Make sure to retain NODEVness, if this is dflt's disposition. */ - if (dflt->nv_int != NODEV) { + if (dflt->nv_int != nodev) { maj = major(dflt->nv_int); min = (minor(dflt->nv_int) / maxpartitions) + part; d = makedev(maj, min); } *nvp = nv = newnv(NULL, NULL, NULL, d, NULL); } - if (nv->nv_int != NODEV) { + if (nv->nv_int != nodev) { /* * By the numbers. Find the appropriate major number * to make a name. @@ -584,7 +583,7 @@ resolve(struct nvlist **nvp, const char *name, const char *what, return (1); } dev = ht_lookup(devbasetab, intern(buf)); - if (dev == NULL || dev->d_major == NODEV) { + if (dev == NULL || dev->d_major == nodev) { error("%s: can't make %s device from `%s'", name, what, nv->nv_str); return (1); |