X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fthermal.c;h=fe54aee443790617b30c22915414bcd4c5123b5c;hb=3f09a6bfc9327f3d3c331b48f1c0cebcd4cd6628;hp=79033b171bd393a4f456c4459533887372b69bf3;hpb=d54dfab9b049de396e6a38d690d5f18917e093ea;p=collectd.git diff --git a/src/thermal.c b/src/thermal.c index 79033b17..fe54aee4 100644 --- a/src/thermal.c +++ b/src/thermal.c @@ -60,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]; @@ -71,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)); @@ -90,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)); @@ -112,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]; @@ -128,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;