Fixed review comments
authorsaerome kim <saerome.kim@samsung.com>
Fri, 4 Jan 2019 01:11:26 +0000 (10:11 +0900)
committer김새롬/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <saerome.kim@samsung.com>
Fri, 4 Jan 2019 15:19:31 +0000 (00:19 +0900)
Signed-off-by: saerome kim <saerome.kim@samsung.com>
ua-daemon/include/ua-manager-common.h
ua-daemon/include/ua-plugin-manager.h
ua-daemon/src/pm/ua-motion-plugin-handler.c [changed mode: 0755->0644]
ua-daemon/src/pm/ua-power-plugin-handler.c
ua-daemon/src/pm/ua-power-plugin-manager.c
ua-daemon/src/ua-manager-common.c

index 463ef42..22ec17c 100644 (file)
@@ -116,8 +116,6 @@ guint _uam_add_timer_full(gint res, gint priority,
        guint interval, GSourceFunc function, gpointer data, GDestroyNotify notify);
 void _uam_remove_timer(guint id);
 
-#define CASE_TO_STR(x) case x: return #x;
-
 const char* _uam_get_sensor_str(unsigned int ids);
 
 #ifdef __cplusplus
index d78f4db..1c9261b 100644 (file)
@@ -36,8 +36,8 @@ extern "C" {
 
 #define UAM_VERSION "0.1"
 
-#define LIB_PATH_SIZE 4096 + 1
-#define LIB_NAME_SIZE 255 + 1
+#define PATH_MAX 4096 + 1 /**< Max. linux path length */
+#define NAME_MAX 255 + 1 /**< Max. linux file name length */
 
 typedef enum {
        UAM_DETECT_PRESENCE = 0x01,
old mode 100755 (executable)
new mode 100644 (file)
index 4292f31..6850564 100644 (file)
@@ -33,10 +33,7 @@ static GList *ppm_reqs = NULL; /**< list of requests from power plugin */
 
 static void __uam_clear_ppm_reqs(void)
 {
-       while (ppm_reqs) {
-               ppm_reqs = g_list_remove(ppm_reqs, ppm_reqs->data);
-       }
-       g_list_free(ppm_reqs);
+       g_list_free_full(ppm_reqs, g_free);
        ppm_reqs = NULL;
 }
 
@@ -62,11 +59,8 @@ static gboolean __uam_check_presence_timeout(gpointer data)
 
 static gboolean __uam_is_busy(uas_plugin_id_e ids)
 {
-       GList *head = NULL;
-       GList *iter = NULL;
-
-       head = ppm_reqs;
-       iter = head;
+       GList *head = ppm_reqs;
+       GList *iter = head;
 
        while (NULL != iter) {
                GList *next = iter->next;
@@ -137,6 +131,7 @@ int stop_presence_check_callback(uas_plugin_id_e ids)
                        con->tid = TIMER_OFF;
 
                        ppm_reqs = g_list_remove(ppm_reqs, con);
+                       g_free(con);
                        con = NULL;
 
                        UAM_DBG("[%d] request canceled", ids);
index 7c08882..4dde25b 100644 (file)
@@ -36,21 +36,20 @@ static void __deinit_power_plugin(void)
 {
        FUNC_ENTRY;
 
-       /* Deinitialize and unload sensor plugins */
-       uam_power_plugin_info_t *plugin = pwr_plugin;
-       if (!plugin) {
+       /* Deinitialize and unload power plugins */
+       if (!pwr_plugin) {
                UAM_WARN("Power plugin is NULL");
                return;
        }
-       if (plugin->api && plugin->api->deinit)
-               plugin->api->deinit();
-       if (plugin->module && plugin->module->deinit)
-               plugin->module->deinit();
-       if (plugin->handle)
-               dlclose(plugin->handle);
+       if (pwr_plugin->api && pwr_plugin->api->deinit)
+               pwr_plugin->api->deinit();
+       if (pwr_plugin->module && pwr_plugin->module->deinit)
+               pwr_plugin->module->deinit();
+       if (pwr_plugin->handle)
+               dlclose(pwr_plugin->handle);
 
-       g_free(plugin);
-       plugin = NULL;
+       g_free(pwr_plugin);
+       pwr_plugin = NULL;
 
        FUNC_EXIT;
 }
@@ -60,7 +59,7 @@ static gboolean __add_power_plugin(void *handle, uap_module_t *module)
        FUNC_ENTRY;
 
        uap_api_t *api = NULL;
-       uam_power_plugin_info_t *plugin;
+       uam_power_plugin_info_t *plugin = pwr_plugin;
        UAM_DBG("Plugin [id: %d, name: %s, version: %s]",
                        module->id, module->name, module->version);
 
index 9abace9..d92ef6a 100644 (file)
@@ -152,13 +152,16 @@ guint _uam_add_timer_full(gint res, gint priority,
 
        retv_if(NULL == function, 0);
 
-       source = res == TIMER_RES_MSEC ? g_timeout_source_new(interval)
-                                               : g_timeout_source_new_seconds(interval);
+       if (TIMER_RES_MSEC)
+               source = g_timeout_source_new(interval);
+       else
+               source = g_timeout_source_new_seconds(interval);
 
        retv_if(NULL == source, 0);
 
        if (priority != G_PRIORITY_DEFAULT)
                g_source_set_priority(source, priority);
+
        g_source_set_callback(source, function, data, notify);
        id = g_source_attach(source, NULL);
        g_source_unref(source);
@@ -166,7 +169,9 @@ guint _uam_add_timer_full(gint res, gint priority,
        return id;
 }
 
-const char* _uam_get_sensor_str(uas_plugin_id_e ids)
+#define CASE_TO_STR(x) case x: return #x;
+
+const char *_uam_get_sensor_str(uas_plugin_id_e ids)
 {
        switch (ids) {
                CASE_TO_STR(UAS_PLUGIN_ID_BLE)