Fix memory leak due to missing unref on returned g_variant value 72/106772/2
authorSeungbae Shin <seungbae.shin@samsung.com>
Fri, 23 Dec 2016 03:44:17 +0000 (12:44 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Fri, 23 Dec 2016 04:28:20 +0000 (13:28 +0900)
revise some improper log level prints

[Version] 0.10.75
[Profile] Common
[Issue Type] KONA

Change-Id: I199b15b37b38010a62d5a1cec957a9e9af6b1ab8

focus_server/mm_sound_mgr_focus.c
focus_server/mm_sound_mgr_focus_dbus.c
mm_sound_client.c
packaging/libmm-sound.spec
server/mm_sound_mgr_ipc_dbus.c

index 650e7c3..58d9480 100644 (file)
@@ -330,7 +330,7 @@ int _mm_sound_mgr_focus_do_callback(focus_command_e command, focus_node_t *victi
 
        focus_cb_data cb_data;
 
-       debug_error(" __mm_sound_mgr_focus_do_callback_ for pid(%d) handle(%d)\n", victim_node->pid, victim_node->handle_id);
+       debug_msg(" __mm_sound_mgr_focus_do_callback_ for pid(%d) handle(%d)\n", victim_node->pid, victim_node->handle_id);
 
        memset(&cb_data, 0, sizeof(focus_cb_data));
        cb_data.pid= victim_node->pid;
@@ -450,7 +450,7 @@ int _mm_sound_mgr_focus_do_callback(focus_command_e command, focus_node_t *victi
                if (victim_node->reacquisition != (bool)((ret >> 16) & 0xf)) {
                        reacquisition_changed = true;
                        victim_node->reacquisition = (bool)((ret >> 16) & 0xf);
-                       debug_error("[RETCB] victim's reacquisition is changed to (%d)\n", victim_node->reacquisition);
+                       debug_msg("[RETCB] victim's reacquisition is changed to (%d)\n", victim_node->reacquisition);
                }
        }
 
index 119ce49..fd05a95 100644 (file)
@@ -219,14 +219,15 @@ static int _get_sender_pid(GDBusMethodInvocation* invocation)
        connection = g_dbus_method_invocation_get_connection(invocation);
        sender = g_dbus_method_invocation_get_sender(invocation);
 
-       debug_error("connection = %p, sender = %s", connection, sender);
+       debug_msg("connection = %p, sender = %s", connection, sender);
 
        value = g_dbus_connection_call_sync(connection, "org.freedesktop.DBus", "/org/freedesktop/DBus",
                                                                                "org.freedesktop.DBus", "GetConnectionUnixProcessID",
                                                                                g_variant_new("(s)", sender, NULL), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
        if (value) {
                g_variant_get(value, "(u)", &pid);
-               debug_error("Sender PID = [%d]", pid);
+               debug_msg("Sender PID = [%d]", pid);
+               g_variant_unref(value);
        } else {
                debug_error("err code = %d, err msg = %s", err->code, err->message);
        }
@@ -237,7 +238,7 @@ static void _method_call_return_value(GDBusMethodInvocation *invocation, GVarian
 {
        const char *method_name;
        method_name = g_dbus_method_invocation_get_method_name(invocation);
-       debug_error("Method Call '%s' success", method_name);
+       debug_msg("Method Call '%s' success", method_name);
        g_dbus_method_invocation_return_value(invocation, params);
 }
 static void _method_call_return_error(GDBusMethodInvocation *invocation, int ret)
@@ -557,7 +558,7 @@ void emergent_exit_signal_handler(audio_event_t event, GVariant *param, void *us
        debug_log("emergent exit : pid %d", pid);
        ret = __mm_sound_mgr_focus_ipc_emergent_exit(pid);
        if (ret)
-               debug_error("__mm_sound_mgr_focus_ipc_emergent_exit faild : 0x%x", ret);
+               debug_error("__mm_sound_mgr_focus_ipc_emergent_exit failed : 0x%x", ret);
 
        debug_fleave();
 }
@@ -602,7 +603,7 @@ static int _mm_sound_mgr_focus_dbus_own_name(GBusType bus_type, const char* well
 {
        guint oid;
 
-       debug_log("Own name (%s) for focus-server", wellknown_name);
+       debug_msg("Own name (%s) for focus-server", wellknown_name);
 
        oid = g_bus_own_name(bus_type, wellknown_name, G_BUS_NAME_OWNER_FLAGS_NONE,
                        on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
@@ -613,14 +614,14 @@ static int _mm_sound_mgr_focus_dbus_own_name(GBusType bus_type, const char* well
                *owner_id = oid;
        }
 
-       debug_log("OwnerID (%d) for focus-server", *owner_id);
+       debug_msg("OwnerID (%d) for focus-server", *owner_id);
 
        return MM_ERROR_NONE;
 }
 
 static void _mm_sound_mgr_focus_dbus_unown_name(guint oid)
 {
-       debug_log("Unown name for focus-server [%d]", oid);
+       debug_msg("Unown name for focus-server [%d]", oid);
        if (oid > 0) {
                g_bus_unown_name(oid);
        }
index e71d8f9..fe9cef3 100644 (file)
@@ -137,7 +137,7 @@ void _system_signal_handler(int signo)
        int ret = MM_ERROR_NONE;
        sigset_t old_mask, all_mask;
 
-       debug_error("Got signal : signo(%d)", signo);
+       debug_warning("Got signal : signo(%d)", signo);
 
        /* signal block */
 
@@ -184,7 +184,7 @@ void _system_signal_handler(int signo)
                break;
        }
 
-       debug_error("signal handling end");
+       debug_warning("signal handling end");
 }
 
 int mm_sound_client_initialize(void)
@@ -284,7 +284,7 @@ void mm_sound_convert_volume_type_to_stream_type(int volume_type, char *stream_t
                break;
        }
 
-       debug_error("volume type (%d) converted to stream type (%s)", volume_type, stream_type);
+       debug_msg("volume type (%d) converted to stream type (%s)", volume_type, stream_type);
 
 }
 
@@ -297,7 +297,7 @@ void _mm_sound_client_focus_signal_callback(mm_sound_signal_name_t signal, int v
        int ret = MM_ERROR_NONE;
 
        debug_fenter();
-       debug_error("focus signal received, value = %d", value);
+       debug_msg("focus signal received, value = %d", value);
 
        if (value == 1) {
                ret = mm_sound_proxy_clear_focus(getpid());
@@ -1150,17 +1150,17 @@ static gboolean _focus_callback_handler(gpointer d)
                tid = g_focus_sound_handle[focus_index].focus_tid;
 
                if (changed_state != -1) {
-                       debug_error("Got and start CB : TID(%d), handle(%d), type(%d), state(%d,(DEACTIVATED(0)/ACTIVATED(1)), trigger(%s)", tid, cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type);
+                       debug_msg("Got and start CB : TID(%d), handle(%d), type(%d), state(%d,(DEACTIVATED(0)/ACTIVATED(1)), trigger(%s)", tid, cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type);
                        if (g_focus_sound_handle[focus_index].focus_callback == NULL) {
                                        debug_error("callback is null..");
                                        g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
                                        return FALSE;
                        }
-                       debug_error("[CALLBACK(%p) START]",g_focus_sound_handle[focus_index].focus_callback);
+                       debug_msg("[CALLBACK(%p) START]",g_focus_sound_handle[focus_index].focus_callback);
                        (g_focus_sound_handle[focus_index].focus_callback)(cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type, cb_data.option, cb_data.ext_info, g_focus_sound_handle[focus_index].user_data);
-                       debug_error("[CALLBACK END]");
+                       debug_msg("[CALLBACK END]");
                        if (g_focus_session_interrupt_info.user_cb) {
-                               debug_error("sending session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
+                               debug_msg("sending session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
                                (g_focus_session_interrupt_info.user_cb)(cb_data.state, cb_data.stream_type, false, g_focus_session_interrupt_info.user_data);
                        }
                }
@@ -1174,7 +1174,7 @@ static gboolean _focus_callback_handler(gpointer d)
                        if (tmpfd < 0) {
                                char str_error[256];
                                strerror_r(errno, str_error, sizeof(str_error));
-                               debug_error("[RETCB][Failed(May Server Close First)]tid(%d) fd(%d) %s errno=%d(%s)\n", tid, tmpfd, filename2, errno, str_error);
+                               debug_warning("[RETCB][Failed(May Server Close First)]tid(%d) fd(%d) %s errno=%d(%s)\n", tid, tmpfd, filename2, errno, str_error);
                                g_free(filename2);
                                g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
                                return FALSE;
@@ -1226,12 +1226,12 @@ static gboolean _focus_watch_callback_handler(gpointer d)
                        return FALSE;
                }
 
-               debug_error("lock focus_lock = %p", &g_focus_sound_handle[focus_index].focus_lock);
+               debug_msg("lock focus_lock = %p", &g_focus_sound_handle[focus_index].focus_lock);
                g_mutex_lock(&g_focus_sound_handle[focus_index].focus_lock);
 
                tid = g_focus_sound_handle[focus_index].focus_tid;
 
-               debug_error("Got and start CB : TID(%d), handle(%d), type(%d), state(%d,(DEACTIVATED(0)/ACTIVATED(1)), trigger(%s)", tid, cb_data.handle,  cb_data.type, cb_data.state, cb_data.stream_type);
+               debug_msg("Got and start CB : TID(%d), handle(%d), type(%d), state(%d,(DEACTIVATED(0)/ACTIVATED(1)), trigger(%s)", tid, cb_data.handle,  cb_data.type, cb_data.state, cb_data.stream_type);
 
                if (g_focus_sound_handle[focus_index].watch_callback == NULL) {
                        debug_msg("callback is null..");
@@ -1240,7 +1240,7 @@ static gboolean _focus_watch_callback_handler(gpointer d)
                        (g_focus_sound_handle[focus_index].watch_callback)(cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type, cb_data.ext_info, g_focus_sound_handle[focus_index].user_data);
                        debug_msg("[CALLBACK END]");
                        if (g_focus_session_interrupt_info.user_cb) {
-                               debug_error("sending session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
+                               debug_msg("sending session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
                                (g_focus_session_interrupt_info.user_cb)(cb_data.state, cb_data.stream_type, true, g_focus_session_interrupt_info.user_data);
                        }
                }
@@ -1255,7 +1255,7 @@ static gboolean _focus_watch_callback_handler(gpointer d)
                        if (tmpfd < 0) {
                                char str_error[256];
                                strerror_r(errno, str_error, sizeof(str_error));
-                               debug_error("[RETCB][Failed(May Server Close First)]tid(%d) fd(%d) %s errno=%d(%s)\n", tid, tmpfd, filename2, errno, str_error);
+                               debug_warning("[RETCB][Failed(May Server Close First)]tid(%d) fd(%d) %s errno=%d(%s)\n", tid, tmpfd, filename2, errno, str_error);
                                g_free(filename2);
                                g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
                                return FALSE;
@@ -1269,7 +1269,7 @@ static gboolean _focus_watch_callback_handler(gpointer d)
 #endif
        }
 
-       debug_error("unlock focus_lock = %p", &g_focus_sound_handle[focus_index].focus_lock);
+       debug_msg("unlock focus_lock = %p", &g_focus_sound_handle[focus_index].focus_lock);
        g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
 
        debug_fleave();
@@ -1299,7 +1299,7 @@ static void _focus_open_callback(int index, bool is_for_watching)
        if (g_focus_sound_handle[index].focus_fd == -1) {
                debug_error("Open fail : index(%d), file open error(%d)", index, errno);
        } else {
-               debug_log("Open sucess : index(%d), filename(%s), fd(%d)", index, filename, g_focus_sound_handle[index].focus_fd);
+               debug_log("Open success : index(%d), filename(%s), fd(%d)", index, filename, g_focus_sound_handle[index].focus_fd);
        }
        g_free(filename);
        filename = NULL;
@@ -1334,7 +1334,7 @@ void _focus_close_callback(int index, bool is_for_watching)
                debug_error("Close fail : index(%d)", index);
        } else {
                close(g_focus_sound_handle[index].focus_fd);
-               debug_log("Close Sucess : index(%d)", index);
+               debug_log("Close Success : index(%d)", index);
        }
 
        if (is_for_watching) {
index b0b9ed5..c82dad7 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.10.74
+Version:    0.10.75
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 67ffa59..1fc3ec1 100644 (file)
@@ -238,6 +238,7 @@ static int _get_sender_pid(GDBusMethodInvocation* invocation)
        if (value) {
                g_variant_get(value, "(u)", &pid);
                debug_msg("Sender PID = [%d]", pid);
+               g_variant_unref(value);
        } else {
                debug_error("err code = %d, err msg = %s", err->code, err->message);
        }