summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-01-09 01:07:16 +0000
committerngie <ngie@FreeBSD.org>2017-01-09 01:07:16 +0000
commit50fbe764d5e4b2f76f5248fd311e24b90867c360 (patch)
tree6be68102a2802553b243a325bc38ba2643fd869f /usr.sbin
parent3406221da4df81dc98011b7229f1b25f0691a5b5 (diff)
downloadFreeBSD-src-50fbe764d5e4b2f76f5248fd311e24b90867c360.zip
FreeBSD-src-50fbe764d5e4b2f76f5248fd311e24b90867c360.tar.gz
MFC r311393:
OS_getSystemUptime: use nitems for calculating the number of elements in a sysctl mib instead of hardcoding the number 2
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
index f5c2e11..6634ae2 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
@@ -33,7 +33,7 @@
* Host Resources MIB scalars implementation for SNMPd.
*/
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/sysctl.h>
#include <pwd.h>
@@ -85,7 +85,7 @@ OS_getSystemUptime(uint32_t *ut)
int mib[2] = { CTL_KERN, KERN_BOOTTIME };
size_t len = sizeof(kernel_boot_timestamp);
- if (sysctl(mib, 2, &kernel_boot_timestamp,
+ if (sysctl(mib, nitems(mib), &kernel_boot_timestamp,
&len, NULL, 0) == -1) {
syslog(LOG_ERR, "sysctl KERN_BOOTTIME failed: %m");
return (SNMP_ERR_GENERR);
OpenPOWER on IntegriCloud