summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2010-07-03 22:02:29 +0000
committermarcel <marcel@FreeBSD.org>2010-07-03 22:02:29 +0000
commitdf88de43605c31d57017c38efd18fb24d0ae9a2c (patch)
treed6e1a728f7828796c73aa6a1d7608b91b1081095 /sbin
parent94d3d209e1d15ce1ba3735812117345077e4a8bd (diff)
downloadFreeBSD-src-df88de43605c31d57017c38efd18fb24d0ae9a2c.zip
FreeBSD-src-df88de43605c31d57017c38efd18fb24d0ae9a2c.tar.gz
sysctlbyname() returns -1 on error and sets errno. It does
not return the error itself.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/mca/mca.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/sbin/mca/mca.c b/sbin/mca/mca.c
index 9934454..f774ac6 100644
--- a/sbin/mca/mca.c
+++ b/sbin/mca/mca.c
@@ -469,29 +469,28 @@ main(int argc, char **argv)
if (file == NULL || fl_dump) {
len = sizeof(count);
- error = sysctlbyname(hw_mca_count, &count, &len, NULL, 0);
- if (error)
+ if (sysctlbyname(hw_mca_count, &count, &len, NULL, 0) == -1)
err(1, hw_mca_count);
if (count == 0)
errx(0, "no error records found");
len = sizeof(first);
- error = sysctlbyname(hw_mca_first, &first, &len, NULL, 0);
- if (error)
+ if (sysctlbyname(hw_mca_first, &first, &len, NULL, 0) == -1)
err(1, hw_mca_first);
len = sizeof(last);
- error = sysctlbyname(hw_mca_last, &last, &len, NULL, 0);
- if (error)
+ if (sysctlbyname(hw_mca_last, &last, &len, NULL, 0) == -1)
err(1, hw_mca_last);
cpuid = 0;
+ error = 0;
while (count && first <= last) {
do {
sprintf(mib, hw_mca_recid, first, cpuid);
len = 0;
- error = sysctlbyname(mib, NULL, &len, NULL, 0);
+ ch = sysctlbyname(mib, NULL, &len, NULL, 0);
+ error = (ch == -1) ? errno : 0;
if (error != ENOENT)
break;
cpuid++;
@@ -502,14 +501,13 @@ main(int argc, char **argv)
continue;
}
if (error)
- err(1, "%s(1)", mib);
+ errc(1, error, "%s(1)", mib);
buf = malloc(len);
if (buf == NULL)
err(1, "buffer");
- error = sysctlbyname(mib, buf, &len, NULL, 0);
- if (error)
+ if (sysctlbyname(mib, buf, &len, NULL, 0) == -1)
err(1, "%s(2)", mib);
if (fl_dump)
OpenPOWER on IntegriCloud