summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2007-06-11 13:02:15 +0000
committerbde <bde@FreeBSD.org>2007-06-11 13:02:15 +0000
commit0911a23bee4243ce1453f87ec9ba6ee1747b5f32 (patch)
tree92f8189c1f2e2652b26c564555073d383dd3d368 /sbin
parentab1cc6077331154af8bd445b9bedfc7bac75bd8b (diff)
downloadFreeBSD-src-0911a23bee4243ce1453f87ec9ba6ee1747b5f32.zip
FreeBSD-src-0911a23bee4243ce1453f87ec9ba6ee1747b5f32.tar.gz
When we return from a "show" function without printing anything except
a warning, return 1 instead of 0 to indicate that we didn't print anything, so that top-level callers don't print a spurious newline. This is mainly to fix output formatting when stderr is redirected. It also helps in some cases when stderr is interleaved with stdout, depending on the details of the interleaving (this program has the usual null explicit support for syncing stderr with stdout). Return 1 instead of -1 after printing the "malloc failed" warning, since the return value is boolean.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/sysctl/sysctl.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index f84b47b..9dcfcb0 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -327,7 +327,7 @@ S_clockinfo(int l2, void *p)
if (l2 != sizeof(*ci)) {
warnx("S_clockinfo %d != %d", l2, sizeof(*ci));
- return (0);
+ return (1);
}
printf(hflag ? "{ hz = %'d, tick = %'d, profhz = %'d, stathz = %'d }" :
"{ hz = %d, tick = %d, profhz = %d, stathz = %d }",
@@ -342,7 +342,7 @@ S_loadavg(int l2, void *p)
if (l2 != sizeof(*tv)) {
warnx("S_loadavg %d != %d", l2, sizeof(*tv));
- return (0);
+ return (1);
}
printf(hflag ? "{ %'.2f %'.2f %'.2f }" : "{ %.2f %.2f %.2f }",
(double)tv->ldavg[0]/(double)tv->fscale,
@@ -360,7 +360,7 @@ S_timeval(int l2, void *p)
if (l2 != sizeof(*tv)) {
warnx("S_timeval %d != %d", l2, sizeof(*tv));
- return (0);
+ return (1);
}
printf(hflag ? "{ sec = %'ld, usec = %'ld } " :
"{ sec = %ld, usec = %ld } ",
@@ -382,7 +382,7 @@ S_vmtotal(int l2, void *p)
if (l2 != sizeof(*v)) {
warnx("S_vmtotal %d != %d", l2, sizeof(*v));
- return (0);
+ return (1);
}
printf(
@@ -414,7 +414,7 @@ T_dev_t(int l2, void *p)
if (l2 != sizeof(*d)) {
warnx("T_dev_T %d != %d", l2, sizeof(*d));
- return (0);
+ return (1);
}
if ((int)(*d) != -1) {
if (minor(*d) > 255 || minor(*d) < 0)
@@ -588,7 +588,7 @@ show_var(int *oid, int nlen)
val = oval = malloc(j + 1);
if (val == NULL) {
warnx("malloc failed");
- return (-1);
+ return (1);
}
len = j;
i = sysctl(oid, nlen, val, &len, 0, 0);
OpenPOWER on IntegriCloud