summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnsung Lee <unsung.lee@samsung.com>2024-02-22 17:41:24 +0900
committerUnsung Lee <unsung.lee@samsung.com>2024-03-05 21:07:31 +0900
commit0a753019e528a7a6f069b842436b294022e0cd23 (patch)
treed4d9611014fe1c3c35b05df91af5305146c7bf5d
parent992334666316e03545a1cdfe66f4c746482edd9b (diff)
downloadresourced-0a753019e528a7a6f069b842436b294022e0cd23.tar.gz
resourced-0a753019e528a7a6f069b842436b294022e0cd23.tar.bz2
resourced-0a753019e528a7a6f069b842436b294022e0cd23.zip
logging: Remove useless code which causes bug
Remove useless code which access critical section without lock. g_queue_foreach() and g_queue_get_length() already handles empty queue case. This problem is reported in coverity with 1739919 id. Change-Id: Id7f678b5731d4339a61848c91251305e3050ff7c Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
-rw-r--r--src/resource-monitor/logging.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/resource-monitor/logging.c b/src/resource-monitor/logging.c
index f487752a..0d297120 100644
--- a/src/resource-monitor/logging.c
+++ b/src/resource-monitor/logging.c
@@ -905,11 +905,9 @@ int logging_read_foreach(char *name, char *appid, char *pkgid,
}
/* search from cache */
- if (!g_queue_is_empty(module->cache)) {
- pthread_mutex_lock(&(module->cache_mutex));
- g_queue_foreach(module->cache, (GFunc)logging_cache_search, (gpointer)&search);
- pthread_mutex_unlock(&(module->cache_mutex));
- }
+ pthread_mutex_lock(&(module->cache_mutex));
+ g_queue_foreach(module->cache, (GFunc)logging_cache_search, (gpointer)&search);
+ pthread_mutex_unlock(&(module->cache_mutex));
return RESOURCED_ERROR_NONE;
}
@@ -1042,16 +1040,14 @@ int logging_modify_appid(char *module_name, char *old_appid, char *new_appid, in
}
/* Modify cache */
- if (!g_queue_is_empty(module->cache)) {
- pthread_mutex_lock(&(module->cache_mutex));
- for (i = 0; i < g_queue_get_length(module->cache); i++) {
- entry = (struct logging_table_form *)g_queue_peek_nth(
- module->cache, i);
- if (entry->uid == uid && !strncmp(entry->appid, old_appid, strlen(old_appid)))
- snprintf(entry->appid, MAX_APPID_LENGTH, "%s", new_appid);
- }
- pthread_mutex_unlock(&(module->cache_mutex));
+ pthread_mutex_lock(&(module->cache_mutex));
+ for (i = 0; i < g_queue_get_length(module->cache); i++) {
+ entry = (struct logging_table_form *)g_queue_peek_nth(
+ module->cache, i);
+ if (entry->uid == uid && !strncmp(entry->appid, old_appid, strlen(old_appid)))
+ snprintf(entry->appid, MAX_APPID_LENGTH, "%s", new_appid);
}
+ pthread_mutex_unlock(&(module->cache_mutex));
/* Modify DB */
switch (module->db_type) {