X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fuptime.c;h=cbe2f8c5dcaf2ebcaf4ff4fc059bbffa684d805e;hb=d59524524af36bf9e3eb6108d21744076c79701d;hp=064c3ceed4752a359c7ec2e5b9d84afa27068543;hpb=ef4a3db895a0aba7107c0f1c6c2ef2a7f128aaf8;p=collectd.git diff --git a/src/uptime.c b/src/uptime.c index 064c3cee..cbe2f8c5 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -20,6 +20,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" @@ -179,17 +180,13 @@ static int uptime_init (void) /* {{{ */ /* #endif HAVE_LIBKSTAT */ # elif HAVE_SYS_SYSCTL_H - struct timeval boottv; + struct timeval boottv = { 0 }; size_t boottv_len; int status; - int mib[2]; - - mib[0] = CTL_KERN; - mib[1] = KERN_BOOTTIME; + int mib[] = { CTL_KERN, KERN_BOOTTIME }; boottv_len = sizeof (boottv); - memset (&boottv, 0, boottv_len); status = sysctl (mib, STATIC_ARRAY_SIZE (mib), &boottv, &boottv_len, /* new_value = */ NULL, /* new_length = */ 0); @@ -241,7 +238,7 @@ static int uptime_read (void) gauge_t uptime; time_t elapsed; - /* calculate the ammount of time elapsed since boot, AKA uptime */ + /* calculate the amount of time elapsed since boot, AKA uptime */ elapsed = time (NULL) - boottime; uptime = (gauge_t) elapsed;