svn commit: r311393 - head/usr.sbin/bsnmpd/modules/snmp_hostres

Ngie Cooper ngie at FreeBSD.org
Thu Jan 5 09:28:39 UTC 2017


Author: ngie
Date: Thu Jan  5 09:28:38 2017
New Revision: 311393
URL: https://svnweb.freebsd.org/changeset/base/311393

Log:
  OS_getSystemUptime: use nitems for calculating the number of elements
  in a sysctl mib instead of hardcoding the number 2
  
  MFC after:	3 days

Modified:
  head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c

Modified: head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
==============================================================================
--- head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c	Thu Jan  5 09:23:54 2017	(r311392)
+++ head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c	Thu Jan  5 09:28:38 2017	(r311393)
@@ -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);


More information about the svn-src-all mailing list