summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config/mkoptions.c
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2010-03-30 13:46:40 +0000
committerru <ru@FreeBSD.org>2010-03-30 13:46:40 +0000
commit5562af42b475b5dd9510c3aae83fb5c13b2461aa (patch)
treea397f140c6755a88a4687730d41abc1141ca66c4 /usr.sbin/config/mkoptions.c
parent09e7af977a9c3aa17fc324806c8ba6d8a7ab3c72 (diff)
downloadFreeBSD-src-5562af42b475b5dd9510c3aae83fb5c13b2461aa.zip
FreeBSD-src-5562af42b475b5dd9510c3aae83fb5c13b2461aa.tar.gz
- Handle calloc() allocation failures.
- Fixed a comment. - 2 -> EXIT_FAILURE in some places. - errx() -> err() where appropriate. PR: 144644 Submitted by: Garrett Cooper
Diffstat (limited to 'usr.sbin/config/mkoptions.c')
-rw-r--r--usr.sbin/config/mkoptions.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/usr.sbin/config/mkoptions.c b/usr.sbin/config/mkoptions.c
index c4bd624..5cd9d61 100644
--- a/usr.sbin/config/mkoptions.c
+++ b/usr.sbin/config/mkoptions.c
@@ -70,6 +70,8 @@ options(void)
/* Fake the cpu types as options. */
SLIST_FOREACH(cp, &cputype, cpu_next) {
op = (struct opt *)calloc(1, sizeof(*op));
+ if (op == NULL)
+ err(EXIT_FAILURE, "calloc");
op->op_name = ns(cp->cpu_name);
SLIST_INSERT_HEAD(&opt, op, op_next);
}
@@ -84,6 +86,8 @@ options(void)
/* Fake MAXUSERS as an option. */
op = (struct opt *)calloc(1, sizeof(*op));
+ if (op == NULL)
+ err(EXIT_FAILURE, "calloc");
op->op_name = ns("MAXUSERS");
snprintf(buf, sizeof(buf), "%d", maxusers);
op->op_value = ns(buf);
@@ -199,6 +203,8 @@ do_option(char *name)
tidy++;
} else {
op = (struct opt *) calloc(1, sizeof *op);
+ if (op == NULL)
+ err(EXIT_FAILURE, "calloc");
op->op_name = inw;
op->op_value = invalue;
SLIST_INSERT_HEAD(&op_head, op, op_next);
@@ -225,6 +231,8 @@ do_option(char *name)
if (value && !seen) {
/* New option appears */
op = (struct opt *) calloc(1, sizeof *op);
+ if (op == NULL)
+ err(EXIT_FAILURE, "calloc");
op->op_name = ns(name);
op->op_value = value ? ns(value) : NULL;
SLIST_INSERT_HEAD(&op_head, op, op_next);
@@ -336,6 +344,8 @@ next:
}
po = (struct opt_list *) calloc(1, sizeof *po);
+ if (po == NULL)
+ err(EXIT_FAILURE, "calloc");
po->o_name = this;
po->o_file = val;
SLIST_INSERT_HEAD(&otab, po, o_next);
OpenPOWER on IntegriCloud