From: SangYoun Kwak Date: Tue, 13 Sep 2022 09:43:18 +0000 (+0900) Subject: Fix duplicated code for popup/noti callback X-Git-Tag: accepted/tizen/7.0/unified/20221110.062844~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=87f74edf2ec79532670cfd9f5e2439e281a6d739;p=platform%2Fcore%2Fsystem%2Fstoraged.git Fix duplicated code for popup/noti callback Change-Id: Ic956f12838a14f59916ce2b4ae3ade666bbf1dd8 Signed-off-by: SangYoun Kwak --- diff --git a/src/storage/storage.c b/src/storage/storage.c index 99dc516..4553459 100644 --- a/src/storage/storage.c +++ b/src/storage/storage.c @@ -231,9 +231,9 @@ out: cleanup_storage(path, level); } -static void _popup_cb(GVariant *var, void *user_data, GError *err) +static void _cb_get_message(GVariant *var, void *user_data, GError *err, int *ret) { - int ret_val; + int ret_val = 0; if (!var) { _E("No message: %s", err->message); @@ -245,12 +245,19 @@ static void _popup_cb(GVariant *var, void *user_data, GError *err) goto out; } - _D("Reply value: %d", ret_val); + if (ret != NULL) + *ret = ret_val; + _D("Reply value: %d", ret_val); out: g_variant_unref(var); } +static void _popup_cb(GVariant *var, void *user_data, GError *err) +{ + _cb_get_message(var, user_data, err, NULL); +} + static int launch_memory_popup(int num, ...) { int ret; @@ -275,23 +282,7 @@ static int launch_memory_popup(int num, ...) static void _noti_cb(GVariant *var, void *user_data, GError *err) { - int ret_val; - - if (!var) { - _E("No message: %s", err->message); - return; - } - - if (!g_variant_get_safe(var, "(i)", &ret_val)) { - _E("No message: %s", g_variant_get_type_string(var)); - goto out; - } - - noti_id = ret_val; - _D("Reply value: %d", ret_val); - -out: - g_variant_unref(var); + _cb_get_message(var, user_data, err, ¬i_id); } static int remove_notification(void)