X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcpufreq.c;h=42248a98deebf9a8b4a5f6e5d5e7f76c72e0b2e9;hb=54ada5ddddb3692d8ec3493fbf4a5fd7aa39b5d1;hp=e4caf5ffb4015da1bc1a0c98b26d4eca16b2e88c;hpb=06adec208286b5a136ffa5c5f3832c35e9f62844;p=collectd.git diff --git a/src/cpufreq.c b/src/cpufreq.c index e4caf5ff..42248a98 100644 --- a/src/cpufreq.c +++ b/src/cpufreq.c @@ -26,30 +26,10 @@ #define MODULE_NAME "cpufreq" -#if defined(KERNEL_LINUX) -# define CPUFREQ_HAVE_READ 1 -#else -# define CPUFREQ_HAVE_READ 0 -#endif - -static data_source_t data_source[1] = -{ - {"value", DS_TYPE_GAUGE, 0, NAN} -}; - -static data_set_t data_set = -{ - "cpufreq", 1, data_source -}; - -#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]; @@ -60,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)) @@ -74,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 */ @@ -99,7 +78,6 @@ static void cpufreq_submit (int cpu_num, double value) static int cpufreq_read (void) { -#ifdef KERNEL_LINUX int status; unsigned long long val; int i = 0; @@ -112,7 +90,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) @@ -148,23 +126,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 (modreg_e load) +void module_register (void) { - if (load & MR_DATASETS) - plugin_register_data_set (&data_set); - -#if CPUFREQ_HAVE_READ - if (load & MR_READ) - { - plugin_register_init ("cpufreq", cpufreq_init); - plugin_register_read ("cpufreq", cpufreq_read); - } -#endif /* CPUFREQ_HAVE_READ */ + plugin_register_init ("cpufreq", cpufreq_init); + plugin_register_read ("cpufreq", cpufreq_read); }