treewide: declare loop variable in loop expression
[collectd.git] / src / cgroups.c
index 17b12d0..3a59ec4 100644 (file)
@@ -22,6 +22,7 @@
  **/
 
 #include "collectd.h"
+
 #include "common.h"
 #include "plugin.h"
 #include "configfile.h"
@@ -144,7 +145,7 @@ static int read_cpuacct_procs (const char *dirname, char const *cgroup_name,
 
 /*
  * Gets called for every file/folder in /sys/fs/cgroup/cpu,cpuacct (or
- * whereever cpuacct is mounted on the system). Calls walk_directory with the
+ * wherever cpuacct is mounted on the system). Calls walk_directory with the
  * read_cpuacct_procs callback on every folder it finds, such as "system".
  */
 static int read_cpuacct_root (const char *dirname, const char *filename,
@@ -206,18 +207,16 @@ static int cgroups_config (const char *key, const char *value)
 
 static int cgroups_read (void)
 {
-       cu_mount_t *mnt_list;
-       cu_mount_t *mnt_ptr;
+       cu_mount_t *mnt_list = NULL;
        _Bool cgroup_found = 0;
 
-       mnt_list = NULL;
        if (cu_mount_getlist (&mnt_list) == NULL)
        {
                ERROR ("cgroups plugin: cu_mount_getlist failed.");
                return (-1);
        }
 
-       for (mnt_ptr = mnt_list; mnt_ptr != NULL; mnt_ptr = mnt_ptr->next)
+       for (cu_mount_t *mnt_ptr = mnt_list; mnt_ptr != NULL; mnt_ptr = mnt_ptr->next)
        {
                /* Find the cgroup mountpoint which contains the cpuacct
                 * controller. */