d2d-manager: fix svace issue
authorsaerome.kim <saerome.kim@samsung.com>
Thu, 22 Mar 2018 08:44:11 +0000 (17:44 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:49 +0000 (19:38 +0900)
- memory leak and etc.

Signed-off-by: saerome.kim <saerome.kim@samsung.com>
26 files changed:
capi/CMakeLists.txt [changed mode: 0755->0644]
capi/capi-network-companion.pc.in [changed mode: 0755->0644]
capi/demo/main.c
capi/include/companion.h [changed mode: 0755->0644]
capi/include/companion_debug.h [changed mode: 0755->0644]
capi/src/companion.c
capi/src/companion_gdbus.xml [changed mode: 0755->0644]
capi/unittest/CMakeLists.txt [changed mode: 0755->0644]
capi/unittest/companion_unit_test.cpp [changed mode: 0755->0644]
src/companion-manager/include/comp_enum.h
src/companion-manager/include/comp_group.h
src/companion-manager/include/comp_iot.h
src/companion-manager/include/comp_log.h
src/companion-manager/src/comp_gdbus.c
src/companion-manager/src/comp_group.c
src/companion-manager/src/comp_iot.cpp
src/companion-manager/src/comp_manager.c
src/companion-manager/src/comp_mot_agent.c
src/companion-manager/src/comp_resource.c
src/mot-agent/ma-log.h
src/mot-agent/ma-service-interface.c
src/mot-agent/ma-service-interface.h
src/mot-agent/ma-service.c
src/mot-agent/ma-service.h
src/mot-agent/ma-util.h
src/mot-agent/ma.h

old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index f8b6d23..48fa104 100644 (file)
@@ -90,6 +90,11 @@ static gboolean __create_init_menu(struct menu_data init_menu[1])
        return TRUE;
 }
 
+void _free_device(gpointer data)
+{
+       companion_device_information_destroy(data);
+}
+
 int main(int arg, char **argv)
 {
        GMainLoop *mainloop = NULL;
@@ -121,9 +126,9 @@ int main(int arg, char **argv)
 
 OUT:
        if (found_group_list)
-               g_list_free(found_group_list);
+               g_list_free_full(found_group_list, _free_device);
        if (found_device_list)
-               g_list_free(found_device_list);
+               g_list_free_full(found_device_list, _free_device);
 
        companion_deinitialize();
 
old mode 100755 (executable)
new mode 100644 (file)
index 86b0102..545bc8e
@@ -45,8 +45,9 @@ typedef enum {
 } comp_error_e;
 
 typedef enum {
-       COMPANION_GROUP_TYPE_MINE = 0, /**< My own group */
-       COMPANION_GROUP_TYPE_REMOTE, /**< Groups in remote devices */
+       COMPANION_GROUP_TYPE_ERROR = 0, /**< Error */
+       COMPANION_GROUP_TYPE_MINE = 1, /**< Local type */
+       COMPANION_GROUP_TYPE_REMOTE = 2, /**< Remote type */
 } companion_group_type_e;
 
 typedef void *companion_group_h;
old mode 100755 (executable)
new mode 100644 (file)
index 842d2e9..bfd6dfe
 #define LOG_TAG "COMP_MANAGER_CAPI"
 
 #define _ERR(fmt, ...) \
-        do { \
-                LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__); \
-        } while (0)
+       do { \
+               LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__); \
+       } while (0)
 
 #define _INFO(fmt, ...) \
-        do { \
-                LOGI(COLOR_GREEN fmt COLOR_END, ##__VA_ARGS__); \
-        } while (0)
+       do { \
+               LOGI(COLOR_GREEN fmt COLOR_END, ##__VA_ARGS__); \
+       } while (0)
 
 #define _WARN(fmt, ...) \
-        do { \
-                LOGI(COLOR_BROWN fmt COLOR_END, ##__VA_ARGS__); \
-        } while (0)
+       do { \
+               LOGI(COLOR_BROWN fmt COLOR_END, ##__VA_ARGS__); \
+       } while (0)
 
 #define _DBG(fmt, ...) \
-        do { \
-                LOGD(fmt, ##__VA_ARGS__); \
-        } while (0)
+       do { \
+               LOGD(fmt, ##__VA_ARGS__); \
+       } while (0)
 
 #define _BEGIN() \
-        do { \
-                LOGD(COLOR_BLUE "BEGIN >>>>" COLOR_END); \
-        } while (0)
+       do { \
+               LOGD(COLOR_BLUE "BEGIN >>>>" COLOR_END); \
+       } while (0)
 
 #define _END() \
-        do { \
-                LOGD(COLOR_BLUE "END <<<<" COLOR_END); \
-        } while (0)
+       do { \
+               LOGD(COLOR_BLUE "END <<<<" COLOR_END); \
+       } while (0)
 
 #define cond_expr_ret(expr, val) \
-        do { \
-                if (expr) { \
-                        _ERR("[precond fail] expr : %s, ret : %d\n", #expr, val); \
-                        return (val); \
-                } \
-        } while (0)
+       do { \
+               if (expr) { \
+                       _ERR("[precond fail] expr : %s, ret : %d\n", #expr, val); \
+                       return (val); \
+               } \
+       } while (0)
 
 #define cond_ret(val) \
-        do { \
-                if (val) { \
-                        _ERR("[precond fail] ret : %d\n", val); \
-                        return (val); \
-                } \
-        } while (0)
+       do { \
+               if (val) { \
+                       _ERR("[precond fail] ret : %d\n", val); \
+                       return (val); \
+               } \
+       } while (0)
+
+#define companion_check_null_ret_error(name, value, error) do { \
+       /* LCOV_EXCL_START */ \
+       if (G_UNLIKELY(NULL == (value))) { \
+                               LOGE("%s is NULL", name); \
+                               return error; \
+                       } \
+       /* LCOV_EXCL_STOP */ \
+} while (FALSE)
+
+#define companion_check_null_ret(name, value) do { \
+       /* LCOV_EXCL_START */ \
+       if (G_UNLIKELY(NULL == (value))) { \
+                               LOGE("%s is NULL", name); \
+                               return; \
+                       } \
+       /* LCOV_EXCL_STOP */ \
+} while (FALSE)
+
 
 #define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
 #define TC_PRT(format, args...) PRT(format"\n", ##args)
index 965f800..16afa15 100644 (file)
@@ -141,7 +141,8 @@ static companion_group_t *_create_group_handle(char *uri_path, char *device_id,
        return group;
 }
 
-static companion_device_t *_create_device_handle(char *device_id, char *ip, char *device_type, int port)
+static companion_device_t *_create_device_handle(char *device_id, char *ip,
+       char *device_type, int port)
 {
        companion_device_t *device = g_new0(companion_device_t, 1);
 
@@ -158,14 +159,14 @@ static void __group_found_cb(Group *object,
 {
        GVariantIter *iter = NULL;
        const gchar *key;
-       GVariant *key_value;
+       GVariant *key_value= NULL;
        companion_group_t *group = NULL;
-       char *uri_path;
-       char *device_id;
-       char *group_name;
-       char *host_addr;
-       char *resource_type;
-       companion_group_type_e type;
+       char *uri_path = NULL;
+       char *device_id = NULL;
+       char *group_name = NULL;
+       char *host_addr = NULL;
+       char *resource_type = NULL;
+       companion_group_type_e type = COMPANION_GROUP_TYPE_ERROR;
 
        g_variant_get(va, "a{sv}", &iter);
        while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) {
@@ -209,10 +210,10 @@ static void __device_found_cb(Group *object,
 
        g_variant_get(va, "aa{sv}", &iter);
        while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
-               char *device_id;
-               char *ip;
-               char *device_type;
-               int port;
+               char *device_id = NULL;
+               char *ip = NULL;
+               char *device_type = NULL;
+               int port = -1;
 
                while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) {
                        if (g_strcmp0(key, "DeviceID") == 0) {
@@ -253,10 +254,10 @@ static void __mowned_device_found_cb(Group *object,
 
        g_variant_get(va, "aa{sv}", &iter);
        while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
-               char *device_id;
-               char *ip;
-               char *device_type;
-               int port;
+               char *device_id = NULL;
+               char *ip = NULL;
+               char *device_type = NULL;
+               int port = -1;
 
                while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) {
                        if (g_strcmp0(key, "DeviceID") == 0) {
@@ -442,7 +443,36 @@ int companion_group_create(char *group_name)
        return ret;
 }
 
-int companion_group_find(int timeout, companion_group_found_cb found_cb, companion_group_find_finish_cb finish_cb, void *user_data)
+void companion_group_destroy(companion_group_t *group)
+{
+       companion_check_null_ret("group", group);
+
+       if (group->uri_path) {
+               g_free(group->uri_path);
+               group->uri_path = NULL;
+       }
+       if (group->device_id) {
+               g_free(group->device_id);
+               group->device_id = NULL;
+       }
+       if (group->group_name) {
+               g_free(group->group_name);
+               group->group_name = NULL;
+       }
+       if (group->host_addr) {
+               g_free(group->host_addr);
+               group->host_addr = NULL;
+       }
+       if (group->resource_type) {
+               g_free(group->resource_type);
+               group->resource_type = NULL;
+       }
+       g_free(group);
+       group = NULL;
+}
+
+int companion_group_find(int timeout, companion_group_found_cb found_cb,
+       companion_group_find_finish_cb finish_cb, void *user_data)
 {
        int ret = 0;
        GError *error = NULL;
@@ -480,13 +510,15 @@ int companion_group_get_found_groups(companion_group_h **groups, int *count)
 
                g_variant_get(va, "aa{sv}", &iter);
                while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
+
+                       char *uri_path = NULL;
+                       char *device_id = NULL;
+                       char *group_name = NULL;
+                       char *host_addr = NULL;
+                       char *resource_type = NULL;
+
                        companion_group_t *group = NULL;
-                       companion_group_type_e type;
-                       char *uri_path;
-                       char *device_id;
-                       char *group_name;
-                       char *host_addr;
-                       char *resource_type;
+                       companion_group_type_e type = COMPANION_GROUP_TYPE_ERROR;
 
                        while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) {
                                if (g_strcmp0(key, "URI") == 0) {
@@ -717,11 +749,11 @@ int companion_device_get_my_device(companion_device_h *device)
        GVariant *va = NULL;
        GVariantIter *iter = NULL;
        const gchar *key;
-       GVariant *key_value;
-       char *deviceid;
-       char *addr;
-       char *ver;
-       int port;
+       GVariant *key_value = NULL;
+       char *deviceid = NULL;
+       char *addr = NULL;
+       char *ver = NULL;
+       int port = -1;
 
        group_call_get_my_mowned_device_sync(group_proxy, &va, NULL, &error);
 
@@ -747,6 +779,27 @@ int companion_device_get_my_device(companion_device_h *device)
 
        return ret;
 }
+
+static void companion_device_destroy(companion_device_t *device)
+{
+       companion_check_null_ret("device", device);
+
+       if (device->device_id) {
+               g_free(device->device_id);
+               device->device_id = NULL;
+       }
+       if (device->ip) {
+               g_free(device->ip);
+               device->ip = NULL;
+       }
+       if (device->device_type) {
+               g_free(device->device_type);
+               device->device_type = NULL;
+       }
+       g_free(device);
+       device = NULL;
+}
+
 int companion_device_get_my_uuid(char **uuid)
 {
        int ret = 0;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index ba1e306..cbbe801 100644 (file)
@@ -43,17 +43,18 @@ typedef enum {
 
 /* resource type enum */
 typedef enum {
-       COMP_RESOURCE_TYPE_GROUP = 0,
-       COMP_RESOURCE_TYPE_DEVICE,
-       COMP_RESOURCE_TYPE_OPERATION,
-       COMP_RESOURCE_TYPE_DATA,
+       COMP_RESOURCE_TYPE_GROUP = 0, /**< Group resource type  */
+       COMP_RESOURCE_TYPE_DEVICE, /**< Device resource type  */
+       COMP_RESOURCE_TYPE_OPERATION, /**< Operation resource type */
+       COMP_RESOURCE_TYPE_DATA, /**< Data resource type */
        COMP_RESOURCE_TYPE_MAX
 } comp_resource_type_e;
 
 /* group type enum */
 typedef enum {
-       COMP_GROUP_DEVICE = 0,
-       COMP_GROUP_REMOTE_DEVICE,
+       COMP_GROUP_GROUP_ERROR = 0, /**< Group type error */
+       COMP_GROUP_GROUP_LOCAL = 1, /**< Local group type */
+       COMP_GROUP_GROUP_REMOTE = 2, /**< Remote group type */
 } comp_group_type_e;
 
 /**
index 8523fd0..06a7b24 100644 (file)
@@ -81,7 +81,7 @@ int comp_group_add_new(char *uri_path, char *device_id, char *device_name,
 int comp_group_get_groups(comp_group_t ***handles, int *count); //Get all of group in my daemon
 int comp_group_get_remote_devices(/* callback */); //Get all of device in network (Async)
 
-void comp_group_add_new_mot_device(comp_mot_device_t *device);
+int comp_group_add_new_mot_device(comp_mot_device_t *device);
 void comp_group_notify_mot_enable_device_done();
 int comp_group_find_mot_enabled_devices(int timeout);
 
@@ -107,7 +107,7 @@ int comp_group_send_data(gchar *uuid_dev, gchar *addr, int port, gchar *data, in
 GVariant *comp_group_get_remote_mot_enabled_devices();
 int comp_group_get_mot_device_count();
 
-void comp_group_add_new_mowned_device(comp_mot_device_t *device);
+int comp_group_add_new_mowned_device(comp_mot_device_t *device);
 void comp_group_notify_mowned_device_find_done();
 int comp_group_find_mowned_devices();
 GVariant *comp_group_get_mowned_devices();
index 950b283..dfdccdf 100644 (file)
@@ -25,27 +25,27 @@ extern "C"
 {
 #endif
 
-#define SVR_PATH "/tmp/.svr.dat"
+#define SVR_PATH "/tmp/.svr.dat" /**< For Temp */
 
 typedef struct _iot_discovery_t {
-       gchar *uuid;
-       gchar *data;
-       gchar *host;
+       gchar *uuid; /**< Device Id */
+       gchar *data; /**< Data to send */
+       gchar *host; /**< Target host IP address + Port */
 } iot_discovery_t;
 
 typedef struct _comp_command_t {
-       int tid;
-       int resource_type;
-       comp_request_type_e command;
-       gchar *uuid;
-       gchar *host;
-       gchar *arg1;
+       int tid; /**< Timer ID */
+       int resource_type; /**< OCF resource type */
+       comp_request_type_e command; /**< Comments set for group management */
+       gchar *uuid; /**< Device UUID */
+       gchar *host; /**< Host address + Port */
+       gchar *arg1; /**< Arguement #1 */
 #ifdef SUPPORT_BASE64_ENCODING
-       int arg1_len;
+       int arg1_len; /**< Arguement #1 length */
 #endif
-       gchar *arg2;
-       gchar *arg3;
-       gchar *arg4;
+       gchar *arg2; /**< Arguement #2 */
+       gchar *arg3; /**< Arguement #3 */
+       gchar *arg4; /**< Arguement #4 */
 } comp_command_t;
 
 int comp_iot_initialize();
index 8fd95e1..1a72d9f 100644 (file)
                LOGD(COLOR_BLUE "END <<<<"COLOR_END); \
        } while (0)
 
+#define NOTUSED(var) (var = var)
+
+#define comp_check_null_ret_error(name, value, error) do { \
+       /* LCOV_EXCL_START */ \
+       if (G_UNLIKELY(NULL == (value))) { \
+                               LOGE("%s is NULL", name); \
+                               return error; \
+                       } \
+       /* LCOV_EXCL_STOP */ \
+} while (FALSE)
+
+#define comp_check_null_ret(name, value) do { \
+       /* LCOV_EXCL_START */ \
+       if (G_UNLIKELY(NULL == (value))) { \
+                               LOGE("%s is NULL", name); \
+                               return; \
+                       } \
+       /* LCOV_EXCL_STOP */ \
+} while (FALSE)
+
 const char *comp_log_get_error_string(int result);
 
 #endif
index 2ff2195..27e1da4 100644 (file)
@@ -174,6 +174,7 @@ gboolean enabler_disable(Enabler *enabler, GDBusMethodInvocation *invocation,
        LOG_DEBUG("disable called using dbus successful");
 
        comp_context_t *comp_ctx = comp_context_get_context();
+       comp_check_null_ret_error("comp_ctx", comp_ctx, TRUE);
 
        enabler_complete_disable(enabler, invocation, 0);
 
index 27c0cb2..18dc9f8 100644 (file)
@@ -34,8 +34,8 @@ int comp_group_initialize()
 }
 
 typedef struct {
-       char *name; //group name
-       GList *device_list; //remote device UUIDs. char* type
+       char *name; /**< Group name */
+       GList *device_list; /**< Remote device UUIDs. (char* type) */
 } comp_grp_t;
 
 void __print_foreach_device(gpointer data, gpointer user_data)
@@ -56,6 +56,8 @@ void __print_foreach_grp(gpointer data, gpointer user_data)
 void __print_groups_information()
 {
        comp_context_t *comp_ctx = comp_context_get_context();
+       comp_check_null_ret("comp_ctx", comp_ctx);
+
        LOG_DEBUG("-------------------------------------------");
        g_list_foreach(comp_ctx->grp_list, __print_foreach_grp, NULL);
        LOG_DEBUG("-------------------------------------------");
@@ -68,13 +70,13 @@ int comp_group_create(char* name)
 
        LOG_BEGIN();
 
-
        ret = comp_iot_add_resource(COMP_RESOURCE_TYPE_GROUP, name);
        if (ret != COMP_ERROR_NONE) {
                LOG_ERR("Add resource is failed : %s", comp_log_get_error_string(ret));
        }
 
        comp_context_t *comp_ctx = comp_context_get_context();
+       comp_check_null_ret_error("comp_ctx", comp_ctx, COMP_ERROR_INVALID_PARAMETER);
        GList *list = comp_ctx->grp_list;
 
        GList *l;
@@ -107,44 +109,69 @@ int comp_group_destroy(comp_group_t *handle)
        return ret;
 }
 
-void _free_func (gpointer data)
+static void _free_device_func(gpointer data)
 {
-       comp_group_t *group = (comp_group_t *)data;
+       comp_check_null_ret("data", data);
+       g_free(data);
+       data = NULL;
+}
 
-       if (group != NULL) {
-               if (group->uri_path != NULL)
-                       g_free(group->uri_path);
-               if (group->device_id != NULL)
-                       g_free(group->device_id);
-               if (group->group_name != NULL)
-                       g_free(group->group_name);
-               if (group->host_addr != NULL)
-                       g_free(group->host_addr);
-               if (group->resource_type != NULL)
-                       g_free(group->resource_type);
+static void _free_group_func(gpointer data)
+{
+       comp_group_t *group = (comp_group_t *)data;
+       comp_check_null_ret("group", group);
 
-               g_free(group);
+       if (group->uri_path != NULL) {
+               g_free(group->uri_path);
+               group->uri_path = NULL;
        }
+       if (group->device_id != NULL) {
+               g_free(group->device_id);
+               group->device_id = NULL;
+       }
+       if (group->group_name != NULL) {
+               g_free(group->group_name);
+               group->group_name = NULL;
+       }
+       if (group->host_addr != NULL) {
+               g_free(group->host_addr);
+               group->host_addr = NULL;
+       }
+       if (group->resource_type != NULL) {
+               g_free(group->resource_type);
+               group->resource_type = NULL;
+       }
+       g_free(group);
+       group = NULL;
 }
 
-void _mot_enb_dev_list_free_func(gpointer data)
+static void _mot_enb_dev_list_free_func(gpointer data)
 {
        comp_mot_device_t *device = (comp_mot_device_t *)data;
+       comp_check_null_ret("device", device);
 
-       if (device != NULL) {
-               if (device->device_id != NULL)
-                       g_free(device->device_id);
-               if (device->addr != NULL)
-                       g_free(device->addr);
-               if (device->route_data != NULL)
-                       g_free(device->route_data);
-               if (device->remote_id != NULL)
-                       g_free(device->remote_id);
-               if (device->sec_ver != NULL)
-                       g_free(device->sec_ver);
-
-               g_free(device);
+       if (device->device_id != NULL) {
+               g_free(device->device_id);
+               device->device_id = NULL;
        }
+       if (device->addr != NULL) {
+               g_free(device->addr);
+               device->addr = NULL;
+       }
+       if (device->route_data != NULL) {
+               g_free(device->route_data);
+               device->route_data = NULL;
+       }
+       if (device->remote_id != NULL) {
+               g_free(device->remote_id);
+               device->remote_id = NULL;
+       }
+       if (device->sec_ver != NULL) {
+               g_free(device->sec_ver);
+               device->sec_ver = NULL;
+       }
+       g_free(device);
+       device = NULL;
 }
 
 int comp_group_find(int timeout)
@@ -154,20 +181,19 @@ int comp_group_find(int timeout)
        LOG_BEGIN();
 
        /* list freeing */
-       g_list_free_full (found_group_list, _free_func);
+       g_list_free_full(found_group_list, _free_group_func);
        found_group_list = NULL;
 
        comp_command_t *cmd = g_new0(comp_command_t, 1);
-
+       comp_check_null_ret_error("cmd", cmd, COMP_ERROR_INVALID_PARAMETER);
        ret = comp_iot_discovery_resource(COMP_RESOURCE_TYPE_GROUP, timeout, cmd);
        if (ret != COMP_ERROR_NONE) {
-               LOG_ERR("Failed to discover resource : %s",
-                                comp_log_get_error_string(ret));
+               LOG_ERR("Failed to discover resource : %s", comp_log_get_error_string(ret));
        }
 
        LOG_END();
 
-       return COMP_ERROR_NONE;
+       return ret;
 }
 
 GVariant *comp_group_get_found_groups()
@@ -202,6 +228,7 @@ GVariant *comp_group_get_found_groups()
        }
 
        group_data = g_variant_builder_end(&builder);
+       g_variant_builder_unref(&builder);
 
        return group_data;
 }
@@ -244,6 +271,8 @@ int comp_group_add_new(char *uri_path, char *device_id, char *device_name,
 
        notify_group_found(group_data);
 
+       g_variant_builder_unref(&builder);
+
        LOG_END();
 
        return COMP_ERROR_NONE;
@@ -252,7 +281,7 @@ int comp_group_add_new(char *uri_path, char *device_id, char *device_name,
 /* Join the remote devices in my daemon */
 
 // Find MOT enabled devices
-void comp_group_add_new_mot_device(comp_mot_device_t *device)
+int comp_group_add_new_mot_device(comp_mot_device_t *device)
 {
        GList *iter = NULL;
        gboolean is_exist = FALSE;
@@ -280,6 +309,8 @@ void comp_group_add_new_mot_device(comp_mot_device_t *device)
        }
 
        LOG_END();
+
+       return is_exist;
 }
 
 GVariant *comp_group_get_remote_mot_enabled_devices()
@@ -325,6 +356,7 @@ GVariant *comp_group_get_remote_mot_enabled_devices()
        }
 
        group_data = g_variant_builder_end(&builder);
+       g_variant_builder_unref(&builder);
 
        return group_data;
 }
@@ -410,6 +442,7 @@ void comp_group_notify_group_invite(int ret)
 int _is_pairwise_uuid(char *uuid)
 {
        comp_context_t *comp_ctx = comp_context_get_context();
+       comp_check_null_ret_error("comp_ctx", comp_ctx, -1);
 
        GList *iter = NULL;
 
@@ -429,6 +462,7 @@ int _is_pairwise_uuid(char *uuid)
 int comp_group_add_device_in_group(char *group_name, char *uuid)
 {
        comp_context_t *comp_ctx = comp_context_get_context();
+       comp_check_null_ret_error("comp_ctx", comp_ctx, -1);
 
        GList *iter = NULL;
 
@@ -464,7 +498,7 @@ int comp_group_invite(char *group_name, char *uuid, char *pin)
 
        LOG_BEGIN();
        comp_context_t *comp_ctx = comp_context_get_context();
-
+       comp_check_null_ret_error("comp_ctx", comp_ctx, COMP_ERROR_INVALID_PARAMETER);
 
 #ifdef INVITE_EJECT_DEVICE_BY_MULTI_RUN
        /*
@@ -518,6 +552,36 @@ void comp_group_notify_group_dismiss(int result)
        notify_group_device_eject_result(result);
 }
 
+int comp_group_remove_device_in_group(char *uuid)
+{
+       comp_context_t *comp_ctx = comp_context_get_context();
+       comp_check_null_ret_error("comp_ctx", comp_ctx, -1);
+
+       GList *iter = NULL;
+
+       /* Find the device at every group in list */
+       iter = comp_ctx->grp_list;
+       while (iter != NULL) {
+               comp_grp_t *group = (comp_grp_t *)iter->data;
+
+               /* Find the device in devices list */
+               GList *device_iter = group->device_list;
+               while (device_iter != NULL) {
+                       char *device_uuid = (char *)device_iter->data;
+                       /* Lastly, we find the device in the group */
+                       if (strcmp(device_uuid, uuid) == 0) {
+                               /* Remove device id in devices list */
+                               g_list_free_full(group->device_list, _free_device_func);
+                       }
+                       device_iter = g_list_next(device_iter);
+               }
+               iter = g_list_next(iter);
+       }
+       __print_groups_information();
+
+       return 0;
+}
+
 //dismiss from group (async)
 int comp_group_dismiss(gchar *uuid_dev1, gchar *uuid_dev2)
 {
@@ -534,6 +598,7 @@ int comp_group_dismiss(gchar *uuid_dev1, gchar *uuid_dev2)
 #else
        ret = agent_unpair(uuid_dev1, uuid_dev2);
 #endif
+       comp_group_remove_device_in_group(uuid_dev2);
 
        LOG_END();
 
@@ -619,7 +684,7 @@ int comp_group_send_data(gchar *uuid_dev, gchar *addr, int port, gchar *data,
        return ret;
 }
 
-void comp_group_add_new_mowned_device(comp_mot_device_t *device)
+int  comp_group_add_new_mowned_device(comp_mot_device_t *device)
 {
        GList *iter = NULL;
        gboolean is_exist = FALSE;
@@ -647,6 +712,8 @@ void comp_group_add_new_mowned_device(comp_mot_device_t *device)
        }
 
        LOG_END();
+
+       return is_exist;
 }
 
 GVariant *comp_group_get_mowned_devices()
@@ -692,6 +759,7 @@ GVariant *comp_group_get_mowned_devices()
        }
 
        group_data = g_variant_builder_end(&builder);
+       g_variant_builder_unref(&builder);
 
        return group_data;
 }
@@ -740,6 +808,7 @@ GVariant *comp_group_get_my_mowned_devices()
        }
 
        group_data = g_variant_builder_end(&builder);
+       g_variant_builder_unref(&builder);
 
        return group_data;
 }
index 7ccc4e2..6e417b2 100644 (file)
@@ -151,6 +151,32 @@ int __comp_iot_get_platform_info(OCPlatformInfo *platform_info)
        return 0;
 }
 
+static void _clean_platform_info(OCPlatformInfo *platform_info)
+{
+       comp_check_null_ret("platform_info", platform_info);
+
+       if (platform_info->platformID) {
+               free(platform_info->platformID);
+               platform_info->platformID = NULL;
+       }
+       if (platform_info->manufacturerName) {
+               free(platform_info->manufacturerName);
+               platform_info->manufacturerName = NULL;
+       }
+       if (platform_info->modelNumber) {
+               free(platform_info->modelNumber);
+               platform_info->modelNumber = NULL;
+       }
+       if (platform_info->platformVersion) {
+               free(platform_info->platformVersion);
+               platform_info->platformVersion = NULL;
+       }
+       if (platform_info->firmwareVersion) {
+               free(platform_info->firmwareVersion);
+               platform_info->firmwareVersion = NULL;
+       }
+}
+
 int comp_iot_initialize()
 {
        char *device_id = NULL;
@@ -174,17 +200,12 @@ int comp_iot_initialize()
        OCPlatform::Configure(cfg);
 
        ret = __comp_iot_get_platform_info(&platform_info);
+       _clean_platform_info(&platform_info);
        if (ret != 0) {
                LOG_ERR("Failed to get platform info %d", ret);
                return COMP_ERROR_NONE;
        }
 
-       free(platform_info.platformID);
-       free(platform_info.manufacturerName);
-       free(platform_info.modelNumber);
-       free(platform_info.platformVersion);
-       free(platform_info.firmwareVersion);
-
        ret = OCPlatform::registerPlatformInfo(platform_info);
 
        if (ret != OC_STACK_OK)
@@ -228,6 +249,8 @@ int comp_iot_initialize()
        LOG_DEBUG("device_id : %s", device_id);
 
        comp_context_t *comp_ctx = comp_context_get_context();
+       comp_check_null_ret_error("comp_ctx", comp_ctx, COMP_ERROR_INVALID_PARAMETER);
+
        comp_ctx->device_uuid = g_strdup(device_id);
 
        /* Do Self-Ownership Transfer */
@@ -570,9 +593,9 @@ static bool _found_resource(std::shared_ptr<OCResource> resource)
                        if (g_strcmp0(resource_type, "core.comp.group") == 0) {
                                comp_context_t *comp_ctx = comp_context_get_context();
                                if (g_strcmp0(resource_device_id, comp_ctx->device_uuid) == 0)
-                                       group_type = COMP_GROUP_DEVICE;
+                                       group_type = COMP_GROUP_GROUP_LOCAL;
                                else
-                                       group_type = COMP_GROUP_REMOTE_DEVICE;
+                                       group_type = COMP_GROUP_GROUP_REMOTE;
 
                                char *temp = g_strdup(resource_uri_path);
                                char *ptr = strtok(temp, "/");
@@ -612,7 +635,7 @@ static bool _found_resource(std::shared_ptr<OCResource> resource)
        char *resource_device_id;
        char *resource_host;
        char *resource_type;
-       comp_group_type_e group_type;
+       comp_group_type_e group_type = COMP_GROUP_GROUP_ERROR;
 
        /* Callback: When no more resource available.
           As timeout is configured by IOTCON Library*/
@@ -662,15 +685,18 @@ static bool _found_resource(std::shared_ptr<OCResource> resource)
 
        if (strcmp(resource_type, "core.comp.group") == 0) {
                comp_context_t *comp_ctx = comp_context_get_context();
+               comp_check_null_ret_error("comp_ctx", comp_ctx, IOTCON_FUNC_CONTINUE);
+
                if (strcmp(resource_device_id, comp_ctx->device_uuid) == 0)
-                       group_type = COMP_GROUP_DEVICE;
+                       group_type = COMP_GROUP_GROUP_LOCAL;
                else
-                       group_type = COMP_GROUP_REMOTE_DEVICE;
+                       group_type = COMP_GROUP_GROUP_REMOTE;
 
+               char *sp = NULL;
                char *temp = strdup(resource_uri_path);
-               char *ptr = strtok(temp, "/");
-               ptr = strtok(NULL, "/");
-               ptr = strtok(NULL, "/");
+               char *ptr = strtok_r(temp, "/", &sp);
+               ptr = strtok_r(NULL, "/", &sp);
+               ptr = strtok_r(NULL, "/", &sp);
 
                LOG_DEBUG("group name is %s", ptr);
                comp_group_add_new(resource_uri_path, resource_device_id,
@@ -678,6 +704,10 @@ static bool _found_resource(std::shared_ptr<OCResource> resource)
                found_group_count++;
 
                g_free(resource_type);
+               if (temp) {
+                       free(temp);
+                       temp = NULL;
+               }
 
                return IOTCON_FUNC_CONTINUE;
        } else if (strcmp(resource_type, "core.comp.data") == 0) {
@@ -798,12 +828,13 @@ static gboolean _timeout_cb(gpointer data)
 }
 
 int comp_iot_discovery_resource(comp_resource_type_e resource_type, int timeout,
-                                                               void *user_data)
+       void *user_data)
 {
        int ret;
        iotcon_query_h query;
-       comp_command_t *cmd = (comp_command_t *) user_data;
        std::ostringstream requestURI;
+       comp_command_t *cmd = (comp_command_t *) user_data;
+       comp_check_null_ret_error("cmd", cmd, COMP_ERROR_INVALID_PARAMETER);
 
        found_group_count = 0;
 
@@ -850,7 +881,7 @@ int comp_iot_discovery_resource(comp_resource_type_e resource_type, int timeout,
                LOG_ERR("iotcon_set_timeout: Failed %s", get_error_message(ret));
        }
 
-       if (cmd && (cmd->command == COMP_REQ_SEND_DATA_ALL))
+       if (cmd->command == COMP_REQ_SEND_DATA_ALL)
                ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS,
                        IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP,
                        query, _found_resource, user_data);
index 5d1f261..435bb4c 100644 (file)
@@ -65,6 +65,8 @@ int main(int argc, char *argv[])
 
        //8. g main loop run
        comp_context_t *comp_ctx = comp_context_get_context();
+       comp_check_null_ret_error("comp_ctx", comp_ctx, COMP_ERROR_INVALID_PARAMETER);
+
        comp_ctx->main_loop = g_main_loop_new(NULL, FALSE);
        g_main_loop_run(comp_ctx->main_loop);
 
index a7e4181..13ee7ed 100644 (file)
@@ -537,6 +537,8 @@ static gboolean __perform_mot_me(gpointer data)
 {
        int ret;
        comp_context_t *comp_ctx = comp_context_get_context();
+       comp_check_null_ret_error("comp_ctx", comp_ctx, FALSE);
+
        ret = agent_mot(comp_ctx->device_uuid, "12341234");
        if (ret != COMP_ERROR_NONE) {
                LOG_ERR("agent_mot(%s) Failed", comp_ctx->device_uuid);
@@ -545,6 +547,35 @@ static gboolean __perform_mot_me(gpointer data)
        return FALSE;
 }
 
+static void _free_device_info(comp_mot_device_t *device) {
+
+       if (!device)
+               return;
+
+       if (device->device_id != NULL) {
+               g_free(device->device_id);
+               device->device_id = NULL;
+       }
+       if (device->addr != NULL) {
+               g_free(device->addr);
+               device->addr = NULL;
+       }
+       if (device->route_data != NULL) {
+               g_free(device->route_data);
+               device->route_data = NULL;
+       }
+       if (device->remote_id != NULL) {
+               g_free(device->remote_id);
+               device->remote_id = NULL;
+       }
+       if (device->sec_ver != NULL) {
+               g_free(device->sec_ver);
+               device->sec_ver = NULL;
+       }
+       g_free(device);
+       device = NULL;
+}
+
 static void _agent_signal_handler(GDBusConnection *connection,
                const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
                const gchar *signal_name, GVariant *parameters, gpointer userdata)
@@ -571,12 +602,15 @@ static void _agent_signal_handler(GDBusConnection *connection,
                gsize len = 0;
                int mot_enb_devs_cnt = 0;
                comp_mot_device_t *device;
+
                comp_context_t *comp_ctx = comp_context_get_context();
+               comp_check_null_ret("comp_ctx", comp_ctx);
 
                if (NULL == parameters) {
                        LOG_ERR("No MOT enabled devices found");
                        return;
                }
+
                g_variant_get(parameters, "(aa{sv})", &iter);
                while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
                        device = g_try_malloc0(sizeof(comp_mot_device_t));
@@ -649,13 +683,18 @@ static void _agent_signal_handler(GDBusConnection *connection,
                        g_variant_iter_free(iter_row);
 
                        if (strcmp(device->device_id, comp_ctx->device_uuid) != 0) {
-                               mot_enb_devs_cnt += 1;
-                               comp_group_add_new_mot_device(device);
-                               } else {
-                                       LOG_DEBUG("It is my mowned device. Store the mowned device"
-                                                         " in daemon");
-                                       comp_group_change_mowned_device(device);
+
+                               /* Is new device */
+                               if (FALSE == comp_group_add_new_mot_device(device)) {
+                                       mot_enb_devs_cnt += 1;
+                               } else  {
+                                       /* We have this device already */
+                                       _free_device_info(device);
                                }
+                       } else {
+                               LOG_DEBUG("It is my mowned device. Store the mowned device in daemon");
+                               comp_group_change_mowned_device(device);
+                       }
                }
                g_variant_iter_free(iter);
 
@@ -670,7 +709,7 @@ static void _agent_signal_handler(GDBusConnection *connection,
                GVariant *val;
                gsize len = 0;
                int mowned_devs_cnt = 0;
-               comp_mot_device_t *device;
+               comp_mot_device_t *device = NULL;
 
                if (NULL == parameters) {
                        LOG_ERR("No Multiple Owned devices found");
@@ -679,7 +718,9 @@ static void _agent_signal_handler(GDBusConnection *connection,
 
                g_variant_get(parameters, "(aa{sv})", &iter);
                while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
+
                        device = g_try_malloc0(sizeof(comp_mot_device_t));
+                       comp_check_null_ret("device", device);
 
                        while (g_variant_iter_loop(iter_row, "{sv}", &key, &val)) {
                                if (strcasecmp(key, "deviceId") == 0)  {
@@ -742,9 +783,17 @@ static void _agent_signal_handler(GDBusConnection *connection,
                        g_variant_iter_free(iter_row);
 
                        comp_context_t *comp_ctx = comp_context_get_context();
+                       comp_check_null_ret("comp_ctx", comp_ctx);
+
                        if (strcmp(device->device_id, comp_ctx->device_uuid) != 0) {
-                               mowned_devs_cnt += 1;
-                               comp_group_add_new_mowned_device(device);
+
+                               /* Is new device */
+                               if (FALSE == comp_group_add_new_mowned_device(device)) {
+                                       mowned_devs_cnt += 1;
+                               } else  {
+                                       /* We have this device already */
+                                       _free_device_info(device);
+                               }
                        } else {
                                LOG_DEBUG("It is my mowned device. Store the mowned device in daemon");
                                comp_group_change_mowned_device(device);
@@ -765,6 +814,7 @@ static void _agent_signal_handler(GDBusConnection *connection,
 #ifdef INVITE_EJECT_DEVICE_BY_MULTI_RUN
                comp_mot_device_t *device;
                comp_context_t *comp_ctx = comp_context_get_context();
+               comp_check_null_ret("comp_ctx", comp_ctx);
 
                g_variant_get(parameters, "(i)", &result);
                LOG_DEBUG("Result : %d", result);
index 171a2f7..16724a7 100644 (file)
@@ -72,10 +72,9 @@ void comp_resource_print_list()
        LOG_DEBUG("-------------------Print resource list-----------------------");
 
        for (int i = 0; i < COMP_RESOURCE_TYPE_MAX; i++) {
-               LOG_DEBUG("Resource type %d list length : %d", i,
-                                 g_list_length(comp_ctx->resource_list[i]));
-               g_list_foreach(comp_ctx->resource_list[i], __print_foreach_resource,
-                                          NULL);
+               LOG_DEBUG("Resource type %d list length : %d",
+                       i, g_list_length(comp_ctx->resource_list[i]));
+               g_list_foreach(comp_ctx->resource_list[i], __print_foreach_resource, NULL);
        }
 
        LOG_DEBUG("-------------------Print resource list end-------------------");
index edc8713..7116fbb 100644 (file)
@@ -1,18 +1,18 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+/*\r
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
  */\r
 \r
 #ifndef __MA_LOG_H__\r
index 694daf9..a3ba916 100644 (file)
@@ -1,18 +1,18 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+/*\r
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
  */\r
 #include <glib.h>\r
 \r
index 79b332c..8ef73c6 100644 (file)
@@ -1,18 +1,18 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+/*\r
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
  */\r
 \r
 #ifndef __MA_SERVICE_INTERFACE_H__\r
index ff50d37..aa11aa2 100644 (file)
@@ -1,18 +1,18 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+/*\r
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
  */\r
 \r
 #include <glib.h>\r
index 172b04c..14b73f5 100644 (file)
@@ -1,18 +1,18 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+/*\r
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
  */\r
 \r
 #ifndef __MA_SERVICE_H__\r
index 73fadda..fca0b62 100644 (file)
 } while (FALSE)
 
 const char* ma_ocf_error_to_string(OCStackResult err);
-
 const char* ma_wifi_error_to_string(wifi_manager_error_e err);
 OicUuid_t* ma_convert_uuid(gchar *device_id);
-
 char * ma_get_readable_uuid(const OicUuid_t* uuid);
 #ifdef TEST
 OCProvisionDev_t* ma_get_dev_by_id(const OCProvisionDev_t* dev_lst, const int dev_num);
 #endif
-
 OCProvisionDev_t* ma_get_dev_by_uuid(const OCProvisionDev_t* dev_lst,
        const OicUuid_t* uuid);
-
 int ma_print_dev_list(const OCProvisionDev_t* dev_lst);
-
 int ma_print_result_list(const OCProvisionResult_t* rslt_lst, const int rslt_cnt);
-
 int ma_set_device_id_seed(void);
 
 #if 0
index e3078e4..fbdf41a 100644 (file)
@@ -1,18 +1,18 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+/*\r
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
  */\r
 \r
 #ifndef __MA_AGENT_H__\r