Added "type" to the value_list_t struct.
[collectd.git] / src / cpufreq.c
index 7a5c8fd..5cb1b4e 100644 (file)
 
 #define MODULE_NAME "cpufreq"
 
-#if defined(KERNEL_LINUX)
-# define CPUFREQ_HAVE_READ 1
-#else
-# define CPUFREQ_HAVE_READ 0
-#endif
-
-#if CPUFREQ_HAVE_READ
-#ifdef KERNEL_LINUX
 static int num_cpu = 0;
-#endif
 
 static int cpufreq_init (void)
 {
-#ifdef KERNEL_LINUX
         int status;
        char filename[256];
 
@@ -50,7 +40,7 @@ static int cpufreq_init (void)
                status = snprintf (filename, sizeof (filename),
                                "/sys/devices/system/cpu/cpu%d/cpufreq/"
                                "scaling_cur_freq", num_cpu);
-               if (status < 1 || status >= sizeof (filename))
+               if ((status < 1) || ((unsigned int)status >= sizeof (filename)))
                        break;
 
                if (access (filename, R_OK))
@@ -64,7 +54,6 @@ static int cpufreq_init (void)
 
        if (num_cpu == 0)
                plugin_unregister_read ("cpufreq");
-#endif /* defined(KERNEL_LINUX) */
 
        return (0);
 } /* int cpufreq_init */
@@ -81,15 +70,15 @@ static void cpufreq_submit (int cpu_num, double value)
        vl.time = time (NULL);
        strcpy (vl.host, hostname_g);
        strcpy (vl.plugin, "cpufreq");
+       strcpy (vl.type, "cpufreq");
        snprintf (vl.type_instance, sizeof (vl.type_instance),
                        "%i", cpu_num);
 
-       plugin_dispatch_values ("cpufreq", &vl);
+       plugin_dispatch_values (&vl);
 }
 
 static int cpufreq_read (void)
 {
-#ifdef KERNEL_LINUX
         int status;
        unsigned long long val;
        int i = 0;
@@ -102,7 +91,7 @@ static int cpufreq_read (void)
                status = snprintf (filename, sizeof (filename),
                                "/sys/devices/system/cpu/cpu%d/cpufreq/"
                                "scaling_cur_freq", i);
-               if (status < 1 || status >= sizeof (filename))
+               if ((status < 1) || ((unsigned int)status >= sizeof (filename)))
                        return (-1);
 
                if ((fp = fopen (filename, "r")) == NULL)
@@ -138,17 +127,12 @@ static int cpufreq_read (void)
 
                cpufreq_submit (i, val);
        }
-#endif /* defined(KERNEL_LINUX) */
 
        return (0);
 } /* int cpufreq_read */
-#endif /* CPUFREQ_HAVE_READ */
-#undef BUFSIZE
 
 void module_register (void)
 {
-#if CPUFREQ_HAVE_READ
        plugin_register_init ("cpufreq", cpufreq_init);
        plugin_register_read ("cpufreq", cpufreq_read);
-#endif /* CPUFREQ_HAVE_READ */
 }