Fixed coding style error and build warnings
authorAtul Rai <a.rai@samsung.com>
Wed, 9 Jan 2019 09:23:55 +0000 (14:53 +0530)
committer김새롬/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <saerome.kim@samsung.com>
Wed, 9 Jan 2019 13:36:49 +0000 (22:36 +0900)
Signed-off-by: Atul Rai <a.rai@samsung.com>
ua-daemon/include/ua-plugin-manager.h
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
ua-plugins/include/ua-power-plugin.h

index 1c9261b..abfb742 100644 (file)
@@ -36,8 +36,8 @@ extern "C" {
 
 #define UAM_VERSION "0.1"
 
-#define PATH_MAX 4096 + 1 /**< Max. linux path length */
-#define NAME_MAX 255 + 1 /**< Max. linux file name length */
+//#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,
index 4306550..89597e6 100644 (file)
@@ -33,7 +33,7 @@ static GSList *ppm_reqs = NULL; /**< list of requests from power plugin */
 
 static void __uam_clear_ppm_reqs(void)
 {
-       g_list_free_full(ppm_reqs, g_free);
+       g_slist_free_full(ppm_reqs, g_free);
        ppm_reqs = NULL;
 }
 
@@ -51,7 +51,7 @@ static gboolean __uam_check_presence_timeout(gpointer data)
        _uam_remove_timer(con->tid);
        con->tid = TIMER_OFF;
 
-       ppm_reqs = g_list_remove(ppm_reqs, con);
+       ppm_reqs = g_slist_remove(ppm_reqs, con);
        con = NULL;
 
        return FALSE;
@@ -59,30 +59,30 @@ static gboolean __uam_check_presence_timeout(gpointer data)
 
 static gboolean __uam_is_busy(uas_plugin_id_e ids)
 {
-       GList *head = ppm_reqs;
-       GList *iter = head;
+       GSList *head = ppm_reqs;
+       GSList *iter = head;
 
        while (NULL != iter) {
-               GList *next = iter->next;
+               GSList *next = iter->next;
                _uam_req_cb_s *con = iter->data;
-               if (con && con->ids == ids) {
+               if (con && con->ids == ids)
                        return TRUE;
-               }
+
                iter = next;
        }
        return FALSE;
 }
 
-int do_presence_check_callback(uas_plugin_id_e ids, int timeout, presence_cb cb)
+static int do_presence_check_callback(uas_plugin_id_e ids, int timeout, presence_cb cb)
 {
        FUNC_ENTRY;
 
        _uam_req_cb_s *con = NULL;
 
-       retv_if(NULL == cb, UAP_STATUS_INVALID_PARAMS);
+       retv_if(NULL == cb, UAP_STATUS_INVALID_PARAMS);
 
        UAM_DBG("Do one time presence check-up %s %d (msec)",
-               _uam_get_sensor_str(ids), timeout);
+                       _uam_get_sensor_str(ids), timeout);
 
        if (0 >= timeout) {
                UAM_ERR("Invalid timeout value %d (msec)", timeout);
@@ -100,9 +100,9 @@ int do_presence_check_callback(uas_plugin_id_e ids, int timeout, presence_cb cb)
        con->cb = cb;
        con->ids = ids;
        con->tid = _uam_add_timer_full(TIMER_RES_MSEC, G_PRIORITY_DEFAULT,
-               timeout, __uam_check_presence_timeout, con, NULL);
+                       timeout, __uam_check_presence_timeout, con, NULL);
 
-       ppm_reqs = g_list_append(ppm_reqs, con);
+       ppm_reqs = g_slist_append(ppm_reqs, con);
 
        /* To-Do : Need to do one-time presence check */
 
@@ -111,20 +111,20 @@ int do_presence_check_callback(uas_plugin_id_e ids, int timeout, presence_cb cb)
        return UAP_STATUS_SUCCESS;
 }
 
-int stop_presence_check_callback(uas_plugin_id_e ids)
+static void stop_presence_check_callback(uas_plugin_id_e ids)
 {
        FUNC_ENTRY;
 
        UAM_DBG("Stop one time presence check-up : %s", _uam_get_sensor_str(ids));
 
-       GList *head = NULL;
-       GList *iter = NULL;
+       GSList *head = NULL;
+       GSList *iter = NULL;
 
        head = ppm_reqs;
        iter = head;
 
        while (NULL != iter) {
-               GList *next = iter->next;
+               GSList *next = iter->next;
                _uam_req_cb_s *con = iter->data;
                if (con && con->ids == ids) {
                        _uam_remove_timer(con->tid);
@@ -135,8 +135,7 @@ int stop_presence_check_callback(uas_plugin_id_e ids)
                        con = NULL;
 
                        UAM_DBG("[%d] request canceled", ids);
-
-                       return UAP_STATUS_SUCCESS;
+                       return;
                }
                iter = next;
        }
@@ -144,19 +143,18 @@ int stop_presence_check_callback(uas_plugin_id_e ids)
        UAM_DBG("[%d] no matching request", ids);
 
        FUNC_EXIT;
-
-       return UAP_STATUS_SUCCESS;
-
 }
 
 int _uam_ppm_handler_init(void)
 {
        __uam_clear_ppm_reqs();
+       return UAP_STATUS_SUCCESS;
 }
 
 int _uam_ppm_handler_deinit(void)
 {
        __uam_clear_ppm_reqs();
+       return UAP_STATUS_SUCCESS;
 }
 
 uap_callbacks_t power_cbs = {
index 4dde25b..97ff5f6 100644 (file)
@@ -20,6 +20,7 @@
 #include <ua-plugin.h>
 #include <ua-power-plugin.h>
 #include <ua-plugin-manager.h>
+#include <ua-power-plugin-manager.h>
 #include <tzplatform_config.h>
 
 extern const uap_callbacks_t power_cbs;
@@ -36,22 +37,22 @@ static void __deinit_power_plugin(void)
 {
        FUNC_ENTRY;
 
-       /* Deinitialize and unload power plugins */
-       if (!pwr_plugin) {
+       /* Deinitialize and unload power plugins */
+       if (!pwr_plugin) {
                UAM_WARN("Power plugin is NULL");
                return;
        }
-       if (pwr_plugin->api && pwr_plugin->api->deinit)
+       if (pwr_plugin->api && pwr_plugin->api->deinit)
                pwr_plugin->api->deinit();
-       if (pwr_plugin->module && pwr_plugin->module->deinit)
+       if (pwr_plugin->module && pwr_plugin->module->deinit)
                pwr_plugin->module->deinit();
-       if (pwr_plugin->handle)
+       if (pwr_plugin->handle)
                dlclose(pwr_plugin->handle);
 
-       g_free(pwr_plugin);
+       g_free(pwr_plugin);
        pwr_plugin = NULL;
 
-       FUNC_EXIT;
+       FUNC_EXIT;
 }
 
 static gboolean __add_power_plugin(void *handle, uap_module_t *module)
@@ -60,40 +61,40 @@ static gboolean __add_power_plugin(void *handle, uap_module_t *module)
 
        uap_api_t *api = NULL;
        uam_power_plugin_info_t *plugin = pwr_plugin;
-       UAM_DBG("Plugin [id: %d, name: %s, version: %s]",
+       UAM_DBG("Plugin [id: %d, name: %s, version: %s]",
                        module->id, module->name, module->version);
 
-       if (NULL != pwr_plugin) {
+       if (NULL != pwr_plugin) {
                UAM_ERR("Plugin already added");
                return FALSE;
        }
 
-       if (g_str_equal(module->version, UAM_VERSION) == FALSE) {
+       if (g_str_equal(module->version, UAM_VERSION) == FALSE) {
                UAM_ERR("Version (%s) mismatch for %s",
                                module->version, module->name);
                return FALSE;
        }
 
-       plugin = g_try_new0(uam_power_plugin_info_t, 1);
+       plugin = g_try_new0(uam_power_plugin_info_t, 1);
        if (NULL == plugin) {
                UAM_ERR("Memory allocation failed");
                return FALSE;
        }
 
-       retv_if(NULL == module->init, FALSE);
-       module->init(&api);
+       retv_if(NULL == module->init, FALSE);
+       module->init(&api);
        if (NULL == api) {
                UAM_ERR("API returned is NULL");
                return FALSE;
        }
 
-       plugin->handle = handle;
+       plugin->handle = handle;
        plugin->module = module;
        plugin->api = api;
 
-       pwr_plugin = plugin;
+       pwr_plugin = plugin;
 
-       FUNC_EXIT;
+       FUNC_EXIT;
        return TRUE;
 }
 
@@ -105,36 +106,36 @@ static int __load_power_plugin(const char *path, const char *name, const char *s
        void *handle = NULL;
        uap_module_t *module = NULL;
 
-       retv_if(NULL == path, UAM_ERROR_INVALID_PARAM);
+       retv_if(NULL == path, UAM_ERROR_INVALID_PARAM);
        retv_if(NULL == name, UAM_ERROR_INVALID_PARAM);
        retv_if(NULL == symbol, UAM_ERROR_INVALID_PARAM);
 
-       filename = g_build_filename(path, name, NULL);
+       filename = g_build_filename(path, name, NULL);
        UAM_DBG("Loading [%s]", filename);
 
-       handle = dlopen(filename, RTLD_NOW);
+       handle = dlopen(filename, RTLD_NOW);
        g_free(filename);
        if (handle == NULL) {
                UAM_ERR("Can't load plugin %s: %s", filename, dlerror());
                return UAM_ERROR_INTERNAL;
        }
 
-       module = (uap_module_t *)dlsym(handle, symbol);
+       module = (uap_module_t *)dlsym(handle, symbol);
        if (module == NULL) {
                UAM_ERR("Can't load power plugin module: %s", dlerror());
                dlclose(handle);
                return UAM_ERROR_INTERNAL;
        }
 
-       if (UAP_PLUGIN_ID_POWER != module->id) {
+       if (UAP_PLUGIN_ID_POWER != module->id) {
                dlclose(handle);
                handle = NULL;
                return UAM_ERROR_INVALID_PARAM;
        }
 
-       retv_if(FALSE == __add_power_plugin(handle, module), UAM_ERROR_INTERNAL);
+       retv_if(FALSE == __add_power_plugin(handle, module), UAM_ERROR_INTERNAL);
 
-       FUNC_EXIT;
+       FUNC_EXIT;
        return UAM_ERROR_NONE;
 }
 
@@ -142,29 +143,29 @@ static int __load_power_plugins(void)
 {
        FUNC_ENTRY;
 
-       GDir *dir;
+       GDir *dir;
        const char *filename;
        int ret = UAM_ERROR_INTERNAL;
 
-       retv_if(0 == strlen(POWER_PLUGIN_DIR), UAM_ERROR_INVALID_PARAM);
-       UAM_DBG("Loading power plugin from %s", POWER_PLUGIN_DIR);
+       retv_if(0 == strlen(POWER_PLUGIN_DIR), UAM_ERROR_INVALID_PARAM);
+       UAM_DBG("Loading power plugin from %s", POWER_PLUGIN_DIR);
 
-       dir = g_dir_open(POWER_PLUGIN_DIR, 0, NULL);
+       dir = g_dir_open(POWER_PLUGIN_DIR, 0, NULL);
        if (!dir) {
                UAM_ERR("Unable to open directory");
                return UAM_ERROR_INTERNAL;
        }
 
-       while ((filename = g_dir_read_name(dir)) != NULL) {
-               if (g_str_has_suffix(filename, ".so") == FALSE)
+       while ((filename = g_dir_read_name(dir)) != NULL) {
+               if (g_str_has_suffix(filename, ".so") == FALSE)
                        continue;
-               /* If atleast one plugin is loaded, return value is UAM_ERROR_NONE */
+               /* If atleast one plugin is loaded, return value is UAM_ERROR_NONE */
                if (UAM_ERROR_NONE == __load_power_plugin(POWER_PLUGIN_DIR, filename, "uap_module"))
                        ret = UAM_ERROR_NONE;
        }
-       g_dir_close(dir);
+       g_dir_close(dir);
 
-       FUNC_EXIT;
+       FUNC_EXIT;
        return ret;
 }
 
@@ -172,28 +173,28 @@ static int __init_power_plugin(void)
 {
        FUNC_ENTRY;
 
-       int ret;
+       int ret;
        int status;
-       /* Initialize loaded power plugins */
+       /* Initialize loaded power plugins */
        retv_if(UAM_ERROR_NONE != __load_power_plugins(), UAM_ERROR_INTERNAL);
 
-       uam_power_plugin_info_t *plugin = pwr_plugin;
-       if (!plugin || !plugin->api) {
+       uam_power_plugin_info_t *plugin = pwr_plugin;
+       if (!plugin || !plugin->api) {
                UAM_WARN("Plugin is NULL");
                return UAM_ERROR_INVALID_PARAM;
        }
 
-       status = plugin->api->init(&power_cbs);
+       status = plugin->api->init(&power_cbs);
        if (UAS_STATUS_SUCCESS != status) {
                /* Deinit plugin */
                __deinit_power_plugin();
                return UAM_ERROR_NOT_IN_OPERATION;
        }
 
-       /* If atleast one sensor init is success, return success */
+       /* If atleast one sensor init is success, return success */
        ret = UAM_ERROR_NONE;
 
-       FUNC_EXIT;
+       FUNC_EXIT;
        return ret;
 }
 
@@ -213,7 +214,6 @@ int _uam_ppm_init(void)
                return ret;
 
        FUNC_EXIT;
-
        return UAM_ERROR_NONE;
 }
 
index d92ef6a..d76576a 100644 (file)
@@ -174,12 +174,12 @@ guint _uam_add_timer_full(gint res, gint priority,
 const char *_uam_get_sensor_str(uas_plugin_id_e ids)
 {
        switch (ids) {
-               CASE_TO_STR(UAS_PLUGIN_ID_BLE)
-               CASE_TO_STR(UAS_PLUGIN_ID_WIFI)
-               CASE_TO_STR(UAS_PLUGIN_ID_LIGHT)
-               CASE_TO_STR(UAS_PLUGIN_ID_MOTION)
-               CASE_TO_STR(UAS_PLUGIN_ID_MAX)
-               default:
+       CASE_TO_STR(UAS_PLUGIN_ID_BLE)
+       CASE_TO_STR(UAS_PLUGIN_ID_WIFI)
+       CASE_TO_STR(UAS_PLUGIN_ID_LIGHT)
+       CASE_TO_STR(UAS_PLUGIN_ID_MOTION)
+       CASE_TO_STR(UAS_PLUGIN_ID_MAX)
+       default:
                return "UNKNOWN SENSOR";
        }
 }
index 27a163b..8f2a445 100644 (file)
@@ -76,11 +76,11 @@ typedef struct {
 typedef struct {
        /* [Sync API] To initialize power plug-in */
        int (*init)(const uap_callbacks_t* callbacks);
-       /* [Sync API] To deinitialize senspor plug-in */
+       /* [Sync API] To deinitialize senspor plug-in */
        int (*deinit)(void);
-       /* [Sync API] To get plug-in's current state (READY/NOT_READY) */
+       /* [Sync API] To get plug-in's current state (READY/NOT_READY) */
        int (*get_state)(uap_state_e *state);
-       /*
+       /*
         * [Sync API] This function notify power-plugin of presence/absence detection.
         *
         * [Param] type - What event be detected (i.e., PRESENCE or ABSENCE)