X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fthermal.c;h=2b708052d707461afa3f9976f3bd9132affa79a6;hb=0d5c879672770e3b8a740727fb223a6febdeaa27;hp=b6136480c1e5036606f2e9730538e8c068d69e83;hpb=597adb008e5cb9b39bc925046d2aedc084ec2b9e;p=collectd.git diff --git a/src/thermal.c b/src/thermal.c index b6136480..2b708052 100644 --- a/src/thermal.c +++ b/src/thermal.c @@ -51,7 +51,6 @@ static void thermal_submit (const char *plugin_instance, enum dev_type dt, vt.gauge = value; vl.values = &vt; - vl.time = time (NULL); sstrncpy (vl.plugin, "thermal", sizeof(vl.plugin)); sstrncpy (vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance)); @@ -61,8 +60,8 @@ static void thermal_submit (const char *plugin_instance, enum dev_type dt, plugin_dispatch_values (&vl); } -static int thermal_sysfs_device_read (const char *dir, const char *name, - void *user_data) +static int thermal_sysfs_device_read (const char __attribute__((unused)) *dir, + const char *name, void __attribute__((unused)) *user_data) { char filename[256]; char data[1024]; @@ -72,8 +71,9 @@ static int thermal_sysfs_device_read (const char *dir, const char *name, if (device_list && ignorelist_match (device_list, name)) return -1; - len = snprintf (filename, sizeof (filename), "%s/%s/temp", dirname_sysfs, name); - if ((len < 0) || ((unsigned int)len >= sizeof (filename))) + len = snprintf (filename, sizeof (filename), + "%s/%s/temp", dirname_sysfs, name); + if ((len < 0) || ((size_t) len >= sizeof (filename))) return -1; len = read_file_contents (filename, data, sizeof(data)); @@ -91,8 +91,9 @@ static int thermal_sysfs_device_read (const char *dir, const char *name, } } - len = snprintf (filename, sizeof (filename), "%s/%s/cur_state", dirname_sysfs, name); - if ((len < 0) || ((unsigned int)len >= sizeof (filename))) + len = snprintf (filename, sizeof (filename), + "%s/%s/cur_state", dirname_sysfs, name); + if ((len < 0) || ((size_t) len >= sizeof (filename))) return -1; len = read_file_contents (filename, data, sizeof(data)); @@ -113,8 +114,8 @@ static int thermal_sysfs_device_read (const char *dir, const char *name, return ok ? 0 : -1; } -static int thermal_procfs_device_read (const char *dir, const char *name, - void *user_data) +static int thermal_procfs_device_read (const char __attribute__((unused)) *dir, + const char *name, void __attribute__((unused)) *user_data) { const char str_temp[] = "temperature:"; char filename[256]; @@ -129,12 +130,15 @@ static int thermal_procfs_device_read (const char *dir, const char *name, * temperature: 55 C */ - len = snprintf (filename, sizeof (filename), "%s/%s/temperature", dirname_procfs, name); - if ((len < 0) || ((unsigned int)len >= sizeof (filename))) + len = snprintf (filename, sizeof (filename), + "%s/%s/temperature", dirname_procfs, name); + if ((len < 0) || ((size_t) len >= sizeof (filename))) return -1; len = read_file_contents (filename, data, sizeof(data)); - if (len > sizeof(str_temp) && data[--len] == '\n' && !strncmp(data, str_temp, sizeof(str_temp)-1)) { + if ((len > 0) && ((size_t) len > sizeof(str_temp)) + && (data[--len] == '\n') + && (! strncmp(data, str_temp, sizeof(str_temp)-1))) { char *endptr = NULL; double temp; double celsius, add; @@ -194,17 +198,13 @@ static int thermal_config (const char *key, const char *value) else if (strcasecmp (key, "IgnoreSelected") == 0) { ignorelist_set_invert (device_list, 1); - if ((strcasecmp (value, "True") == 0) - || (strcasecmp (value, "Yes") == 0) - || (strcasecmp (value, "On") == 0)) + if (IS_TRUE (value)) ignorelist_set_invert (device_list, 0); } else if (strcasecmp (key, "ForceUseProcfs") == 0) { force_procfs = 0; - if ((strcasecmp (value, "True") == 0) - || (strcasecmp (value, "Yes") == 0) - || (strcasecmp (value, "On") == 0)) + if (IS_TRUE (value)) force_procfs = 1; } else