/* LCOV_EXCL_START */
_DBG("all connections closed\n");
ref_count = 0;
+ MDG_UNLOCK;
return ret;
/* LCOV_EXCL_STOP */
}
CHECK_FEATURE_SUPPORTED(MDG_FEATURE);
- mdg_device_s * dst = (mdg_device_s *)target;
+ mdg_device_s *dst = (mdg_device_s *)target;
mdg_check_null_ret_error("target", target, MDG_ERROR_INVALID_PARAMETER);
- mdg_device_s * src = (mdg_device_s *)source;
+ mdg_device_s *src = (mdg_device_s *)source;
mdg_check_null_ret_error("source", source, MDG_ERROR_INVALID_PARAMETER);
ret = mdg_device_info_create(&target);
if (handle->mowned_device_found_cb.found_cb)
handle->mowned_device_found_cb.found_cb(device,
handle->mowned_device_found_cb.user_data);
+ destroy_device_handle(device);
}
g_variant_iter_free(iter);
}
g_variant_get(arg, "(iay)", &len, &iter);
data = g_try_malloc0(len + 1);
+ if (data) {
+ data = NULL;
+ len = 0;
+ } else {
+ while (g_variant_iter_loop(iter, "y", &data[length]))
+ length += 1;
- while (g_variant_iter_loop(iter, "y", &data[length]))
- length += 1;
+ data[length > len ? len : length] = '\0';
+ _DBG("Received result length %d data %s", len, data);
- data[length] = '\0';
- _DBG("Received result length %d data %s", len, data);
-
- g_variant_iter_free(iter);
+ g_variant_iter_free(iter);
+ }
if (handle->request_result_cb.result_cb)
handle->request_result_cb.result_cb(cmd, device_id, data, len, ret,
return NULL;
/* LCOV_EXCL_STOP */
}
+
+void destroy_device_handle(mdg_device_s *device)
+{
+ if (NULL == device) {
+ /* LCOV_EXCL_START */
+ _ERR("Memory allocation failed");
+ return;
+ /* LCOV_EXCL_STOP */
+ }
+
+ if (device->device_id) {
+ free(device->device_id);
+ device->device_id = NULL;
+ }
+ if (device->model_name) {
+ free(device->model_name);
+ device->model_name = NULL;
+ }
+ if (device->device_name) {
+ free(device->device_name);
+ device->device_name = NULL;
+ }
+ if (device->platform_ver) {
+ free(device->platform_ver);
+ device->platform_ver = NULL;
+ }
+ if (device->vendor_id) {
+ free(device->vendor_id);
+ device->vendor_id = NULL;
+ }
+ if (device->profile) {
+ free(device->profile);
+ device->profile = NULL;
+ }
+ if (device->ip) {
+ free(device->ip);
+ device->ip = NULL;
+ }
+ free(device);
+ device = NULL;
+}
+
mdg_device_s *create_device_handle(char *device_id, char *ip, int device_type,
int port, int sec_port, char *model_name, char *device_name,
char *platform_ver, char *vendor_id, char *profile);
+void destroy_device_handle(mdg_device_s *device);
#ifdef __cplusplus
}
static int run_device_eject(MManager *mm, struct menu_data *menu)
{
int ret;
- int idx;
+ int idx = 1;
mdg_group_h group = NULL;
mdg_device_h device = NULL;
static int run_device_invite(MManager *mm, struct menu_data *menu)
{
int ret;
- int idx;
+ int idx = 1;
mdg_group_h group = NULL;
mdg_device_h device = NULL;
static int run_group_delete(MManager *mm, struct menu_data *menu)
{
int ret;
- int idx;
- mdg_group_h group;
+ int idx = 1;
+ mdg_group_h group = NULL;
msg("Delete Group");
static int run_devices_find(MManager *mm, struct menu_data *menu)
{
int ret;
- int duration;
+ int duration = 2;
msg("Find Devices");
if (strlen(timeout))
static int run_group_leave(MManager *mm, struct menu_data *menu)
{
int ret;
- int idx;
- mdg_group_h group;
+ int idx = 1;
+ mdg_group_h group = NULL;
msg("Leave Group");
static int run_group_join(MManager *mm, struct menu_data *menu)
{
int ret;
- int idx;
- mdg_group_h group;
+ int idx = 1;
+ mdg_group_h group = NULL;
msg("Join Group");
{
int ret;
int count;
- mdg_group_h *groups;
+ mdg_group_h *groups = NULL;
msg("Show Found Group(s)");
static int run_group_find(MManager *mm, struct menu_data *menu)
{
int ret;
- int duration;
+ int duration = 2;
msg("Find Group");
if (strlen(timeout))
static int run_devices_find_mowned_device(MManager *mm, struct menu_data *menu)
{
int ret;
- int duration;
+ int duration = 2;
msg("Find My Owned Devices");
if (strlen(timeout))
static int run_request_create_group(MManager *mm, struct menu_data *menu)
{
int ret = 0;
+ int dev_idx = 1;
int dev_count = 0;
mdg_device_h device = NULL;
return RET_SUCCESS;
}
- int dev_idx;
if (device_idx != NULL && strlen(device_idx)) {
dev_idx = (unsigned short)strtol(device_idx, NULL, 10);
if (0 >= dev_idx) {
static int run_request_invite(MManager *mm, struct menu_data *menu)
{
int ret = 0;
+ int grp_idx = 1;
+ int dev_idx = 1;
int grp_count = 0;
int dev_count = 0;
mdg_device_h device = NULL;
return RET_SUCCESS;
}
- int grp_idx;
if (group_idx != NULL && strlen(group_idx)) {
grp_idx = (unsigned short)strtol(group_idx, NULL, 10);
if (0 >= grp_idx) {
}
}
- int dev_idx;
if (device_idx != NULL && strlen(device_idx)) {
dev_idx = (unsigned short)strtol(device_idx, NULL, 10);
if (0 >= dev_idx) {