projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-4.3' into collectd-4.4
[collectd.git]
/
src
/
cpufreq.c
diff --git
a/src/cpufreq.c
b/src/cpufreq.c
index
7a5c8fd
..
74e542b
100644
(file)
--- a/
src/cpufreq.c
+++ b/
src/cpufreq.c
@@
-26,20
+26,10
@@
#define MODULE_NAME "cpufreq"
#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;
static int num_cpu = 0;
-#endif
static int cpufreq_init (void)
{
static int cpufreq_init (void)
{
-#ifdef KERNEL_LINUX
int status;
char filename[256];
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);
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))
break;
if (access (filename, R_OK))
@@
-64,7
+54,6
@@
static int cpufreq_init (void)
if (num_cpu == 0)
plugin_unregister_read ("cpufreq");
if (num_cpu == 0)
plugin_unregister_read ("cpufreq");
-#endif /* defined(KERNEL_LINUX) */
return (0);
} /* int cpufreq_init */
return (0);
} /* int cpufreq_init */
@@
-79,8
+68,8
@@
static void cpufreq_submit (int cpu_num, double value)
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- s
trcpy (vl.host, hostname_g
);
- s
trcpy (vl.plugin, "cpufreq"
);
+ s
strncpy (vl.host, hostname_g, sizeof (vl.host)
);
+ s
strncpy (vl.plugin, "cpufreq", sizeof (vl.plugin)
);
snprintf (vl.type_instance, sizeof (vl.type_instance),
"%i", cpu_num);
snprintf (vl.type_instance, sizeof (vl.type_instance),
"%i", cpu_num);
@@
-89,7
+78,6
@@
static void cpufreq_submit (int cpu_num, double value)
static int cpufreq_read (void)
{
static int cpufreq_read (void)
{
-#ifdef KERNEL_LINUX
int status;
unsigned long long val;
int i = 0;
int status;
unsigned long long val;
int i = 0;
@@
-102,7
+90,7
@@
static int cpufreq_read (void)
status = snprintf (filename, sizeof (filename),
"/sys/devices/system/cpu/cpu%d/cpufreq/"
"scaling_cur_freq", i);
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)
return (-1);
if ((fp = fopen (filename, "r")) == NULL)
@@
-138,17
+126,12
@@
static int cpufreq_read (void)
cpufreq_submit (i, val);
}
cpufreq_submit (i, val);
}
-#endif /* defined(KERNEL_LINUX) */
return (0);
} /* int cpufreq_read */
return (0);
} /* int cpufreq_read */
-#endif /* CPUFREQ_HAVE_READ */
-#undef BUFSIZE
void module_register (void)
{
void module_register (void)
{
-#if CPUFREQ_HAVE_READ
plugin_register_init ("cpufreq", cpufreq_init);
plugin_register_read ("cpufreq", cpufreq_read);
plugin_register_init ("cpufreq", cpufreq_init);
plugin_register_read ("cpufreq", cpufreq_read);
-#endif /* CPUFREQ_HAVE_READ */
}
}