summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMichal Mazurek <akfaew@cvs.openbsd.org>2016-09-07 18:29:53 +0000
committerMichal Mazurek <akfaew@cvs.openbsd.org>2016-09-07 18:29:53 +0000
commitccaa55a52338dee8069e54f254bca76a2ba2305f (patch)
tree8f2fda74a35a5d66e96e26e0f6bf123dad8e2519 /usr.sbin
parent037f39c9822da9ac93bb0b78ad5dbcd0ac22b046 (diff)
Get rid of the static nomem() function and replace it with err(1, NULL);
Written with and ok tb@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/config/util.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/usr.sbin/config/util.c b/usr.sbin/config/util.c
index a571697a0e0..84eacc207b7 100644
--- a/usr.sbin/config/util.c
+++ b/usr.sbin/config/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.15 2014/05/29 16:38:23 tedu Exp $ */
+/* $OpenBSD: util.c,v 1.16 2016/09/07 18:29:52 akfaew Exp $ */
/* $NetBSD: util.c,v 1.5 1996/08/31 20:58:29 mycroft Exp $ */
/*
@@ -44,6 +44,7 @@
#include <sys/types.h>
#include <ctype.h>
+#include <err.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -51,7 +52,6 @@
#include "config.h"
-static void nomem(void);
static void vxerror(const char *, int, const char *, va_list);
/*
@@ -63,8 +63,8 @@ emalloc(size_t size)
void *p;
if ((p = calloc(1, size)) == NULL)
- nomem();
- return (p);
+ err(1, NULL);
+ return p;
}
/*
@@ -75,8 +75,8 @@ ereallocarray(void *p, size_t sz1, size_t sz2)
{
if ((p = reallocarray(p, sz1, sz2)) == NULL)
- nomem();
- return (p);
+ err(1, NULL);
+ return p;
}
/*
@@ -88,16 +88,8 @@ ecalloc(size_t sz1, size_t sz2)
void *p;
if ((p = calloc(sz1, sz2)) == NULL)
- nomem();
- return (p);
-}
-
-static void
-nomem(void)
-{
-
- (void)fprintf(stderr, "config: out of memory\n");
- exit(1);
+ err(1, NULL);
+ return p;
}
/*
@@ -111,7 +103,7 @@ sourcepath(const char *file)
cp = emalloc(len);
(void)snprintf(cp, len, "%s/%s", srcdir, file);
- return (cp);
+ return cp;
}
static struct nvlist *nvhead;
@@ -135,7 +127,7 @@ newnv(const char *name, const char *str, void *ptr, int i, struct nvlist *next)
nv->nv_ptr = ptr;
}
nv->nv_int = i;
- return (nv);
+ return nv;
}
/*