summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/smaps.c6
-rw-r--r--src/heart/heart-cpu.c7
-rw-r--r--src/heart/logging.c14
-rw-r--r--src/proc-stat/proc-main.c2
4 files changed, 13 insertions, 16 deletions
diff --git a/src/common/smaps.c b/src/common/smaps.c
index bf79bcf0..6a04c023 100644
--- a/src/common/smaps.c
+++ b/src/common/smaps.c
@@ -125,6 +125,7 @@ int smaps_get(pid_t pid, struct smaps **maps, enum smap_mask mask)
char buf[LINE_MAX];
bool get_line = true, totmaps;
int r;
+ struct smap *map;
assert(maps);
@@ -152,7 +153,7 @@ int smaps_get(pid_t pid, struct smaps **maps, enum smap_mask mask)
return -ENOMEM;
for (;;) {
- struct smap *map = NULL;
+ map = NULL;
int n;
size_t l;
enum smap_id id;
@@ -209,7 +210,6 @@ totmaps_error:
if (n == 3 && !map->name)
map->name = strndup("[anon]", strlen("[anon]"));
else if (n != 4) {
- free(map);
r = -EINVAL;
goto on_error;
}
@@ -239,7 +239,6 @@ totmaps_error:
k = strndup(buf, l);
if (!k) {
r = -ENOMEM;
- smap_free(map);
goto on_error;
}
@@ -266,6 +265,7 @@ totmaps_error:
return 0;
on_error:
+ smap_free(map);
smaps_free(m);
return r;
}
diff --git a/src/heart/heart-cpu.c b/src/heart/heart-cpu.c
index d35f93cf..f04a24e8 100644
--- a/src/heart/heart-cpu.c
+++ b/src/heart/heart-cpu.c
@@ -639,7 +639,7 @@ void heart_cpu_update(struct logging_table_form *data, void *user_data)
GHashTable *cpu_usage_list = NULL;
cache = (struct heart_cpu_dat_cache*)g_hash_table_lookup(
- heart_cpu_app_list, (gconstpointer)(&(data->uid)));
+ heart_cpu_app_list, (gpointer)(&(data->uid)));
if (!cache) {
path = userinfo_find_home_dir((uid_t)data->uid);
if (!path) {
@@ -1562,10 +1562,7 @@ static int heart_cpu_init(void *data)
heart_free_value);
ret = heart_cpu_read_from_file(cache);
- if (ret != RESOURCED_ERROR_NONE) {
- _E("heart_cpu_init failed");
- return ret;
- }
+ assert(ret == RESOURCED_ERROR_NONE);
cache->last_file_commit_time = logging_get_time(CLOCK_BOOTTIME);
diff --git a/src/heart/logging.c b/src/heart/logging.c
index 78788097..13de89f0 100644
--- a/src/heart/logging.c
+++ b/src/heart/logging.c
@@ -409,6 +409,7 @@ int logging_module_init(char *name, enum logging_period max_period,
if (logging_create_default_db(db_path, &db_file)
!= RESOURCED_ERROR_NONE) {
_E("Fail to create %s", db_path);
+ g_hash_table_unref(module->db_list);
return RESOURCED_ERROR_DB_FAILED;
}
db_elem = (struct logging_db*)malloc(sizeof(struct logging_db));
@@ -678,10 +679,9 @@ int logging_leveldb_put(char *key, unsigned int key_len, char *value, unsigned i
leveldb_put(logging_leveldb, woptions, key, key_len, value, value_len, &err);
if (err != NULL) {
_E("Failed to put to leveldb");
+ free(err);
return RESOURCED_ERROR_DB_FAILED;
}
- free(err);
- err = NULL;
_D("%s:%s", key, value);
return RESOURCED_ERROR_NONE;
}
@@ -714,10 +714,9 @@ int logging_leveldb_putv(char *key, unsigned int key_len, const char *fmt, ...)
leveldb_put(logging_leveldb, woptions, key, key_len, value, value_len, &err);
if (err != NULL) {
_E("Failed to put to leveldb");
+ free(err);
return RESOURCED_ERROR_DB_FAILED;
}
- free(err);
- err = NULL;
_D("%s:%s", key, value);
return RESOURCED_ERROR_NONE;
}
@@ -739,10 +738,9 @@ int logging_leveldb_read(char *key, unsigned int key_len, char *value, unsigned
result = leveldb_get(logging_leveldb, roptions, key, key_len, &read_len, &err);
if (err != NULL) {
_E("Failed to get from leveldb");
+ free(err);
return RESOURCED_ERROR_DB_FAILED;
}
- free(err);
- err = NULL;
if (read_len < value_len) {
memcpy(value, result, read_len);
value[read_len] = '\0';
@@ -772,10 +770,9 @@ int logging_leveldb_delete(char *key, unsigned int key_len)
leveldb_delete(logging_leveldb, woptions, key, key_len, &err);
if (err != NULL) {
_E("Failed to delete from leveldb");
+ free(err);
return RESOURCED_ERROR_DB_FAILED;
}
- free(err);
- err = NULL;
return RESOURCED_ERROR_NONE;
}
@@ -1690,6 +1687,7 @@ int logging_init(void *data)
db_elem->path = strndup(SYSTEM_DEFAULT_DB_NAME, sizeof(SYSTEM_DEFAULT_DB_NAME));
if (!(db_elem->path)) {
_E("Out of memory!");
+ free(db_elem);
return RESOURCED_ERROR_OUT_OF_MEMORY;
}
diff --git a/src/proc-stat/proc-main.c b/src/proc-stat/proc-main.c
index 903d0370..a5bc6fac 100644
--- a/src/proc-stat/proc-main.c
+++ b/src/proc-stat/proc-main.c
@@ -740,6 +740,8 @@ static struct proc_app_info *proc_create_app_info(const char *appid,
pai->ai = resourced_appinfo_get(pai->ai, appid, pkgid);
if (!pai->ai) {
_E("Failed to get resourced_appinfo, appid(%s), pkgid(%s)", appid, pkgid);
+ free(pai);
+ prelaunch = NULL;
return NULL;
}