Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/sysctl use __func__, EXIT_{SUCCESS,FAILURE}
details: https://anonhg.NetBSD.org/src/rev/28a7aaa16f5c
branches: trunk
changeset: 325892:28a7aaa16f5c
user: christos <christos%NetBSD.org@localhost>
date: Fri Jan 10 18:37:18 2014 +0000
description:
use __func__, EXIT_{SUCCESS,FAILURE}
diffstat:
sbin/sysctl/sysctl.c | 132 +++++++++++++++++++++++++-------------------------
1 files changed, 66 insertions(+), 66 deletions(-)
diffs (truncated from 561 to 300 lines):
diff -r bec7c4e49f15 -r 28a7aaa16f5c sbin/sysctl/sysctl.c
--- a/sbin/sysctl/sysctl.c Fri Jan 10 18:03:26 2014 +0000
+++ b/sbin/sysctl/sysctl.c Fri Jan 10 18:37:18 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysctl.c,v 1.150 2014/01/10 09:38:56 pooka Exp $ */
+/* $NetBSD: sysctl.c,v 1.151 2014/01/10 18:37:18 christos Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
#if 0
static char sccsid[] = "@(#)sysctl.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: sysctl.c,v 1.150 2014/01/10 09:38:56 pooka Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.151 2014/01/10 18:37:18 christos Exp $");
#endif
#endif /* not lint */
@@ -337,14 +337,14 @@
aflag = 1;
if (prog_init && prog_init() == -1)
- err(1, "prog init failed");
+ err(EXIT_FAILURE, "prog init failed");
if (Aflag)
warnfp = stdout;
stale = req = 0;
if ((re = malloc(sizeof(*re) * __arraycount(handlers))) == NULL)
- err(1, "malloc regex");
+ err(EXIT_FAILURE, "malloc regex");
if (aflag) {
print_tree(&name[0], 0, NULL, CTLTYPE_NODE, 1,
@@ -359,7 +359,7 @@
fp = fopen(fn, "r");
if (fp == NULL) {
- err(1, "%s", fn);
+ err(EXIT_FAILURE, "%s", fn);
} else {
nr = 0;
while ((l = fparseln(fp, NULL, &nr, NULL, 0)) != NULL)
@@ -380,7 +380,7 @@
while (argc-- > 0)
parse(*argv++, re, &lastcompiled);
- return errs ? 1 : 0;
+ return errs ? EXIT_FAILURE : EXIT_SUCCESS;
}
/*
@@ -405,7 +405,7 @@
j = regcomp(&re[i], p[i].ps_re, REG_EXTENDED);
if (j != 0) {
regerror(j, &re[i], eb, sizeof(eb));
- errx(1, "regcomp: %s: %s", p[i].ps_re, eb);
+ errx(EXIT_FAILURE, "regcomp: %s: %s", p[i].ps_re, eb);
}
*lastcompiled = i + 1;
}
@@ -416,7 +416,7 @@
}
else if (j != REG_NOMATCH) {
regerror(j, &re[i], eb, sizeof(eb));
- errx(1, "regexec: %s: %s", p[i].ps_re, eb);
+ errx(EXIT_FAILURE, "regexec: %s: %s", p[i].ps_re, eb);
}
}
@@ -679,7 +679,7 @@
if (p->ps_p == NULL) {
sysctlperror("Cannot print `%s': %s\n", gsname,
strerror(EOPNOTSUPP));
- exit(1);
+ exit(EXIT_FAILURE);
}
(*p->ps_p)(gsname, gdname, NULL, name, namelen, pnode, type,
__UNCONST(p->ps_d));
@@ -890,7 +890,7 @@
if (optional)
return;
sysctlparseerror(namelen, l);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
type = SYSCTL_TYPE(node->sysctl_flags);
@@ -910,7 +910,7 @@
if (!wflag) {
sysctlperror("Must specify -w to set variables\n");
- exit(1);
+ exit(EXIT_FAILURE);
}
canonicalize(gsname, canonname);
@@ -919,7 +919,7 @@
if (w->ps_w == NULL) {
sysctlperror("Cannot write `%s': %s\n", gsname,
strerror(EOPNOTSUPP));
- exit(1);
+ exit(EXIT_FAILURE);
}
(*w->ps_w)(gsname, gdname, value, name, namelen, node, type,
__UNCONST(w->ps_d));
@@ -987,7 +987,7 @@
if (!wflag) {
sysctlperror("Must specify -w to create nodes\n");
- exit(1);
+ exit(EXIT_FAILURE);
}
/*
@@ -1068,11 +1068,11 @@
"%s: already have %s for new node\n",
nname,
method == CTL_CREATE ? "addr" : "symbol");
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
if (value == NULL) {
sysctlperror("%s: missing value\n", nname);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
errno = 0;
addr = (void*)strtoul(value, &t, 0);
@@ -1080,7 +1080,7 @@
sysctlperror(
"%s: '%s' is not a valid address\n",
nname, value);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
method = CTL_CREATE;
}
@@ -1090,7 +1090,7 @@
"%s: already have %s for new node\n",
nname,
method == CTL_CREATE ? "addr" : "symbol");
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
addr = value;
method = CTL_CREATESYM;
@@ -1098,7 +1098,7 @@
else if (strcmp(key, "type") == 0) {
if (value == NULL) {
sysctlperror("%s: missing value\n", nname);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
if (strcmp(value, "node") == 0)
type = CTLTYPE_NODE;
@@ -1122,13 +1122,13 @@
sysctlperror(
"%s: '%s' is not a valid type\n",
nname, value);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
}
else if (strcmp(key, "size") == 0) {
if (value == NULL) {
sysctlperror("%s: missing value\n", nname);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
errno = 0;
/*
@@ -1141,13 +1141,13 @@
sysctlperror(
"%s: '%s' is not a valid size\n",
nname, value);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
}
else if (strcmp(key, "n") == 0) {
if (value == NULL) {
sysctlperror("%s: missing value\n", nname);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
errno = 0;
q = strtoll(value, &t, 0);
@@ -1156,14 +1156,14 @@
sysctlperror(
"%s: '%s' is not a valid mib number\n",
nname, value);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
node.sysctl_num = (int)q;
}
else if (strcmp(key, "flags") == 0) {
if (value == NULL) {
sysctlperror("%s: missing value\n", nname);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
t = value;
while (*t != '\0') {
@@ -1200,7 +1200,7 @@
sysctlperror(
"%s: '%c' is not a valid flag\n",
nname, *t);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
t++;
}
@@ -1208,7 +1208,7 @@
else {
sysctlperror("%s: unrecognized keyword '%s'\n",
nname, key);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
}
@@ -1228,7 +1228,7 @@
sysctlperror(
"%s: cannot specify both value and "
"address\n", nname);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
switch (type) {
@@ -1240,7 +1240,7 @@
sysctlperror(
"%s: '%s' is not a valid integer\n",
nname, value);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
i = (int)q;
if (!(flags & CTLFLAG_OWNDATA)) {
@@ -1260,7 +1260,7 @@
sysctlperror(
"%s: '%s' is not a valid bool\n",
nname, value);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
b = q == 1;
if (!(flags & CTLFLAG_OWNDATA)) {
@@ -1291,7 +1291,7 @@
sysctlperror(
"%s: '%s' is not a valid quad\n",
nname, value);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
if (!(flags & CTLFLAG_OWNDATA)) {
flags |= CTLFLAG_IMMEDIATE;
@@ -1305,7 +1305,7 @@
case CTLTYPE_STRUCT:
sysctlperror("%s: struct not initializable\n",
nname);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
/*
@@ -1330,7 +1330,7 @@
sysctlperror(
"%s: need a size or a starting value\n",
nname);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
if (!(flags & CTLFLAG_IMMEDIATE))
flags |= CTLFLAG_OWNDATA;
@@ -1345,11 +1345,11 @@
sysctlperror("%s: cannot make an immediate %s\n",
nname,
(type == CTLTYPE_STRING) ? "string" : "struct");
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
if (type == CTLTYPE_NODE && node.sysctl_data != NULL) {
sysctlperror("%s: nodes do not have data\n", nname);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
/*
@@ -1361,12 +1361,12 @@
(type == CTLTYPE_QUAD && sz != sizeof(u_quad_t)) ||
(type == CTLTYPE_NODE && sz != 0)) {
sysctlperror("%s: wrong size for type\n", nname);
- EXIT(1);
+ EXIT(EXIT_FAILURE);
}
}
Home |
Main Index |
Thread Index |
Old Index