Fix Coverity defects (#5394)
* Fix Checked Return issue * Fix Unintended Integer Division issue
Vladimir Kobal committed
Feb 21, 2019 at 11:22 UTC
72b9b47403c67f1ef396b8ebced04daa8c5e8f40
2 files changed
+6
-2
collectors/cgroups.plugin/sys_fs_cgroup.c
+1
-1
@@ -2476,7 +2476,7 @@ void update_cgroup_charts(int update_every) {
2476
else
2477
rrdset_next(cg->st_cpu_limit);
2478
2479
- calculated_number cpu_usage = (cg->cpuacct_stat.user + cg->cpuacct_stat.system) * 100 / system_hz;
2479
+ calculated_number cpu_usage = (calculated_number)(cg->cpuacct_stat.user + cg->cpuacct_stat.system) * 100 / system_hz;
2480
calculated_number cpu_used = 100 * (cpu_usage - cg->prev_cpu_usage) / (value * update_every);
2481
2482
rrdset_isnot_obsolete(cg->st_cpu_limit);
collectors/proc.plugin/sys_fs_btrfs.c
+5
-1
@@ -308,7 +308,11 @@ static inline int find_all_btrfs_pools(const char *path) {
308
char label[FILENAME_MAX + 1] = "";
309
310
snprintfz(filename, FILENAME_MAX, "%s/%s/label", path, de->d_name);
311
- read_file(filename, label, FILENAME_MAX);
311
+ if(read_file(filename, label, FILENAME_MAX) != 0) {
312
+ error("BTRFS: failed to read '%s'", filename);
313
+ btrfs_free_node(node);
314
+ continue;
315
+ }
316
317
char *s = label;
318
if (s[0])