From: Yunhee Seo Date: Fri, 9 Aug 2024 11:44:28 +0000 (+0900) Subject: power: Modify the code to keep code consistency X-Git-Tag: accepted/tizen/8.0/unified/20240813.163313^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_8.0_unified;p=platform%2Fcore%2Fsystem%2Fdeviced.git power: Modify the code to keep code consistency To keep code quality and readability, these modifications are added. 1. Remove unofficial abbreviations in function/variable name. 2. Change void return type function to return int type. 3. Add return value checking and debug message. Change-Id: I2bd738db09beb10cf5a79ba7d95ce2deea399595 Signed-off-by: Yunhee Seo --- diff --git a/src/power/power.c b/src/power/power.c index 16a440e7..96d35efe 100644 --- a/src/power/power.c +++ b/src/power/power.c @@ -199,26 +199,31 @@ int add_change_state_wait(pid_t pid, guint64 state) return 0; } -static void remove_csw_element_from_waiting_list(struct proc_info* pi, guint64 state) +static int remove_change_state_wait_element_from_waiting_list(struct proc_info* proc_info, guint64 state) { GList *iterator = transition_context.waitings; + if (!proc_info) + return -EINVAL; + while (iterator != NULL) { - struct change_state_wait *csw = (struct change_state_wait *)iterator->data; - if (csw->pi->pid == pi->pid && csw->state == state) { + struct change_state_wait *change_state_wait = (struct change_state_wait *)iterator->data; + if (change_state_wait->pi->pid == proc_info->pid && change_state_wait->state == state) { transition_context.waitings = g_list_remove_link(transition_context.waitings, iterator); free(g_steal_pointer(&iterator->data)); g_list_free(iterator); - return; + break; } iterator = g_list_next(iterator); } + return 0; } void remove_change_state_wait(pid_t pid, guint64 state) { struct proc_info *pi = NULL; GList *l = NULL; + int ret = 0; l = g_list_find_custom(proc_list, &pid, find_pi_by_pid); if (!l) @@ -232,7 +237,12 @@ void remove_change_state_wait(pid_t pid, guint64 state) _D("pid=%d(%s) removed csw for %#"PRIx64, pi->pid, pi->comm, state); pi->state_bitmap &= ~state; - remove_csw_element_from_waiting_list(pi, state); + ret = remove_change_state_wait_element_from_waiting_list(pi, state); + if (ret < 0) { + _E("Failed to remove change state wait element from waiting list"); + return; + } + if (pi->state_bitmap == 0) { proc_list = g_list_remove_link(proc_list, l); free(g_steal_pointer(&l->data));