From: saerome.kim Date: Mon, 26 Mar 2018 02:34:10 +0000 (+0900) Subject: d2d-manager: fix Tizen coding rules X-Git-Tag: submit/tizen/20190131.065036~84 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6b8c65fefaf43815ffde1fdd588dec2b82430901;p=platform%2Fcore%2Fapi%2Fmulti-device-group.git d2d-manager: fix Tizen coding rules Signed-off-by: saerome.kim --- diff --git a/capi/demo/comp-manager.c b/capi/demo/comp-manager.c index 2cc9d8c..629dd35 100644 --- a/capi/demo/comp-manager.c +++ b/capi/demo/comp-manager.c @@ -94,7 +94,7 @@ int run_get_my_id(MManager *mm, struct menu_data *menu) void _device_eject_result_cb(int result, void *user_data) { - msgb("\rEject Device Complete [%s]", comp_error_to_string(result) ); + msgb("\rEject Device Complete [%s]", comp_error_to_string(result)); } static int run_device_eject(MManager *mm, struct menu_data *menu) @@ -141,7 +141,7 @@ static int run_device_eject(MManager *mm, struct menu_data *menu) return RET_FAILURE; } - ret = companion_device_eject(group, device, _device_eject_result_cb, NULL ); + ret = companion_device_eject(group, device, _device_eject_result_cb, NULL); if (COMP_ERROR_NONE != ret) { msgr("Failed to Delete Group: [%s(0x%X)]", comp_error_to_string(ret), ret); return RET_FAILURE; @@ -153,7 +153,7 @@ static int run_device_eject(MManager *mm, struct menu_data *menu) void _device_invite_result_cb(int result, void *user_data) { - msgb("\rInvite Device Finished [%s]", comp_error_to_string(result) ); + msgb("\rInvite Device Finished [%s]", comp_error_to_string(result)); } static int run_device_invite(MManager *mm, struct menu_data *menu) @@ -262,7 +262,7 @@ static int run_devices_show(MManager *mm, struct menu_data *menu) deviceid = NULL; } if (ip) { - free(ip ); + free(ip); ip = NULL; } if (devicetype) { @@ -475,7 +475,7 @@ bool _device_found_cb(companion_device_h device, void *user_data) iter = found_device_list; while (iter != NULL) { - companion_device_h temp = (companion_device_h ) iter->data; + companion_device_h temp = (companion_device_h)iter->data; char *temp_device_id; companion_device_information_get_device_id(temp, &temp_device_id); @@ -795,9 +795,8 @@ static int run_group_create(MManager *mm, struct menu_data *menu) void _send_data_finish_cb(int result, char *resp_data, void *user_data) { msgb("\rFind Send Data Finished = %d", result); - if (resp_data != NULL && strlen(resp_data) > 0) { + if (resp_data != NULL && strlen(resp_data) > 0) msgp("Response from %s", resp_data); - } } static int __send_data(int idx) @@ -820,17 +819,16 @@ static int __send_data(int idx) msgp("Sent to [ID] %s [IP] %s", deviceid, address); if (deviceid) { free(deviceid); - deviceid= NULL; + deviceid = NULL; } if (address) { free(address); - address= NULL; + address = NULL; } ret = companion_send_data(device, message, strlen(message), _send_data_finish_cb, NULL); - if (COMP_ERROR_NONE != ret) { + if (COMP_ERROR_NONE != ret) msgr("Failed to Send Data: [ID] %s [IP] %s", deviceid, address); - } return ret; } @@ -840,7 +838,7 @@ static int run_send_data(MManager *mm, struct menu_data *menu) int idx = 0; int count = g_list_length(found_device_list); - if (0 >= count ) { + if (0 >= count) { msgr("No Device"); return RET_SUCCESS; } @@ -861,7 +859,7 @@ static int run_send_data_all(MManager *mm, struct menu_data *menu) count = g_list_length(found_device_list); - if (0 >= count ) { + if (0 >= count) { msgr("No Device"); return RET_SUCCESS; } diff --git a/capi/demo/companion_demo.c b/capi/demo/companion_demo.c index 826e754..9f5df94 100644 --- a/capi/demo/companion_demo.c +++ b/capi/demo/companion_demo.c @@ -140,7 +140,6 @@ bool _group_found_cb(companion_group_type_e type, companion_group_h group, void void _group_finish_cb(int result, void *user_data) { TC_PRT("find operation finished"); - } int companion_group_find_test(void) @@ -152,8 +151,7 @@ int companion_group_find_test(void) found_group_list = NULL; if (!test_get_user_int("==> Input timeout value (sec)" - " - (Enter for skip) :", &input_int)) - { + " - (Enter for skip) :", &input_int)) { input_int = 5; TC_PRT("default timeout value [%d]", input_int); } @@ -225,8 +223,7 @@ int companion_device_find_test(void) found_device_list = NULL; if (!test_get_user_int("==> Input timeout value (sec)" - " - (Enter for skip) :", &input_int)) - { + " - (Enter for skip) :", &input_int)) { input_int = 5; TC_PRT("default timeout value [%d]", input_int); } @@ -252,7 +249,7 @@ int companion_device_get_found_devices_test(void) found_device_list = NULL; - ret = companion_device_get_found_devices(&devices ,&count); + ret = companion_device_get_found_devices(&devices, &count); if (ret == 0) TC_PRT("device find successful"); diff --git a/capi/include/companion.h b/capi/include/companion.h index c946c72..4da28b7 100644 --- a/capi/include/companion.h +++ b/capi/include/companion.h @@ -1116,4 +1116,4 @@ int companion_request_result_callback(companion_request_result_cb callback, } #endif -#endif /* __TIZEN_NETWORK_COMMON_COMPANION_H__ */ \ No newline at end of file +#endif /* __TIZEN_NETWORK_COMMON_COMPANION_H__ */ diff --git a/capi/include/companion_debug.h b/capi/include/companion_debug.h index 4e438c0..10f10dc 100644 --- a/capi/include/companion_debug.h +++ b/capi/include/companion_debug.h @@ -106,4 +106,4 @@ #define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args) #define TC_PRT(format, args...) PRT(format"\n", ##args) -#endif /* __TIZEN_NETWORK_COMMON_COMPANION_DEBUG_H__ */ \ No newline at end of file +#endif /* __TIZEN_NETWORK_COMMON_COMPANION_DEBUG_H__ */ diff --git a/capi/src/companion.c b/capi/src/companion.c index 55002d6..1e6c0ae 100644 --- a/capi/src/companion.c +++ b/capi/src/companion.c @@ -52,8 +52,7 @@ Enabler *enabler_proxy = NULL; /**< Enbler proxy */ int ref_count = 0; bool __is_initialized = false; -typedef struct _companion_group_t -{ +typedef struct _companion_group_t { char *uri_path; char *device_id; char *group_name; @@ -62,8 +61,7 @@ typedef struct _companion_group_t companion_group_type_e type; } companion_group_t; -typedef struct _companion_device_t -{ +typedef struct _companion_device_t { char *device_id; char *ip; char *device_type; @@ -71,62 +69,62 @@ typedef struct _companion_device_t } companion_device_t; typedef struct _group_found_cb_t { - companion_group_found_cb found_cb; - void *user_data; + companion_group_found_cb found_cb; + void *user_data; } group_found_cb_t; group_found_cb_t group_found_cb; typedef struct _device_found_cb_t { - companion_device_found_cb found_cb; - void *user_data; + companion_device_found_cb found_cb; + void *user_data; } device_found_cb_t; device_found_cb_t device_found_cb; typedef struct _group_find_finish_cb_t { - companion_group_find_finish_cb finish_cb; - void *user_data; + companion_group_find_finish_cb finish_cb; + void *user_data; } group_find_finish_cb_t; group_find_finish_cb_t group_find_finish_cb; typedef struct _device_find_finish_cb_t { - companion_device_find_finish_cb finish_cb; - void *user_data; + companion_device_find_finish_cb finish_cb; + void *user_data; } device_find_finish_cb_t; device_find_finish_cb_t device_find_finish_cb; typedef struct _mowned_device_found_cb_t { - companion_device_found_cb found_cb; - void *user_data; + companion_device_found_cb found_cb; + void *user_data; } mowned_device_found_cb_t; mowned_device_found_cb_t mowned_device_found_cb; typedef struct _mowned_device_find_finish_cb_t { - companion_device_find_finish_cb finish_cb; - void *user_data; + companion_device_find_finish_cb finish_cb; + void *user_data; } mowned_device_find_finish_cb_t; mowned_device_find_finish_cb_t mowned_device_find_finish_cb; typedef struct _device_invite_result_cb_t { - companion_device_invite_result_cb result_cb; - void *user_data; + companion_device_invite_result_cb result_cb; + void *user_data; } device_invite_result_cb_t; device_invite_result_cb_t device_invite_result_cb; typedef struct _device_eject_result_cb_t { - companion_device_eject_result_cb result_cb; - void *user_data; + companion_device_eject_result_cb result_cb; + void *user_data; } device_eject_result_cb_t; device_eject_result_cb_t device_eject_result_cb; typedef struct _send_data_finish_cb_t { - companion_send_data_finish_cb finish_cb; - void *user_data; + companion_send_data_finish_cb finish_cb; + void *user_data; } send_data_finish_cb_t; send_data_finish_cb_t send_data_finish_cb; typedef struct _request_result_cb_t { - companion_request_result_cb result_cb; - void *user_data; + companion_request_result_cb result_cb; + void *user_data; } request_result_cb_t; request_result_cb_t request_result_cb; @@ -158,12 +156,11 @@ static companion_device_t *_create_device_handle(char *device_id, char *ip, return device; } -static void __group_found_cb(Group *object, - GVariant *va, gpointer user_data) +static void __group_found_cb(Group *object, GVariant *va, gpointer user_data) { GVariantIter *iter = NULL; const gchar *key; - GVariant *key_value= NULL; + GVariant *key_value = NULL; companion_group_t *group = NULL; char *uri_path = NULL; char *device_id = NULL; @@ -174,19 +171,18 @@ static void __group_found_cb(Group *object, g_variant_get(va, "a{sv}", &iter); while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "URI") == 0) { + if (g_strcmp0(key, "URI") == 0) uri_path = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "DeviceID") == 0) { + else if (g_strcmp0(key, "DeviceID") == 0) device_id = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "GroupName") == 0) { + else if (g_strcmp0(key, "GroupName") == 0) group_name = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "HostAddress") == 0) { + else if (g_strcmp0(key, "HostAddress") == 0) host_addr = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "GroupDeviceType") == 0) { + else if (g_strcmp0(key, "GroupDeviceType") == 0) resource_type = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "GroupType") == 0) { + else if (g_strcmp0(key, "GroupType") == 0) type = g_variant_get_int32(key_value); - } } g_variant_iter_free(iter); @@ -197,15 +193,14 @@ static void __group_found_cb(Group *object, group_found_cb.found_cb(type, group, group_found_cb.user_data); } -static void _group_find_finish_cb(Group *object, - gint ret, gpointer user_data) +static void _group_find_finish_cb(Group *object, gint ret, gpointer user_data) { if (group_find_finish_cb.finish_cb) group_find_finish_cb.finish_cb(ret, group_find_finish_cb.user_data); } -static void __device_found_cb(Group *object, - gint count, GVariant *va, gpointer user_data) +static void __device_found_cb(Group *object, gint count, GVariant *va, + gpointer user_data) { GVariantIter *iter = NULL; GVariantIter *iter_row = NULL; @@ -221,16 +216,14 @@ static void __device_found_cb(Group *object, int port = -1; while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "DeviceID") == 0) { + if (g_strcmp0(key, "DeviceID") == 0) device_id = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "Address") == 0) { + else if (g_strcmp0(key, "Address") == 0) ip = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "SecVer") == 0) { + else if (g_strcmp0(key, "SecVer") == 0) device_type = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "Port") == 0) { + else if (g_strcmp0(key, "Port") == 0) port = g_variant_get_uint16(key_value); - } - } g_variant_iter_free(iter_row); @@ -241,15 +234,14 @@ static void __device_found_cb(Group *object, g_variant_iter_free(iter); } -static void _device_find_finish_cb(Group *object, - gint ret, gpointer user_data) +static void _device_find_finish_cb(Group *object, gint ret, gpointer user_data) { if (device_find_finish_cb.finish_cb) device_find_finish_cb.finish_cb(ret, device_find_finish_cb.user_data); } -static void __mowned_device_found_cb(Group *object, - gint count, GVariant *va, gpointer user_data) +static void __mowned_device_found_cb(Group *object, gint count, GVariant *va, + gpointer user_data) { GVariantIter *iter = NULL; GVariantIter *iter_row = NULL; @@ -265,15 +257,14 @@ static void __mowned_device_found_cb(Group *object, int port = -1; while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "DeviceID") == 0) { + if (g_strcmp0(key, "DeviceID") == 0) device_id = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "Address") == 0) { + else if (g_strcmp0(key, "Address") == 0) ip = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "SecVer") == 0) { + else if (g_strcmp0(key, "SecVer") == 0) device_type = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "Port") == 0) { + else if (g_strcmp0(key, "Port") == 0) port = g_variant_get_uint16(key_value); - } } g_variant_iter_free(iter_row); @@ -285,36 +276,34 @@ static void __mowned_device_found_cb(Group *object, g_variant_iter_free(iter); } -static void _mowned_device_find_finish_cb(Group *object, - gint ret, gpointer user_data) +static void _mowned_device_find_finish_cb(Group *object, gint ret, + gpointer user_data) { if (mowned_device_find_finish_cb.finish_cb) mowned_device_find_finish_cb.finish_cb(ret, mowned_device_find_finish_cb.user_data); } -static void __device_invite_result_cb(Group *object, - gint ret, gpointer user_data) +static void __device_invite_result_cb(Group *object, gint ret, gpointer user_data) { - if(device_invite_result_cb.result_cb) + if (device_invite_result_cb.result_cb) device_invite_result_cb.result_cb(ret, device_invite_result_cb.user_data); } -static void __device_eject_result_cb(Group *object, - gint ret, gpointer user_data) +static void __device_eject_result_cb(Group *object, gint ret, gpointer user_data) { if (device_eject_result_cb.result_cb) device_eject_result_cb.result_cb(ret, device_eject_result_cb.user_data); } -static void __send_data_finish_cb(Group *object, - gchar *resp_data, gint ret, gpointer user_data) +static void __send_data_finish_cb(Group *object, gchar *resp_data, gint ret, + gpointer user_data) { if (send_data_finish_cb.finish_cb) send_data_finish_cb.finish_cb(ret, resp_data, send_data_finish_cb.user_data); } -static void __request_result_cb(Group *object, - gchar *cmd, gchar *arg, gint ret, gpointer user_data) +static void __request_result_cb(Group *object, gchar *cmd, gchar *arg, gint ret, + gpointer user_data) { if (request_result_cb.result_cb) request_result_cb.result_cb(cmd, arg, ret, request_result_cb.user_data); @@ -325,12 +314,12 @@ static void _group_proxy_init(void) GError *error = NULL; group_proxy = group_proxy_new_for_bus_sync( - G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_NONE, - COMP_DBUS_SERVICE, - COMP_DBUS_GROUP_PATH, - NULL, - &error); + G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + COMP_DBUS_SERVICE, + COMP_DBUS_GROUP_PATH, + NULL, + &error); g_signal_connect(group_proxy, "group-found", G_CALLBACK(__group_found_cb), NULL); @@ -537,19 +526,18 @@ EXPORT_API int companion_group_get_found_groups(companion_group_h **groups, 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) { + if (g_strcmp0(key, "URI") == 0) uri_path = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "DeviceID") == 0) { + else if (g_strcmp0(key, "DeviceID") == 0) device_id = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "GroupName") == 0) { + else if (g_strcmp0(key, "GroupName") == 0) group_name = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "HostAddress") == 0) { + else if (g_strcmp0(key, "HostAddress") == 0) host_addr = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "GroupDeviceType") == 0) { + else if (g_strcmp0(key, "GroupDeviceType") == 0) resource_type = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "GroupType") == 0) { + else if (g_strcmp0(key, "GroupType") == 0) type = g_variant_get_int32(key_value); - } } g_variant_iter_free(iter_row); @@ -614,7 +602,7 @@ EXPORT_API int companion_device_find_mowned_device(int timeout, mowned_device_found_cb.found_cb = found_cb; mowned_device_found_cb.user_data = user_data; - mowned_device_find_finish_cb.finish_cb= finish_cb; + mowned_device_find_finish_cb.finish_cb = finish_cb; mowned_device_find_finish_cb.user_data = user_data; /* get groups from daemon using gdbus */ @@ -685,15 +673,14 @@ EXPORT_API int companion_device_get_found_devices(companion_device_h **devices, companion_device_t *device = NULL; while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "DeviceID") == 0) { + if (g_strcmp0(key, "DeviceID") == 0) deviceid = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "Address") == 0) { + else if (g_strcmp0(key, "Address") == 0) addr = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "SecVer") == 0) { + else if (g_strcmp0(key, "SecVer") == 0) ver = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "Port") == 0) { + else if (g_strcmp0(key, "Port") == 0) port = g_variant_get_uint16(key_value); - } } g_variant_iter_free(iter_row); @@ -740,15 +727,14 @@ EXPORT_API int companion_device_get_found_mowned_devices( companion_device_t *device = NULL; while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "DeviceID") == 0) { + if (g_strcmp0(key, "DeviceID") == 0) deviceid = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "Address") == 0) { + else if (g_strcmp0(key, "Address") == 0) addr = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "SecVer") == 0) { + else if (g_strcmp0(key, "SecVer") == 0) ver = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "Port") == 0) { + else if (g_strcmp0(key, "Port") == 0) port = g_variant_get_uint16(key_value); - } } g_variant_iter_free(iter_row); @@ -780,15 +766,14 @@ EXPORT_API int companion_device_get_my_device(companion_device_h *device) g_variant_get(va, "a{sv}", &iter); while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "DeviceID") == 0) { + if (g_strcmp0(key, "DeviceID") == 0) deviceid = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "Address") == 0) { + else if (g_strcmp0(key, "Address") == 0) addr = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "SecVer") == 0) { + else if (g_strcmp0(key, "SecVer") == 0) ver = (char *)g_variant_get_string(key_value, NULL); - } else if (g_strcmp0(key, "Port") == 0) { + else if (g_strcmp0(key, "Port") == 0) port = g_variant_get_uint16(key_value); - } } if (deviceid == NULL || addr == NULL || ver == NULL) @@ -913,21 +898,16 @@ EXPORT_API int companion_group_information_clone(companion_group_h target, return -1; } - if (src->uri_path) { + if (src->uri_path) dst->uri_path = g_strdup(src->uri_path); - } - if (src->device_id) { + if (src->device_id) dst->device_id = g_strdup(src->device_id); - } - if (src->group_name) { + if (src->group_name) dst->group_name = g_strdup(src->group_name); - } - if (src->host_addr) { + if (src->host_addr) dst->host_addr = g_strdup(src->host_addr); - } - if (src->resource_type) { + if (src->resource_type) dst->resource_type = g_strdup(src->resource_type); - } dst->type = src->type; return 0; @@ -1025,15 +1005,12 @@ EXPORT_API int companion_device_information_clone(companion_device_h target, return -1; } - if (src->device_id) { + if (src->device_id) dst->device_id = g_strdup(src->device_id); - } - if (src->ip) { + if (src->ip) dst->ip = g_strdup(src->ip); - } - if (src->device_type) { + if (src->device_type) dst->device_type = g_strdup(src->device_type); - } return 0; } diff --git a/src/companion-manager/include/comp_context.h b/src/companion-manager/include/comp_context.h index 6772ce4..573edbd 100644 --- a/src/companion-manager/include/comp_context.h +++ b/src/companion-manager/include/comp_context.h @@ -53,4 +53,4 @@ comp_context_t *comp_context_get_context(); #ifdef __cplusplus } #endif -#endif /* __COMP_CONTEXT_H__ */ \ No newline at end of file +#endif /* __COMP_CONTEXT_H__ */ diff --git a/src/companion-manager/include/comp_enum.h b/src/companion-manager/include/comp_enum.h index 8416050..577766c 100644 --- a/src/companion-manager/include/comp_enum.h +++ b/src/companion-manager/include/comp_enum.h @@ -84,4 +84,4 @@ typedef enum { COMP_REQ_SEND_DATA_ALL, /**< Send data in subnet */ } comp_request_type_e; -#endif /* __COMP_ENUM_H__ */ \ No newline at end of file +#endif /* __COMP_ENUM_H__ */ diff --git a/src/companion-manager/include/comp_gdbus.h b/src/companion-manager/include/comp_gdbus.h index 029a859..77ac1ea 100644 --- a/src/companion-manager/include/comp_gdbus.h +++ b/src/companion-manager/include/comp_gdbus.h @@ -26,4 +26,4 @@ int comp_gdbus_init(); -#endif /* __COMP_GDBUS_H__ */ \ No newline at end of file +#endif /* __COMP_GDBUS_H__ */ diff --git a/src/companion-manager/include/comp_gdbus_group.h b/src/companion-manager/include/comp_gdbus_group.h index 0bb5757..c12b1e6 100644 --- a/src/companion-manager/include/comp_gdbus_group.h +++ b/src/companion-manager/include/comp_gdbus_group.h @@ -46,7 +46,7 @@ gboolean group_delete(Group *group, GDBusMethodInvocation *invocation, gpointer user_data); gboolean group_device_find(Group *group, GDBusMethodInvocation *invocation, - gint timeout ,gpointer user_data); + gint timeout, gpointer user_data); gboolean group_device_invite(Group *group, GDBusMethodInvocation *invocation, gchar *uuid_dev1, gchar *uuid_dev2, gchar *pin, gchar *uri_1, gchar *rt_1, @@ -92,14 +92,14 @@ gboolean group_get_my_uuid(Group *group, gboolean group_request_create_group(Group *group, GDBusMethodInvocation *invocation, gchar *uuid, gchar *group_name, gpointer user_data); -gboolean group_request_invite(Group *group, GDBusMethodInvocation *invocation, gchar *uuid, - gchar *group_name, gchar *target_uuid, gchar *PIN, gpointer user_data); +gboolean group_request_invite(Group *group, GDBusMethodInvocation *invocation, + gchar *uuid, gchar *group_name, gchar *target_uuid, gchar *PIN, gpointer user_data); -gboolean group_request_eject(Group *group, GDBusMethodInvocation *invocation, gchar *uuid, - gchar *group_name, gchar *target_uuid, gpointer user_data); +gboolean group_request_eject(Group *group, GDBusMethodInvocation *invocation, + gchar *uuid, gchar *group_name, gchar *target_uuid, gpointer user_data); gboolean group_request_delete_group(Group *group, GDBusMethodInvocation *invocation, - gchar *uuid, gchar *group_name, gpointer user_data); + gchar *uuid, gchar *group_name, gpointer user_data); void notify_group_found(GVariant *group_data); void notify_group_find_finish(int ret); @@ -116,4 +116,4 @@ void notify_request_result(const char *cmd, char *arg, int ret); #ifdef __cplusplus } #endif -#endif /* __COMP_GDBUS_GROUP_H__ */ \ No newline at end of file +#endif /* __COMP_GDBUS_GROUP_H__ */ diff --git a/src/companion-manager/include/comp_group.h b/src/companion-manager/include/comp_group.h index c1133f0..22d86ac 100644 --- a/src/companion-manager/include/comp_group.h +++ b/src/companion-manager/include/comp_group.h @@ -143,4 +143,4 @@ int comp_group_request_delete_group(char *uuid, char *group_name); #ifdef __cplusplus } #endif -#endif /* __COMP_GROUP_H__ */ \ No newline at end of file +#endif /* __COMP_GROUP_H__ */ diff --git a/src/companion-manager/include/comp_manager.h b/src/companion-manager/include/comp_manager.h index d22276c..50ae748 100644 --- a/src/companion-manager/include/comp_manager.h +++ b/src/companion-manager/include/comp_manager.h @@ -23,4 +23,4 @@ #include #include -#endif /* __COMP_MANAGER_H__ */ \ No newline at end of file +#endif /* __COMP_MANAGER_H__ */ diff --git a/src/companion-manager/include/comp_resource.h b/src/companion-manager/include/comp_resource.h index 3a20e23..e767838 100644 --- a/src/companion-manager/include/comp_resource.h +++ b/src/companion-manager/include/comp_resource.h @@ -46,4 +46,4 @@ void comp_resource_print_list(); #ifdef __cplusplus } #endif -#endif /* __COMP_RESOURCE_H__ */ \ No newline at end of file +#endif /* __COMP_RESOURCE_H__ */ diff --git a/src/companion-manager/src/comp_gdbus.c b/src/companion-manager/src/comp_gdbus.c index 1ba79df..5ed0468 100644 --- a/src/companion-manager/src/comp_gdbus.c +++ b/src/companion-manager/src/comp_gdbus.c @@ -222,9 +222,8 @@ static bool __enabler_init(GDBusConnection *connection) static void on_bus_acquired(GDBusConnection *connection, const gchar *path, gpointer user_data) { - if (__group_init(connection) == false) { + if (__group_init(connection) == false) LOG_DEBUG("Can not signal connect"); - } if (__enabler_init(connection) == false) LOG_ERR("Can't signal connect"); diff --git a/src/companion-manager/src/comp_group.c b/src/companion-manager/src/comp_group.c index 2c3bb04..e240ad4 100644 --- a/src/companion-manager/src/comp_group.c +++ b/src/companion-manager/src/comp_group.c @@ -71,9 +71,8 @@ int comp_group_create(const char* name) LOG_BEGIN(); ret = comp_iot_add_resource(COMP_RESOURCE_TYPE_GROUP, name); - if (ret != COMP_ERROR_NONE) { + 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); @@ -187,9 +186,8 @@ int comp_group_find(int timeout) 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) { + if (ret != COMP_ERROR_NONE) LOG_ERR("Failed to discover resource : %s", comp_log_get_error_string(ret)); - } LOG_END(); @@ -205,7 +203,7 @@ GVariant *comp_group_get_found_groups() g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}")); iter = found_group_list; - while(iter != NULL) { + while (iter != NULL) { comp_group_t *group = (comp_group_t *)iter->data; g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT); @@ -289,7 +287,7 @@ int comp_group_add_new_mot_device(comp_mot_device_t *device) LOG_BEGIN(); iter = mot_enb_dev_list; - while(iter != NULL) { + while (iter != NULL) { comp_mot_device_t *temp = (comp_mot_device_t *)iter->data; if (g_strcmp0(temp->device_id, device->device_id) == 0) { @@ -322,7 +320,7 @@ GVariant *comp_group_get_remote_mot_enabled_devices() g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}")); iter = mot_enb_dev_list; - while(iter != NULL) { + while (iter != NULL) { comp_mot_device_t *device = (comp_mot_device_t *)iter->data; g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT); @@ -509,13 +507,8 @@ int comp_group_invite(const char *group_name, const char *uuid, const char *pin) LOG_DEBUG("group name : %s, uuid : %s", group_name, uuid); if (_is_pairwise_uuid(uuid) < 0) { - /* - * 1. Perform MOT - * 2. Discover Mowned devices - * 3. Pairwise - */ - ret = agent_mot(uuid, pin); + ret = agent_mot(uuid, pin); if (ret == COMP_ERROR_NONE) { group_invite_info = g_try_malloc0(sizeof(comp_group_invite_info_t)); group_invite_info->uuid_dev1 = g_strdup(comp_ctx->device_uuid); @@ -694,7 +687,7 @@ int comp_group_add_new_mowned_device(comp_mot_device_t *device) LOG_BEGIN(); iter = mowned_dev_list; - while(iter != NULL) { + while (iter != NULL) { comp_mot_device_t *temp = (comp_mot_device_t *)iter->data; if (g_strcmp0(temp->device_id, device->device_id) == 0) { @@ -727,7 +720,7 @@ GVariant *comp_group_get_mowned_devices() g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}")); iter = mowned_dev_list; - while(iter != NULL) { + while (iter != NULL) { comp_mot_device_t *device = (comp_mot_device_t *)iter->data; g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT); diff --git a/src/companion-manager/src/comp_log.c b/src/companion-manager/src/comp_log.c index a0ae827..23346d0 100644 --- a/src/companion-manager/src/comp_log.c +++ b/src/companion-manager/src/comp_log.c @@ -17,7 +17,8 @@ #include -const char *comp_log_get_error_string(int result) { +const char *comp_log_get_error_string(int result) +{ switch (result) { case COMP_ERROR_NONE: return "COMP_ERROR_NONE"; diff --git a/src/companion-manager/src/comp_mot_agent.c b/src/companion-manager/src/comp_mot_agent.c index ed3a888..4ace0d7 100644 --- a/src/companion-manager/src/comp_mot_agent.c +++ b/src/companion-manager/src/comp_mot_agent.c @@ -421,7 +421,7 @@ static void _dbus_name_owner_notify(GObject *object, GParamSpec *pspec, LOG_DEBUG("Name owner notify [%s]", name_owner); if (NULL == name_owner) - _close_gdbus_call( ); + _close_gdbus_call(); g_free(name_owner); } @@ -538,15 +538,14 @@ static gboolean __perform_mot_me(gpointer data) comp_check_null_ret_error("comp_ctx", comp_ctx, FALSE); ret = agent_mot(comp_ctx->device_uuid, "12341234"); - if (ret != COMP_ERROR_NONE) { + if (ret != COMP_ERROR_NONE) LOG_ERR("agent_mot(%s) Failed", comp_ctx->device_uuid); - } return FALSE; } -static void _free_device_info(comp_mot_device_t *device) { - +static void _free_device_info(comp_mot_device_t *device) +{ if (!device) return; @@ -821,9 +820,8 @@ static void _agent_signal_handler(GDBusConnection *connection, (comp_group_get_invite_info() != NULL)) comp_group_notify_group_invite(result); - if (comp_ctx && (TRUE == comp_ctx->mot_me) ) { + if (comp_ctx && (TRUE == comp_ctx->mot_me)) g_timeout_add(10, __perform_agent_pairwise, NULL); - } #endif } else if (0 == g_strcmp0(signal_name, "remove_mo_done")) { g_variant_get(parameters, "(i)", &result); @@ -867,7 +865,7 @@ static void _agent_signal_handler(GDBusConnection *connection, LOG_DEBUG("Result : %d", result); comp_group_notify_group_invite(result); - }else if (0 == g_strcmp0(signal_name, "unpair_done")) { + } else if (0 == g_strcmp0(signal_name, "unpair_done")) { g_variant_get(parameters, "(i)", &result); LOG_DEBUG("Result : %d", result); @@ -1033,7 +1031,7 @@ static void _unsubscribe_event() agent.dbus_sub_ids = NULL; } -int agent_dbus_start( ) +int agent_dbus_start() { int ret = COMP_ERROR_NONE; diff --git a/src/include/d2d-log.h b/src/include/d2d-log.h index bbd0ee2..3898a24 100644 --- a/src/include/d2d-log.h +++ b/src/include/d2d-log.h @@ -1,20 +1,18 @@ -/* - * Network Configuration Module - * - * Copyright (c) 2017 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. - * +/* + * 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. + * */ #ifndef __D2D_LOG_H__ diff --git a/src/mot-agent/ma-log.h b/src/mot-agent/ma-log.h old mode 100644 new mode 100755 index 7116fbb..edc8713 --- a/src/mot-agent/ma-log.h +++ b/src/mot-agent/ma-log.h @@ -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. - * +/* + * 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. + * */ #ifndef __MA_LOG_H__ diff --git a/src/mot-agent/ma-service-interface.c b/src/mot-agent/ma-service-interface.c index a3ba916..694daf9 100644 --- a/src/mot-agent/ma-service-interface.c +++ b/src/mot-agent/ma-service-interface.c @@ -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. - * +/* + * 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. + * */ #include diff --git a/src/mot-agent/ma-service-interface.h b/src/mot-agent/ma-service-interface.h index 8ef73c6..79b332c 100644 --- a/src/mot-agent/ma-service-interface.h +++ b/src/mot-agent/ma-service-interface.h @@ -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. - * +/* + * 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. + * */ #ifndef __MA_SERVICE_INTERFACE_H__ diff --git a/src/mot-agent/ma-service.c b/src/mot-agent/ma-service.c index aa11aa2..749fe38 100644 --- a/src/mot-agent/ma-service.c +++ b/src/mot-agent/ma-service.c @@ -1,20 +1,19 @@ -/* - * 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. - * +/* + * 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. + * */ - #include #include "ma.h" diff --git a/src/mot-agent/ma-service.h b/src/mot-agent/ma-service.h index 14b73f5..172b04c 100644 --- a/src/mot-agent/ma-service.h +++ b/src/mot-agent/ma-service.h @@ -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. - * +/* + * 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. + * */ #ifndef __MA_SERVICE_H__ diff --git a/src/mot-agent/ma-subowner.c b/src/mot-agent/ma-subowner.c index a5171d9..8e1b3ef 100644 --- a/src/mot-agent/ma-subowner.c +++ b/src/mot-agent/ma-subowner.c @@ -134,15 +134,16 @@ ma_subowner_s *g_client; /**< MOT agent client instance */ * data structure */ typedef struct _proc { - char name[2]; - int data; - pthread_t thread; - pthread_mutex_t lock; - pthread_cond_t cond; - long int waits; + char name[2]; /**< Thread name */ + int data; /**< User data */ + pthread_t thread; /**< POSIX Thread */ + pthread_mutex_t lock; /**< POSIX Mutex */ + pthread_cond_t cond; /**< POSIX condition */ + long int waits; /**< How long we have to wait */ } PROC; -void _exec_and_wait(void* args) { +void _exec_and_wait(void* args) +{ OCStackResult ret = OC_STACK_OK; static struct timespec time_to_wait = {0, 0}; PROC *proc = (PROC*) args; @@ -153,7 +154,7 @@ void _exec_and_wait(void* args) { MA_LOGE("before increase proc[%s] data to [%d]", proc->name, proc->data); - while(g_client->g_doneCB && proc->data < TIMES) { + while (g_client->g_doneCB && proc->data < TIMES) { MA_LOGE("increase proc[%s] data to [%d]", proc->name, proc->data); pthread_mutex_lock(&proc->lock); pthread_cond_timedwait(&proc->cond, &proc->lock, &time_to_wait); @@ -161,15 +162,16 @@ void _exec_and_wait(void* args) { ret = OCProcess(); if (OC_STACK_OK != ret) { - MA_LOGE( "OCStack process error = %d", ret); - proc->data = TIMES; + MA_LOGE("OCStack process error = %d", ret); + proc->data = TIMES; } pthread_mutex_unlock(&proc->lock); } } -int _init_proc(PROC *proc, void *(*routine) (void *)) { +int _init_proc(PROC *proc, void *(*routine) (void *)) +{ pthread_attr_t attr; MA_LOGI("try to init proc [%s]", proc->name); @@ -211,34 +213,33 @@ static int _wait_cb_ret(int msec) ma_check_null_ret_error("g_client", g_client, OC_STACK_INVALID_PARAM); #ifdef THREAD_COND_WAIT_USED - int result_a = 0; + int result_a = 0; PROC proc_a; strcpy(proc_a.name, "A\0"); proc_a.data = 0; proc_a.waits = msec; - if (MA_ERROR_NONE !=_init_proc(&proc_a, _exec_and_wait)) + if (MA_ERROR_NONE != _init_proc(&proc_a, _exec_and_wait)) MA_LOGE("Fail to init proc [%s]", proc_a.name); pthread_join(proc_a.thread, (void*) &result_a); #else - for (int i=0; !g_client->g_doneCB && msec > i; i+=100) { + for (int i = 0; !g_client->g_doneCB && msec > i; i += 100) { /* * Basically, nanosleep is more thread-safe function, * But, in our case, nanosleep cause crash frequently */ ret = nanosleep(&tim, &tim2); - if ( 0 > ret) { + if (0 > ret) MA_LOGE("nanosleep failed=%d", errno); - } g_mutex_lock(&g_client->iotivity_mutex); ret = OCProcess(); g_mutex_unlock(&g_client->iotivity_mutex); if (OC_STACK_OK != ret) { - MA_LOGE( "OCStack process error = %d", ret); + MA_LOGE("OCStack process error = %d", ret); break; } } @@ -253,8 +254,8 @@ static void _input_pin_cb(char* pin, size_t len) { ma_check_null_ret("g_client", g_client); - if (!pin || OXM_RANDOM_PIN_MAX_SIZE>=len) { - MA_LOGE( "inputPinCB invalid parameters"); + if (!pin || OXM_RANDOM_PIN_MAX_SIZE >= len) { + MA_LOGE("inputPinCB invalid parameters"); return; } @@ -383,7 +384,7 @@ static void __notify_found_devs(void *data) ma_req_cb_s *con = (ma_req_cb_s *)data; ma_check_null_ret("con", con); - ma_service *service= (ma_service *)con->userdata; + ma_service *service = (ma_service *)con->userdata; ma_check_null_ret("service", service); ma_check_null_ret("g_client", g_client); @@ -468,7 +469,7 @@ static void _disc_mot_env_devs_func(ma_req_cb_s *con) &g_client->g_motdev_list); g_mutex_unlock(&g_client->iotivity_mutex); if (OC_STACK_OK != ret) { - MA_LOGE( "OCDiscoverMultipleOwnerEnalbedDevices API error"); + MA_LOGE("OCDiscoverMultipleOwnerEnalbedDevices API error"); goto DISC_MOT_ENB_DEVS_END; } __notify_found_devs(con); @@ -483,7 +484,7 @@ static int _disc_mot_enb_devs(ma_service *service, int timeout) ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); con = g_malloc0(sizeof(ma_req_cb_s)); if (NULL == con) { - MA_LOGE( "g_malloc0() Fail=%d", errno); + MA_LOGE("g_malloc0() Fail=%d", errno); /* Unset d2ds status 'pending' */ g_atomic_int_set(&g_client->pending, 0); return MA_ERROR_OUT_OF_MEMORY; @@ -518,7 +519,7 @@ static void _disc_owned_devs_func(ma_req_cb_s *con) &g_client->g_mowned_list); g_mutex_unlock(&g_client->iotivity_mutex); if (OC_STACK_OK != ret) { - MA_LOGE( "OCDiscoverMultipleOwnerEnabledDevices API error"); + MA_LOGE("OCDiscoverMultipleOwnerEnabledDevices API error"); goto DISC_OWNED_DEVS_END; } __notify_found_devs(con); @@ -533,7 +534,7 @@ static int _disc_owned_devs(ma_service *service, int timeout) ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); con = g_malloc0(sizeof(ma_req_cb_s)); if (NULL == con) { - MA_LOGE( "g_malloc0() Fail=%d", errno); + MA_LOGE("g_malloc0() Fail=%d", errno); /* Unset d2ds status 'pending' */ g_atomic_int_set(&g_client->pending, 0); return MA_ERROR_OUT_OF_MEMORY; @@ -558,7 +559,7 @@ static void _mot_cb(void* ctx, int num, OCProvisionResult_t* arr, bool has_error if (!has_error) { MA_LOGD("Multiple Ownership Transfer SUCCEEDED"); } else { - MA_LOGD( "Multiple Ownership Transfer FAILED "); + MA_LOGD("Multiple Ownership Transfer FAILED "); ma_print_result_list((const OCProvisionResult_t*) arr, num); } client->g_doneCB = true; @@ -606,11 +607,11 @@ static void _mot_func(ma_req_cb_s *con) #ifdef MULTIPLE_OWN_AT_ONCE OCProvisionDev_t* dev = NULL; LL_FOREACH(g_client->g_motdev_list, dev) { - if(OIC_PRECONFIG_PIN == dev->doxm->oxmSel) { + if (OIC_PRECONFIG_PIN == dev->doxm->oxmSel) { /* Pre-Configured PIN initialization */ const char* testPreconfigPin = con->pin;/* Ex) "12341234" */ ret = OCAddPreconfigPin(dev, testPreconfigPin, strlen(testPreconfigPin)); - if(OC_STACK_OK != ret) { + if (OC_STACK_OK != ret) { MA_LOGE("Failed to save the pre-configured PIN"); MA_LOGE("You can't use the pre-configured PIN OxM for MOT"); goto MOT_ENDED; @@ -618,32 +619,32 @@ static void _mot_func(ma_req_cb_s *con) } } ret = OCDoMultipleOwnershipTransfer(g_client, g_client->g_motdev_list, _mot_cb); - if (OC_STACK_OK != ret ) { - MA_LOGE( "OCDoMultipleOwnershipTransfer: ret = %d (%s)", + if (OC_STACK_OK != ret) { + MA_LOGE("OCDoMultipleOwnershipTransfer: ret = %d (%s)", ret, ma_ocf_error_to_string(ret)); goto MOT_ENDED; } #else - if(OIC_PRECONFIG_PIN == src_dev->doxm->oxmSel) { + if (OIC_PRECONFIG_PIN == src_dev->doxm->oxmSel) { /* Pre-Configured PIN initialization */ const char* testPreconfigPin = con->pin;/* Ex) "12341234" */ ret = OCAddPreconfigPin(src_dev, testPreconfigPin, strlen(testPreconfigPin)); - if(OC_STACK_OK != ret) { + if (OC_STACK_OK != ret) { MA_LOGE("Failed to save the pre-configured PIN"); goto MOT_ENDED; } } ret = OCDoMultipleOwnershipTransfer(g_client, src_dev, _mot_cb); - if (OC_STACK_OK != ret ) { - MA_LOGE( "OCDoMultipleOwnershipTransfer: ret = %d (%s)", + if (OC_STACK_OK != ret) { + MA_LOGE("OCDoMultipleOwnershipTransfer: ret = %d (%s)", ret, ma_ocf_error_to_string(ret)); goto MOT_ENDED; } #endif ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); - if(ret) { - MA_LOGE( "OCDoMultipleOwnershipTransfer callback error = %d (%s)", + if (ret) { + MA_LOGE("OCDoMultipleOwnershipTransfer callback error = %d (%s)", ret, ma_ocf_error_to_string(ret)); goto MOT_ENDED; } @@ -669,7 +670,7 @@ static int _mot(ma_service *service, gchar *uuid_str, gchar *pin) ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); con = g_malloc0(sizeof(ma_req_cb_s)); if (NULL == con) { - MA_LOGE( "g_malloc0() Fail=%d", errno); + MA_LOGE("g_malloc0() Fail=%d", errno); /* Unset d2ds status 'pending' */ g_atomic_int_set(&g_client->pending, 0); return MA_ERROR_OUT_OF_MEMORY; @@ -722,12 +723,12 @@ static OicSecAcl_t* _create_target_acl(const OicUuid_t* target, const OicUuid_t* #endif acl = (OicSecAcl_t*) OICCalloc(1, sizeof(OicSecAcl_t)); if (!acl) { - MA_LOGE( "acl : OICCalloc failed = %d", errno); + MA_LOGE("acl : OICCalloc failed = %d", errno); return NULL; } ace = (OicSecAce_t*) OICCalloc(1, sizeof(OicSecAce_t)); if (!ace) { - MA_LOGE( "ace : OICCalloc failed = %d", errno); + MA_LOGE("ace : OICCalloc failed = %d", errno); return NULL; } LL_APPEND(acl->aces, ace); @@ -736,14 +737,14 @@ static OicSecAcl_t* _create_target_acl(const OicUuid_t* target, const OicUuid_t* /* fill the href */ rsrc = (OicSecRsrc_t*)OICCalloc(1, sizeof(OicSecRsrc_t)); if (!rsrc) { - MA_LOGE( "rsrc: OICCalloc failed = %d", errno); + MA_LOGE("rsrc: OICCalloc failed = %d", errno); goto CREATE_ACL_ERROR; } len = strlen(rsrc_uri)+1; // '1' for null termination rsrc->href = (char*) OICCalloc(len, sizeof(char)); if (!rsrc->href) { - MA_LOGE( "rsrc->href: OICCalloc failed = %d", errno); + MA_LOGE("rsrc->href: OICCalloc failed = %d", errno); goto CREATE_ACL_ERROR; } memcpy(rsrc->href, rsrc_uri, len); @@ -752,12 +753,12 @@ static OicSecAcl_t* _create_target_acl(const OicUuid_t* target, const OicUuid_t* rsrc->typeLen = 1; rsrc->types = (char**)OICCalloc(1, sizeof(char*)); if (!rsrc->types) { - MA_LOGE( "rsrc->types: OICCalloc failed = %d", errno); + MA_LOGE("rsrc->types: OICCalloc failed = %d", errno); goto CREATE_ACL_ERROR; } rsrc->types[0] = g_strdup(rsrc_type); if (!rsrc->types[0]) { - MA_LOGE( "rsrc->types[0]: g_strdup failed = %d", errno); + MA_LOGE("rsrc->types[0]: g_strdup failed = %d", errno); goto CREATE_ACL_ERROR; } @@ -765,12 +766,12 @@ static OicSecAcl_t* _create_target_acl(const OicUuid_t* target, const OicUuid_t* rsrc->interfaceLen = 1; rsrc->interfaces = (char**)OICCalloc(1, sizeof(char*)); if (!rsrc->interfaces) { - MA_LOGE( "rsrc->interfaces: OICCalloc failed = %d", errno); + MA_LOGE("rsrc->interfaces: OICCalloc failed = %d", errno); goto CREATE_ACL_ERROR; } rsrc->interfaces[0] = g_strdup(rsrc_interface); if (!rsrc->interfaces[0]) { - MA_LOGE( "rsrc->interfaces[0] : g_strdup failed = %d", errno); + MA_LOGE("rsrc->interfaces[0] : g_strdup failed = %d", errno); goto CREATE_ACL_ERROR; } @@ -781,7 +782,7 @@ static OicSecAcl_t* _create_target_acl(const OicUuid_t* target, const OicUuid_t* ace->eownerID = (OicUuid_t*)OICCalloc(1, sizeof(OicUuid_t)); if (NULL == ace->eownerID) { - MA_LOGE( "ace->eownerID : OICCalloc failed = %d", errno); + MA_LOGE("ace->eownerID : OICCalloc failed = %d", errno); goto CREATE_ACL_ERROR; } memcpy(ace->eownerID->id, subject->id, sizeof(subject->id)); @@ -801,7 +802,7 @@ static void _acl_provisioning_cb(void* ctx, int nOfRes, OCProvisionResult_t* arr if (!has_error) { MA_LOGD("Provision ACL SUCCEEDED"); } else { - MA_LOGD( "Provision ACL FAILED "); + MA_LOGD("Provision ACL FAILED "); ma_print_result_list((const OCProvisionResult_t*) arr, nOfRes); } client->g_doneCB = true; @@ -846,20 +847,20 @@ static void _acl_provisioning_func(ma_req_cb_s *con) &subject_dev->doxm->deviceID, con->rsrc_uri, con->rsrc_type, con->rsrc_interface, con->permission); if (NULL == acl) { - MA_LOGE( "Failed to create ACL for %s", con->rsrc_uri); + MA_LOGE("Failed to create ACL for %s", con->rsrc_uri); goto PV_ACL_END; } /* Do ACL provisioning */ - ret= OCProvisionACL((void*) g_client, target_dev, acl, _acl_provisioning_cb); + ret = OCProvisionACL((void*) g_client, target_dev, acl, _acl_provisioning_cb); if (OC_STACK_OK != ret) { - MA_LOGD( "OCProvisionACL API error: %d (%s)", ret, ma_ocf_error_to_string(ret)); + MA_LOGD("OCProvisionACL API error: %d (%s)", ret, ma_ocf_error_to_string(ret)); goto PV_ACL_END; } ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (ret) { - MA_LOGE( "OCProvisionCredentials Faild = %d", errno); + MA_LOGE("OCProvisionCredentials Faild = %d", errno); goto PV_ACL_END; } /* display the ACL-provisioned result */ @@ -886,7 +887,7 @@ static int _acl_provisioning(ma_service *service, gchar *target, gchar *subject, ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); con = g_malloc0(sizeof(ma_req_cb_s)); if (NULL == con) { - MA_LOGE( "g_malloc0() Fail=%d", errno); + MA_LOGE("g_malloc0() Fail=%d", errno); /* Unset d2ds status 'pending' */ g_atomic_int_set(&g_client->pending, 0); return MA_ERROR_OUT_OF_MEMORY; @@ -913,7 +914,7 @@ static void _cred_provisioning_cb(void* ctx, int nOfRes, OCProvisionResult_t* ar if (!has_error) { MA_LOGD("Provision ACL SUCCEEDED"); } else { - MA_LOGD( "Provision ACL FAILED "); + MA_LOGD("Provision ACL FAILED "); ma_print_result_list((const OCProvisionResult_t*) arr, nOfRes); } client->g_doneCB = true; @@ -939,7 +940,7 @@ static void _cred_provisioning_func(ma_req_cb_s *con) goto PV_CRED_END; } - if (!con->uuid_dev1 ) { + if (!con->uuid_dev1) { MA_LOGE("dev1 is NULL"); goto PV_CRED_END; } @@ -975,14 +976,14 @@ static void _cred_provisioning_func(ma_req_cb_s *con) SYMMETRIC_PAIR_WISE_KEY, OWNER_PSK_LENGTH_256, dev1, dev2, _cred_provisioning_cb); if (OC_STACK_OK != ret) { - MA_LOGD( "OCProvisionPairwiseDevices API error: %d (%s)", + MA_LOGD("OCProvisionPairwiseDevices API error: %d (%s)", ret, ma_ocf_error_to_string(ret)); goto PV_CRED_END; } ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (ret) { - MA_LOGE( "OCProvisionCredentials Faild = %d", errno); + MA_LOGE("OCProvisionCredentials Faild = %d", errno); goto PV_CRED_END; } @@ -1012,7 +1013,7 @@ static int _cred_provisioning(ma_service *service, ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); con = g_malloc0(sizeof(ma_req_cb_s)); if (!con) { - MA_LOGE( "g_malloc0() Fail=%d", errno); + MA_LOGE("g_malloc0() Fail=%d", errno); /* Unset d2ds status 'pending' */ g_atomic_int_set(&g_client->pending, 0); return MA_ERROR_OUT_OF_MEMORY; @@ -1021,8 +1022,8 @@ static int _cred_provisioning(ma_service *service, con->userdata = service; con->cid = MA_DO_CRED_PROVISIONING; - if (!uuid_dev1 ||!uuid_dev2) { - MA_LOGE( "Invaild Prameters"); + if (!uuid_dev1 || !uuid_dev2) { + MA_LOGE("Invaild Prameters"); _request_cleanup(con); return MA_ERROR_INVALID_PARAMETER; } @@ -1043,7 +1044,7 @@ static void _resources_pairwise_cb(void* ctx, int nOfRes, OCProvisionResult_t* a if (!has_error) { MA_LOGD("Provision pairwise SUCCEEDED"); } else { - MA_LOGD( "Provision pairwise FAILED "); + MA_LOGD("Provision pairwise FAILED "); ma_print_result_list((const OCProvisionResult_t*) arr, nOfRes); } client->g_doneCB = true; @@ -1111,7 +1112,7 @@ static void _resources_pairwise_func(ma_req_cb_s *con) con->rsrc_type_1, con->rsrc_interface_1, con->permission_1); if (NULL == acl_1) { - MA_LOGE( "Failed to create ACL for %s", con->rsrc_uri); + MA_LOGE("Failed to create ACL for %s", con->rsrc_uri); goto PVPAIRWIE_ERROR; } @@ -1120,7 +1121,7 @@ static void _resources_pairwise_func(ma_req_cb_s *con) con->rsrc_type_2, con->rsrc_interface_2, con->permission_2); if (NULL == acl_2) { - MA_LOGE( "Failed to create ACL for %s", con->rsrc_uri); + MA_LOGE("Failed to create ACL for %s", con->rsrc_uri); goto PVPAIRWIE_ERROR; } @@ -1129,14 +1130,14 @@ static void _resources_pairwise_func(ma_req_cb_s *con) OWNER_PSK_LENGTH_256, target_dev_1, acl_1, target_dev_2, acl_2, _resources_pairwise_cb); if (OC_STACK_OK != ret) { - MA_LOGD( "OCProvisionPairwiseDevices API error: %d (%s)", ret, + MA_LOGD("OCProvisionPairwiseDevices API error: %d (%s)", ret, ma_ocf_error_to_string(ret)); goto PVPAIRWIE_ERROR; } ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (ret) { - MA_LOGE( "OCProvisionPairwise Faild = %d", errno); + MA_LOGE("OCProvisionPairwise Faild = %d", errno); goto PVPAIRWIE_ERROR; } /* display the pairwise-provisioned result */ @@ -1164,14 +1165,14 @@ PVPAIRWIE_ERROR: static int _resources_pairwise(ma_service *service, gchar *target_1, gchar *subject_1, gchar *rsrc_uri_1, gchar *rsrc_type_1, gchar *rsrc_interface_1, - int permission_1, gchar *target_2, gchar *subject_2,gchar *rsrc_uri_2, + int permission_1, gchar *target_2, gchar *subject_2, gchar *rsrc_uri_2, gchar *rsrc_type_2, gchar *rsrc_interface_2, int permission_2) { ma_req_cb_s *con = NULL; ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); con = g_malloc0(sizeof(ma_req_cb_s)); if (NULL == con) { - MA_LOGE( "g_malloc0() Fail=%d", errno); + MA_LOGE("g_malloc0() Fail=%d", errno); /* Unset d2ds status 'pending' */ g_atomic_int_set(&g_client->pending, 0); return MA_ERROR_OUT_OF_MEMORY; @@ -1207,7 +1208,7 @@ static void _unlink_resources_cb(void* ctx, int nOfRes, OCProvisionResult_t* arr if (!has_error) { MA_LOGD("unlink SUCCEEDED"); } else { - MA_LOGD( "unlink FAILED "); + MA_LOGD("unlink FAILED "); ma_print_result_list((const OCProvisionResult_t*) arr, nOfRes); } client->g_doneCB = true; @@ -1233,7 +1234,7 @@ static void _unlink_resources_func(ma_req_cb_s *con) goto PVUNLINKPAIRWISE_ERROR; } - if (!con->uuid_dev1 ) { + if (!con->uuid_dev1) { MA_LOGE("dev1 is NULL"); goto PVUNLINKPAIRWISE_ERROR; } @@ -1261,13 +1262,13 @@ static void _unlink_resources_func(ma_req_cb_s *con) MA_LOGI("Unlink Selected Pairwise Devices.."); ret = OCUnlinkDevices((void*) g_client, dev1, dev2, _unlink_resources_cb); if (OC_STACK_OK != ret) { - MA_LOGD( "OCUnlinkDevices API error: %d (%s)", ret, ma_ocf_error_to_string(ret)); + MA_LOGD("OCUnlinkDevices API error: %d (%s)", ret, ma_ocf_error_to_string(ret)); goto PVUNLINKPAIRWISE_ERROR; } ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (ret) { - MA_LOGE( "OCUnlinkDevices Faild = %d", errno); + MA_LOGE("OCUnlinkDevices Faild = %d", errno); goto PVUNLINKPAIRWISE_ERROR; } @@ -1293,7 +1294,7 @@ static int _unlink_resources(ma_service *service, ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); con = g_malloc0(sizeof(ma_req_cb_s)); if (!con) { - MA_LOGE( "g_malloc0() Fail=%d", errno); + MA_LOGE("g_malloc0() Fail=%d", errno); /* Unset d2ds status 'pending' */ g_atomic_int_set(&g_client->pending, 0); return MA_ERROR_OUT_OF_MEMORY; @@ -1303,7 +1304,7 @@ static int _unlink_resources(ma_service *service, con->cid = MA_UNLINK_RESOURCES; if (!uuid_dev1 || !uuid_dev2) { - MA_LOGE( "Invaild Prameters"); + MA_LOGE("Invaild Prameters"); _request_cleanup(con); return MA_ERROR_INVALID_PARAMETER; } @@ -1324,7 +1325,7 @@ static void _remove_subowner_cb(void* ctx, int num, OCProvisionResult_t* arr, if (!has_error) { MA_LOGD("Remove Multiple Ownership SUCCEEDED"); } else { - MA_LOGD( "Remove Multiple Ownership FAILED "); + MA_LOGD("Remove Multiple Ownership FAILED "); ma_print_result_list((const OCProvisionResult_t*) arr, num); } client->g_doneCB = true; @@ -1370,15 +1371,15 @@ static void _remove_subowner_func(ma_req_cb_s *con) goto REMOVE_SUBOWNER_ENDED; } ret = OCRemoveSubOwner(g_client, src_dev, &uuid_mowner, _remove_subowner_cb); - if (OC_STACK_OK != ret ) { - MA_LOGE( "OCRemoveSubOwner: ret = %d (%s)", + if (OC_STACK_OK != ret) { + MA_LOGE("OCRemoveSubOwner: ret = %d (%s)", ret, ma_ocf_error_to_string(ret)); goto REMOVE_SUBOWNER_ENDED; } ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); - if(ret) { - MA_LOGE( "OCRemoveSubOwner callback error = %d (%s)", + if (ret) { + MA_LOGE("OCRemoveSubOwner callback error = %d (%s)", ret, ma_ocf_error_to_string(ret)); goto REMOVE_SUBOWNER_ENDED; } @@ -1398,7 +1399,7 @@ static int _ma_remove_subowner(ma_service *service, gchar *uuid_str) ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); con = g_malloc0(sizeof(ma_req_cb_s)); if (NULL == con) { - MA_LOGE( "g_malloc0() Fail=%d", errno); + MA_LOGE("g_malloc0() Fail=%d", errno); /* Unset d2ds status 'pending' */ g_atomic_int_set(&g_client->pending, 0); return MA_ERROR_OUT_OF_MEMORY; @@ -1421,7 +1422,7 @@ static void _remove_remove_device_cb(void* ctx, int num, if (!has_error) { MA_LOGD("Remove CRED for mowned device SUCCEEDED"); } else { - MA_LOGD( "Remove CRED for mowned device FAILED "); + MA_LOGD("Remove CRED for mowned device FAILED "); ma_print_result_list((const OCProvisionResult_t*) arr, num); } client->g_doneCB = true; @@ -1444,7 +1445,7 @@ static void _remove_device_func(ma_req_cb_s *con) } if (!con->target_to_revoke) { MA_LOGE("Some parameters are wrong"); - MA_LOGE("%s", con->target_to_revoke ); + MA_LOGE("%s", con->target_to_revoke); goto REMOVE_DEVICE_END; } @@ -1454,16 +1455,16 @@ static void _remove_device_func(ma_req_cb_s *con) MA_LOGI(" Removing CRED for remote device at local SVR DB"); ret = OCRemoveDeviceWithUuid((void*) g_client, CALLBACK_TIMEOUT_5S, uuid, - _remove_subowner_cb ); + _remove_subowner_cb); if (OC_STACK_OK != ret) { - MA_LOGD( "OCRemoveDeviceWithUuid API error: %d (%s)", + MA_LOGD("OCRemoveDeviceWithUuid API error: %d (%s)", ret, ma_ocf_error_to_string(ret)); goto REMOVE_DEVICE_END; } ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (ret) { - MA_LOGE( "OCRemoveDeviceWithUuid Faild = %d", errno); + MA_LOGE("OCRemoveDeviceWithUuid Faild = %d", errno); goto REMOVE_DEVICE_END; } /* Disaply result result */ @@ -1483,7 +1484,7 @@ static int _remove_device(ma_service *service, gchar *uuid_str) ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); con = g_malloc0(sizeof(ma_req_cb_s)); if (NULL == con) { - MA_LOGE( "g_malloc0() Fail=%d", errno); + MA_LOGE("g_malloc0() Fail=%d", errno); /* Unset d2ds status 'pending' */ g_atomic_int_set(&g_client->pending, 0); return MA_ERROR_OUT_OF_MEMORY; @@ -1569,13 +1570,13 @@ static void _make_devices_pair_func(ma_req_cb_s *con) g_client->g_doneCB = false; - if(OIC_PRECONFIG_PIN == src_dev->doxm->oxmSel) { + if (OIC_PRECONFIG_PIN == src_dev->doxm->oxmSel) { /* Pre-Configured PIN initialization */ const char* testPreconfigPin = con->pin;/* Ex) "12341234" */ g_mutex_lock(&g_client->iotivity_mutex); ret = OCAddPreconfigPin(src_dev, testPreconfigPin, strlen(testPreconfigPin)); g_mutex_unlock(&g_client->iotivity_mutex); - if(OC_STACK_OK != ret) { + if (OC_STACK_OK != ret) { MA_LOGE("Failed to save the pre-configured PIN"); MA_LOGE("You can't use the pre-configured PIN OxM for MOT"); goto PV_PAIR_END; @@ -1585,15 +1586,15 @@ static void _make_devices_pair_func(ma_req_cb_s *con) g_mutex_lock(&g_client->iotivity_mutex); ret = OCDoMultipleOwnershipTransfer(g_client, src_dev, _mot_cb); g_mutex_unlock(&g_client->iotivity_mutex); - if (OC_STACK_OK != ret ) { - MA_LOGE( "OCDoMultipleOwnershipTransfer: ret = %d (%s)", + if (OC_STACK_OK != ret) { + MA_LOGE("OCDoMultipleOwnershipTransfer: ret = %d (%s)", ret, ma_ocf_error_to_string(ret)); goto PV_PAIR_END; } ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); - if (OC_STACK_OK != ret ) { - MA_LOGE( "OCDoMultipleOwnershipTransfer callback error = %d (%s)", + if (OC_STACK_OK != ret) { + MA_LOGE("OCDoMultipleOwnershipTransfer callback error = %d (%s)", ret, ma_ocf_error_to_string(ret)); goto PV_PAIR_END; } @@ -1609,7 +1610,7 @@ static void _make_devices_pair_func(ma_req_cb_s *con) con->rsrc_type_1, con->rsrc_interface_1, con->permission_1); if (NULL == acl_1) { - MA_LOGE( "Failed to create ACL for %s", con->rsrc_uri); + MA_LOGE("Failed to create ACL for %s", con->rsrc_uri); goto PV_PAIR_END; } @@ -1618,7 +1619,7 @@ static void _make_devices_pair_func(ma_req_cb_s *con) con->rsrc_type_2, con->rsrc_interface_2, con->permission_2); if (NULL == acl_2) { - MA_LOGE( "Failed to create ACL for %s", con->rsrc_uri); + MA_LOGE("Failed to create ACL for %s", con->rsrc_uri); goto PV_PAIR_END; } @@ -1628,14 +1629,14 @@ static void _make_devices_pair_func(ma_req_cb_s *con) target_dev_2, acl_2, _resources_pairwise_cb); g_mutex_unlock(&g_client->iotivity_mutex); if (OC_STACK_OK != ret) { - MA_LOGD( "OCProvisionPairwiseDevices API error: %d (%s)", ret, + MA_LOGD("OCProvisionPairwiseDevices API error: %d (%s)", ret, ma_ocf_error_to_string(ret)); goto PV_PAIR_END; } ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (ret) { - MA_LOGE( "OCProvisionPairwise Faild = %d", errno); + MA_LOGE("OCProvisionPairwise Faild = %d", errno); goto PV_PAIR_END; } /* display the pairwise-provisioned result */ @@ -1666,14 +1667,14 @@ PV_PAIR_END: static int _make_devices_pair(ma_service *service, gchar *pin, gchar *target_1, gchar *subject_1, gchar *rsrc_uri_1, gchar *rsrc_type_1, gchar *rsrc_interface_1, - int permission_1, gchar *target_2, gchar *subject_2,gchar *rsrc_uri_2, + int permission_1, gchar *target_2, gchar *subject_2, gchar *rsrc_uri_2, gchar *rsrc_type_2, gchar *rsrc_interface_2, int permission_2) { ma_req_cb_s *con = NULL; ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); con = g_malloc0(sizeof(ma_req_cb_s)); if (NULL == con) { - MA_LOGE( "g_malloc0() Fail=%d", errno); + MA_LOGE("g_malloc0() Fail=%d", errno); /* Unset d2ds status 'pending' */ g_atomic_int_set(&g_client->pending, 0); return MA_ERROR_OUT_OF_MEMORY; @@ -1723,7 +1724,7 @@ static void _make_devices_unpair_func(ma_req_cb_s *con) goto PV_UNPAIR_END; } - if (NULL == con->uuid_dev1 ) { + if (NULL == con->uuid_dev1) { MA_LOGE("dev1 is NULL"); goto PV_UNPAIR_END; } @@ -1750,15 +1751,15 @@ static void _make_devices_unpair_func(ma_req_cb_s *con) MA_LOGI("Unlink Selected Pairwise Devices.."); g_mutex_lock(&g_client->iotivity_mutex); - ret = OCUnlinkDevices((void*) g_client, owner_dev, owned_dev, _unlink_resources_cb ); + ret = OCUnlinkDevices((void*) g_client, owner_dev, owned_dev, _unlink_resources_cb); g_mutex_unlock(&g_client->iotivity_mutex); if (OC_STACK_OK != ret) { - MA_LOGD( "OCUnlinkDevices API error = %d (%s)", + MA_LOGD("OCUnlinkDevices API error = %d (%s)", ret, ma_ocf_error_to_string(ret)); } else { ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (OC_STACK_OK != ret) { - MA_LOGD( "OCUnlinkDevices Timeout = %d (%s)", + MA_LOGD("OCUnlinkDevices Timeout = %d (%s)", ret, ma_ocf_error_to_string(ret)); goto PV_UNPAIR_END; } @@ -1779,15 +1780,15 @@ static void _make_devices_unpair_func(ma_req_cb_s *con) g_mutex_lock(&g_client->iotivity_mutex); ret = OCRemoveSubOwner(g_client, owned_dev, &uuid_mowner, _remove_subowner_cb); g_mutex_unlock(&g_client->iotivity_mutex); - if (OC_STACK_OK != ret ) { - MA_LOGE( "OCRemoveSubOwner: ret = %d (%s)", + if (OC_STACK_OK != ret) { + MA_LOGE("OCRemoveSubOwner: ret = %d (%s)", ret, ma_ocf_error_to_string(ret)); goto PV_UNPAIR_END; } ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (OC_STACK_OK != ret) { - MA_LOGE( "OCRemoveSubOwner Timeout = %d (%s)", + MA_LOGE("OCRemoveSubOwner Timeout = %d (%s)", ret, ma_ocf_error_to_string(ret)); goto PV_UNPAIR_END; } @@ -1800,17 +1801,17 @@ static void _make_devices_unpair_func(ma_req_cb_s *con) g_mutex_lock(&g_client->iotivity_mutex); ret = OCRemoveDeviceWithUuid((void*) g_client, CALLBACK_TIMEOUT_5S, owned_uuid, - _remove_remove_device_cb ); + _remove_remove_device_cb); g_mutex_unlock(&g_client->iotivity_mutex); if (OC_STACK_OK != ret) { - MA_LOGD( "OCRemoveDeviceWithUuid API error = %d (%s)", + MA_LOGD("OCRemoveDeviceWithUuid API error = %d (%s)", ret, ma_ocf_error_to_string(ret)); goto PV_UNPAIR_END; } ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S); if (OC_STACK_OK != ret) { - MA_LOGD( "OCRemoveDeviceWithUuid Timeout = %d (%s)", + MA_LOGD("OCRemoveDeviceWithUuid Timeout = %d (%s)", ret, ma_ocf_error_to_string(ret)); goto PV_UNPAIR_END; } @@ -1833,7 +1834,7 @@ static int _make_devices_unpair(ma_service *service, gchar *uuid_dev1, gchar *uu ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); con = g_malloc0(sizeof(ma_req_cb_s)); if (!con) { - MA_LOGE( "g_malloc0() Fail=%d", errno); + MA_LOGE("g_malloc0() Fail=%d", errno); /* Unset d2ds status 'pending' */ g_atomic_int_set(&g_client->pending, 0); return MA_ERROR_OUT_OF_MEMORY; @@ -1842,8 +1843,8 @@ static int _make_devices_unpair(ma_service *service, gchar *uuid_dev1, gchar *uu con->userdata = service; con->cid = MA_MAKE_UNPAIR; - if (!uuid_dev1 ||!uuid_dev2) { - MA_LOGE( "Invaild Prameters"); + if (!uuid_dev1 || !uuid_dev2) { + MA_LOGE("Invaild Prameters"); _request_cleanup(con); return MA_ERROR_INVALID_PARAMETER; } @@ -1862,7 +1863,7 @@ static int _disable(ma_service *service) ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); con = g_malloc0(sizeof(ma_req_cb_s)); if (!con) { - MA_LOGE( "g_malloc0() Fail=%d", errno); + MA_LOGE("g_malloc0() Fail=%d", errno); /* Unset d2ds status 'pending' */ g_atomic_int_set(&g_client->pending, 0); return MA_ERROR_OUT_OF_MEMORY; @@ -1884,7 +1885,7 @@ static gpointer _worker_thread(gpointer data) if (0 == g_atomic_int_get(&client->pending)) { con = g_async_queue_pop(client->queue); if (NULL == con) continue; - switch(con->cid) { + switch (con->cid) { case MA_FIND_MOT_ENABLED_DEVICES: _disc_mot_env_devs_func(con); break; @@ -1939,7 +1940,7 @@ static int _init_provision_client(void) g_client = g_malloc0(sizeof(ma_subowner_s)); if (!g_client) { - MA_LOGE( "memory allocation error = %d", errno); + MA_LOGE("memory allocation error = %d", errno); return MA_ERROR_OUT_OF_MEMORY; } g_mutex_init(&g_client->iotivity_mutex); @@ -1958,8 +1959,8 @@ static int _init_provision_client(void) g_mutex_lock(&g_client->iotivity_mutex); ret = OCRegisterPersistentStorageHandler(&ps); g_mutex_unlock(&g_client->iotivity_mutex); - if (OC_STACK_OK != ret ) { - MA_LOGE( "OCRegisterPersistentStorageHandler error = %d", ret); + if (OC_STACK_OK != ret) { + MA_LOGE("OCRegisterPersistentStorageHandler error = %d", ret); return ret; } @@ -1969,8 +1970,8 @@ static int _init_provision_client(void) g_mutex_lock(&g_client->iotivity_mutex); ret = OCInit(NULL, 0, OC_CLIENT_SERVER); g_mutex_unlock(&g_client->iotivity_mutex); - if (OC_STACK_OK != ret ) { - MA_LOGE( "OCInit() error = [%d][%s]", ret, ma_ocf_error_to_string(ret)); + if (OC_STACK_OK != ret) { + MA_LOGE("OCInit() error = [%d][%s]", ret, ma_ocf_error_to_string(ret)); return ret; } @@ -1978,16 +1979,16 @@ static int _init_provision_client(void) g_mutex_lock(&g_client->iotivity_mutex); ret = OCConfigSelfOwnership(); g_mutex_unlock(&g_client->iotivity_mutex); - if (OC_STACK_OK != ret ) { - MA_LOGE( "OCConfigSelfOwnership() error = [%d][%s]", + if (OC_STACK_OK != ret) { + MA_LOGE("OCConfigSelfOwnership() error = [%d][%s]", ret, ma_ocf_error_to_string(ret)); } g_mutex_lock(&g_client->iotivity_mutex); ret = OCInitPM(data_dir); g_mutex_unlock(&g_client->iotivity_mutex); - if (OC_STACK_OK != ret ) { - MA_LOGE( "OCInitPM() error = [%d][%s]", ret, ma_ocf_error_to_string(ret)); + if (OC_STACK_OK != ret) { + MA_LOGE("OCInitPM() error = [%d][%s]", ret, ma_ocf_error_to_string(ret)); return ret; } @@ -1998,7 +1999,7 @@ static int _init_provision_client(void) int ma_request_get_ownerid(ma_service *service, gchar **uuid_str) { - int ret =MA_ERROR_NONE; + int ret = MA_ERROR_NONE; OicUuid_t uuid; ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); @@ -2061,7 +2062,7 @@ int ma_request_disc_owned_devs(ma_service *service, int timeout) int ma_request_mot(ma_service *service, gchar* uuid_str, gchar *pin) { - int ret =MA_ERROR_NONE; + int ret = MA_ERROR_NONE; ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); ma_check_null_ret_error("service", service, FALSE); @@ -2089,7 +2090,7 @@ int ma_request_mot(ma_service *service, gchar* uuid_str, gchar *pin) int ma_request_prov_acl(ma_service *service, gchar *target, gchar *subject, gchar *rsrc_uri, gchar *rsrc_type, gchar *rsrc_interface, int permission) { - int ret =MA_ERROR_NONE; + int ret = MA_ERROR_NONE; ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); ma_check_null_ret_error("service", service, FALSE); @@ -2117,7 +2118,7 @@ int ma_request_prov_acl(ma_service *service, gchar *target, gchar *subject, int ma_request_prov_cred(ma_service *service, gchar *uuid_dev1, gchar *uuid_dev2) { - int ret =MA_ERROR_NONE; + int ret = MA_ERROR_NONE; ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); ma_check_null_ret_error("service", service, FALSE); @@ -2145,7 +2146,7 @@ int ma_request_prov_cred(ma_service *service, gchar *uuid_dev1, gchar *uuid_dev2 int ma_request_rsrc_pairwise(ma_service *service, gchar *target_1, gchar *subject_1, gchar *rsrc_uri_1, gchar *rsrc_type_1, gchar *rsrc_interface_1, int permission_1, - gchar *target_2, gchar *subject_2,gchar *rsrc_uri_2, + gchar *target_2, gchar *subject_2, gchar *rsrc_uri_2, gchar *rsrc_type_2, gchar *rsrc_interface_2, int permission_2) { @@ -2213,7 +2214,7 @@ int ma_request_unlink_rsrc(ma_service *service, gchar *uuid_dev1, int ma_request_remove_subowner(ma_service *service, gchar* uuid_str) { - int ret =MA_ERROR_NONE; + int ret = MA_ERROR_NONE; ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); ma_check_null_ret_error("service", service, FALSE); @@ -2239,7 +2240,7 @@ int ma_request_remove_subowner(ma_service *service, gchar* uuid_str) int ma_request_remove_device(ma_service *service, gchar* uuid_str) { - int ret =MA_ERROR_NONE; + int ret = MA_ERROR_NONE; ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA); ma_check_null_ret_error("service", service, FALSE); @@ -2266,7 +2267,7 @@ int ma_request_remove_device(ma_service *service, gchar* uuid_str) int ma_request_pair(ma_service *service, gchar *pin, gchar *target_1, gchar *subject_1, gchar *rsrc_uri_1, gchar *rsrc_type_1, gchar *rsrc_interface_1, int permission_1, - gchar *target_2, gchar *subject_2,gchar *rsrc_uri_2, + gchar *target_2, gchar *subject_2, gchar *rsrc_uri_2, gchar *rsrc_type_2, gchar *rsrc_interface_2, int permission_2) { @@ -2366,9 +2367,8 @@ int ma_delete_mot_agent(ma_service *service) g_mutex_lock(&g_client->iotivity_mutex); ret = OCStop(); g_mutex_unlock(&g_client->iotivity_mutex); - if (OC_STACK_OK != ret) { - MA_LOGE( "OCStack stop error"); - } + if (OC_STACK_OK != ret) + MA_LOGE("OCStack stop error"); /* Stop provisioning */ g_mutex_lock(&g_client->iotivity_mutex); diff --git a/src/mot-agent/ma-subowner.h b/src/mot-agent/ma-subowner.h index 3007df8..6069278 100644 --- a/src/mot-agent/ma-subowner.h +++ b/src/mot-agent/ma-subowner.h @@ -61,7 +61,7 @@ int ma_request_prov_cred(ma_service *service, gchar *uuid_dev1, gchar *uuid_dev2 int ma_request_rsrc_pairwise(ma_service *service, gchar *target_1, gchar *subject_1, gchar *rsrc_uri_1, gchar *rsrc_type_1, gchar *rsrc_interface_1, int permission_1, - gchar *target_2, gchar *subject_2,gchar *rsrc_uri_2, + gchar *target_2, gchar *subject_2, gchar *rsrc_uri_2, gchar *rsrc_type_2, gchar *rsrc_interface_2, int permission_2); int ma_request_unlink_rsrc(ma_service *service, gchar *uuid_dev1, gchar *uuid_dev2); @@ -70,7 +70,7 @@ int ma_request_remove_device(ma_service *service, gchar* uuid_str); int ma_request_pair(ma_service *service, gchar *pin, gchar *target_1, gchar *subject_1, gchar *rsrc_uri_1, gchar *rsrc_type_1, gchar *rsrc_interface_1, int permission_1, - gchar *target_2, gchar *subject_2,gchar *rsrc_uri_2, + gchar *target_2, gchar *subject_2, gchar *rsrc_uri_2, gchar *rsrc_type_2, gchar *rsrc_interface_2, int permission_2); int ma_request_unpair(ma_service *service, gchar *uuid_owner, gchar *uuid_owned); diff --git a/src/mot-agent/ma-util.c b/src/mot-agent/ma-util.c index 601518c..be337d4 100644 --- a/src/mot-agent/ma-util.c +++ b/src/mot-agent/ma-util.c @@ -174,32 +174,30 @@ char * ma_get_readable_uuid(const OicUuid_t* uuid) OCProvisionDev_t* ma_get_dev_by_id(const OCProvisionDev_t* dev_lst, const int dev_num) { - if (!dev_lst || 0>=dev_num) { + if (!dev_lst || 0 >= dev_num) { MA_LOGI("Device List is Empty..\n"); return NULL; } OCProvisionDev_t* lst = (OCProvisionDev_t*) dev_lst; - for (int i=0; lst; ) { - if (dev_num == ++i) { + for (int i = 0; lst; ) { + if (dev_num == ++i) return lst; - } lst = lst->next; } - - return NULL; + return NULL; } #endif OCProvisionDev_t* ma_get_dev_by_uuid(const OCProvisionDev_t* dev_lst, const OicUuid_t* uuid) { - if (!dev_lst ) { + if (!dev_lst) { MA_LOGI("dev_lst is empty"); return NULL; } - if (!uuid ) { + if (!uuid) { MA_LOGI("uuid is NULL"); return NULL; } @@ -220,7 +218,7 @@ OCProvisionDev_t* ma_get_dev_by_uuid(const OCProvisionDev_t* dev_lst, lst = lst->next; } - return NULL; + return NULL; } int ma_print_dev_list(const OCProvisionDev_t* dev_lst) @@ -243,13 +241,13 @@ int ma_print_dev_list(const OCProvisionDev_t* dev_lst) int ma_print_result_list(const OCProvisionResult_t* rslt_lst, const int rslt_cnt) { - if (!rslt_lst || 0>=rslt_cnt) { + if (!rslt_lst || 0 >= rslt_cnt) { MA_LOGI(" Device List is Empty..\n\n"); return 0; } int lst_cnt = 0; - for ( ; rslt_cnt>lst_cnt; ++lst_cnt) { + for (; rslt_cnt > lst_cnt; ++lst_cnt) { MA_LOGD("%s : [%d][%s]", ma_get_readable_uuid((const OicUuid_t*) &rslt_lst[lst_cnt].deviceId), rslt_lst[lst_cnt].res, ma_ocf_error_to_string(rslt_lst[lst_cnt].res)); @@ -291,9 +289,9 @@ int ma_set_device_id_seed(void) ret = SetDeviceIdSeed((const guchar *)mac_addr, WIFI_MAC_ADDR_LENGTH); g_free(mac_addr); } - if (OC_STACK_OK != ret ) { - MA_LOGE( "SetDeviceIdSeed() error = [%d][%s]", ret, ma_ocf_error_to_string(ret)); - } + if (OC_STACK_OK != ret) + MA_LOGE("SetDeviceIdSeed() error = [%d][%s]", ret, ma_ocf_error_to_string(ret)); + wifi_manager_deinitialize(wifi_handle); return ret; } @@ -302,8 +300,7 @@ static OCProvisionDev_t* _clone_ocprovision_dev(const OCProvisionDev_t* src) { MA_LOGD(""); - if (!src) - { + if (!src) { MA_LOGD("Invalid parameter"); return NULL; } @@ -312,9 +309,8 @@ static OCProvisionDev_t* _clone_ocprovision_dev(const OCProvisionDev_t* src) memcpy(&newDev->endpoint, &src->endpoint, sizeof(OCDevAddr)); - if (src->pstat) - { - newDev->pstat= g_try_malloc0(sizeof(OicSecPstat_t)); + if (src->pstat) { + newDev->pstat = g_try_malloc0(sizeof(OicSecPstat_t)); memcpy(newDev->pstat, src->pstat, sizeof(OicSecPstat_t)); // We have to assign NULL for not necessary information to prevent memory corruption. @@ -322,8 +318,7 @@ static OCProvisionDev_t* _clone_ocprovision_dev(const OCProvisionDev_t* src) memcpy(newDev->pstat->sm, src->pstat->sm, sizeof(OicSecDpom_t)); } - if (src->doxm) - { + if (src->doxm) { newDev->doxm = g_try_malloc0(sizeof(OicSecDoxm_t)); memcpy(newDev->doxm, src->doxm, sizeof(OicSecDoxm_t)); @@ -357,13 +352,9 @@ static OCProvisionDev_t* _clone_ocprovision_dev(const OCProvisionDev_t* src) } if (0 == strlen(src->secVer)) - { g_strlcpy(newDev->secVer, "0.0.0", OIC_SEC_MAX_VER_LEN); - } else - { g_strlcpy(newDev->secVer, src->secVer, OIC_SEC_MAX_VER_LEN); - } newDev->securePort = src->securePort; newDev->devStatus = src->devStatus; @@ -372,4 +363,4 @@ static OCProvisionDev_t* _clone_ocprovision_dev(const OCProvisionDev_t* src) return newDev; } -#endif \ No newline at end of file +#endif diff --git a/src/mot-agent/ma.h b/src/mot-agent/ma.h index fbdf41a..94cd320 100644 --- a/src/mot-agent/ma.h +++ b/src/mot-agent/ma.h @@ -1,20 +1,19 @@ -/* - * 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. - * +/* + * 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. + * */ - #ifndef __MA_AGENT_H__ #define __MA_AGENT_H__ @@ -46,3 +45,4 @@ typedef struct _ma_service { } ma_service; #endif /* __MA_AGENT_H__ */ +