Fix lcov option for lcov 2.0
[platform/core/appfw/librua.git] / src / rua_dbus.c
index 1957e48..e910328 100644 (file)
@@ -20,6 +20,7 @@
 #include <glib.h>
 #include <gio/gio.h>
 #include <dlog.h>
+#include <sqlite3.h>
 
 #include "rua.h"
 #include "rua_dbus.h"
@@ -29,8 +30,7 @@
 #define RUA_PATH "/org/tizen/rua"
 #define RUA_SIGNAL_DATA_UPDATE "dataupdate"
 
-struct cb_data
-{
+struct cb_data {
        int callback_id;
        rua_history_update_cb callback;
        void *user_data;
@@ -40,7 +40,7 @@ static GDBusConnection *conn;
 static guint s_id;
 
 static gint atomic_callback_id;
-static GHashTablecallback_hash_table;
+static GHashTable *callback_hash_table;
 
 static void __foreach_callback(gpointer key, gpointer value,
                gpointer user_data);
@@ -66,15 +66,25 @@ int rua_dbus_send_update_signal(update_type type)
                                RUA_SIGNAL_DATA_UPDATE,
                                g_variant_new("(i)", type),
                                &err) == FALSE) {
-               LOGE("g_dbus_connection_emit_signal() is failed. %s",
-                               err->message);
+               if (err != NULL) {
+                       LOGE("g_dbus_connection_emit_signal() is failed. %s",
+                                       err->message);
+                       g_clear_error(&err);
+               } else {
+                       LOGE("g_dbus_connection_emit_signal() is failed");
+               }
                __rua_dbus_exit();
                return -1;
        }
 
        if (g_dbus_connection_flush_sync(conn, NULL, &err) == FALSE) {
-               LOGE("g_dbus_connection_flush_sync() is failed. %s",
-                               err->message);
+               if (err != NULL) {
+                       LOGE("g_dbus_connection_flush_sync() is failed. %s",
+                                       err->message);
+                       g_clear_error(&err);
+               } else {
+                       LOGE("g_dbus_connection_emit_signal() is failed");
+               }
                __rua_dbus_exit();
                return -1;
        }
@@ -179,9 +189,10 @@ static void __foreach_callback(gpointer key, gpointer value,
        if (r == -1)
                return;
 
-       if (cd->callback) {
+       if (cd->callback)
                cd->callback(table, nrows, ncols, cd->user_data);
-       }
+
+       sqlite3_free_table(table);
 }
 
 static void __signal_handler(GDBusConnection *connection,
@@ -205,14 +216,20 @@ static void __signal_handler(GDBusConnection *connection,
 
 static void __rua_dbus_init(void)
 {
-       if (!conn) {
-               GError *err = NULL;
-               conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-               if (!conn) {
-                       LOGE("g_bus_get_sync() is failed. %s", err->message);
-                       g_error_free(err);
-                       return;
-               }
+       GError *err = NULL;
+
+       if (conn)
+               return;
+
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+       if (conn)
+               return;
+
+       if (err != NULL) {
+               LOGE("g_bus_get_sync() is failed. %s", err->message);
+               g_error_free(err);
+       } else {
+               LOGE("g_bus_get_sync() is failed.");
        }
 }