summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-01-09 01:05:44 +0000
committerngie <ngie@FreeBSD.org>2017-01-09 01:05:44 +0000
commitb14eb6181cea4aa362e1789a38f1065dde5872f8 (patch)
tree1725ff261736017bcb02f6ecbf20e1476913715e
parent038e1211ccdefb7bf6553d0fc1b26d9576344d7d (diff)
downloadFreeBSD-src-b14eb6181cea4aa362e1789a38f1065dde5872f8.zip
FreeBSD-src-b14eb6181cea4aa362e1789a38f1065dde5872f8.tar.gz
MFC r311393:
OS_getSystemUptime: use nitems for calculating the number of elements in a sysctl mib instead of hardcoding the number 2
-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