diff options
author | Vladimir Kobal <vlad@prokk.net> | 2019-02-21 11:22:58 +0200 |
---|---|---|
committer | Costa Tsaousis <costa@tsaousis.gr> | 2019-02-21 11:22:58 +0200 |
commit | 72b9b47403c67f1ef396b8ebced04daa8c5e8f40 (patch) | |
tree | 4a473057eeeb875df9697a8cb7992b619c6c0768 | |
parent | 76c4236233d1cd1bdbe8ec2d3eaf066eb779e971 (diff) |
Fix Coverity defects (#5394)
* Fix Checked Return issue
* Fix Unintended Integer Division issue
-rw-r--r-- | collectors/cgroups.plugin/sys_fs_cgroup.c | 2 | ||||
-rw-r--r-- | collectors/proc.plugin/sys_fs_btrfs.c | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/collectors/cgroups.plugin/sys_fs_cgroup.c b/collectors/cgroups.plugin/sys_fs_cgroup.c index f42bc71446..a57dc3a1ec 100644 --- a/collectors/cgroups.plugin/sys_fs_cgroup.c +++ b/collectors/cgroups.plugin/sys_fs_cgroup.c @@ -2476,7 +2476,7 @@ void update_cgroup_charts(int update_every) { else rrdset_next(cg->st_cpu_limit); - calculated_number cpu_usage = (cg->cpuacct_stat.user + cg->cpuacct_stat.system) * 100 / system_hz; + calculated_number cpu_usage = (calculated_number)(cg->cpuacct_stat.user + cg->cpuacct_stat.system) * 100 / system_hz; calculated_number cpu_used = 100 * (cpu_usage - cg->prev_cpu_usage) / (value * update_every); rrdset_isnot_obsolete(cg->st_cpu_limit); diff --git a/collectors/proc.plugin/sys_fs_btrfs.c b/collectors/proc.plugin/sys_fs_btrfs.c index 5aab24c1a8..cb25ad440d 100644 --- a/collectors/proc.plugin/sys_fs_btrfs.c +++ b/collectors/proc.plugin/sys_fs_btrfs.c @@ -308,7 +308,11 @@ static inline int find_all_btrfs_pools(const char *path) { char label[FILENAME_MAX + 1] = ""; snprintfz(filename, FILENAME_MAX, "%s/%s/label", path, de->d_name); - read_file(filename, label, FILENAME_MAX); + if(read_file(filename, label, FILENAME_MAX) != 0) { + error("BTRFS: failed to read '%s'", filename); + btrfs_free_node(node); + continue; + } char *s = label; if (s[0]) |