Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Jan 2017 01:07:16 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r311720 - stable/10/usr.sbin/bsnmpd/modules/snmp_hostres
Message-ID:  <201701090107.v0917GwG085265@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Mon Jan  9 01:07:16 2017
New Revision: 311720
URL: https://svnweb.freebsd.org/changeset/base/311720

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

Modified:
  stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c
==============================================================================
--- stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c	Mon Jan  9 01:05:44 2017	(r311719)
+++ stable/10/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c	Mon Jan  9 01:07:16 2017	(r311720)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701090107.v0917GwG085265>