summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/procfs.c2
-rw-r--r--src/heart/heart-cpu.c4
-rw-r--r--src/heart/logging.c2
3 files changed, 7 insertions, 1 deletions
diff --git a/src/common/procfs.c b/src/common/procfs.c
index eaa6756b..a716840c 100644
--- a/src/common/procfs.c
+++ b/src/common/procfs.c
@@ -327,7 +327,7 @@ int proc_get_zram_usage(pid_t pid, unsigned int *usage)
* Calculate aproximated value of zram usage for selected process
* by formula: proc_zram_usage = ( VmSwap x ZramMemoryUsage )/SwapTotal
*/
- *usage = ((float)((proc_swap_usage*BYTE_TO_KBYTE(zram_usage))/swap_total));
+ *usage = (float)proc_swap_usage * BYTE_TO_KBYTE(zram_usage) / swap_total;
return RESOURCED_ERROR_NONE;
}
diff --git a/src/heart/heart-cpu.c b/src/heart/heart-cpu.c
index b9de90cf..b0c04fdd 100644
--- a/src/heart/heart-cpu.c
+++ b/src/heart/heart-cpu.c
@@ -647,6 +647,8 @@ void heart_cpu_update(struct logging_table_form *data, void *user_data)
return;
}
cache = (struct heart_cpu_dat_cache*)malloc(sizeof(struct heart_cpu_dat_cache));
+ assert(cache);
+
cache->path = strndup(path, strlen(path));
cache->list = g_hash_table_new_full(
g_str_hash,
@@ -1527,6 +1529,8 @@ static int heart_cpu_init(void *data)
userinfo_for_each(elem, user_list) {
cache = (struct heart_cpu_dat_cache*)malloc(sizeof(struct heart_cpu_dat_cache));
+ assert(cache);
+
cache->path = strndup(elem->home_dir, strlen(elem->home_dir));
cache->list = g_hash_table_new_full(
g_str_hash,
diff --git a/src/heart/logging.c b/src/heart/logging.c
index b9070f18..86c0232d 100644
--- a/src/heart/logging.c
+++ b/src/heart/logging.c
@@ -415,6 +415,8 @@ int logging_module_init(char *name, enum logging_period max_period,
return RESOURCED_ERROR_DB_FAILED;
}
db_elem = (struct logging_db*)malloc(sizeof(struct logging_db));
+ assert(db_elem);
+
db_elem->path = strndup(db_path, sizeof(db_path));
db_elem->file = db_file;
db_elem->insert_stmt = NULL;