GVariantIter *iter2 = NULL;
g_variant_get(parameters, "(a(y)ya(y)q)", &iter1, &count, &iter2, &addr16);
+ RETM_IF(NULL == iter1, "Invalid parameter !");
+ RETM_IF(NULL == iter2, "Invalid parameter !");
+
while (g_variant_iter_loop(iter1, "(y)", &value)) {
addr64[j] = value;
j++;
}
- if (NULL != iter1)
- g_variant_iter_free(iter1);
+ g_variant_iter_free(iter1);
j = 0;
while (g_variant_iter_loop(iter2, "(y)", &value)) {
ep[j] = value;
j++;
}
- if (NULL != iter2)
- g_variant_iter_free(iter2);
+ g_variant_iter_free(iter2);
zb_event_data_s ev;
ev.data.join = calloc(1, sizeof(zb_event_join_s));
GVariantIter *iter = NULL;
g_variant_get(parameters, "(a(y))", &iter);
+ RETM_IF(NULL == iter, "Invalid parameter !");
+
while (g_variant_iter_loop(iter, "(y)", &value)) {
addr64[j] = value;
j++;
}
- if (NULL != iter)
- g_variant_iter_free(iter);
+ g_variant_iter_free(iter);
zb_event_data_s ev;
memset(&ev, 0, sizeof(zb_event_data_s));
unsigned char value, status;
g_variant_get(parameters, "(a(y)y)", &iter, &status);
+ RETM_IF(NULL == iter, "Invalid parameter !");
+
while (g_variant_iter_loop(iter, "(y)", &value)) {
addr64[j] = value;
j++;
}
- if (NULL != iter)
- g_variant_iter_free(iter);
+ g_variant_iter_free(iter);
zb_event_data_s ev;
ev.data.child_left = calloc(1, sizeof(zb_event_child_left_s));
g_variant_get(parameters, "(qyqaqa(y)a(y)i)", &addr16, &ep,
&cluster_id, &attr_iter, &dataType_iter, &data_iter, &records_len);
+ RETM_IF(NULL == attr_iter, "Invalid parameter !");
+ RETM_IF(NULL == dataType_iter, "Invalid parameter !");
+ RETM_IF(NULL == data_iter, "Invalid parameter !");
+
records = calloc(records_len, sizeof(struct attribute_report_s*));
RETM_IF(NULL == records, "calloc() Fail(%d)", errno);
for (j = 0; j < records_len; j++) {
for (i = 0; i < j; i++)
free(records[i]);
free(records);
- if (NULL != attr_iter)
- g_variant_iter_free(attr_iter);
- if (NULL != dataType_iter)
- g_variant_iter_free(dataType_iter);
- if (NULL != data_iter)
- g_variant_iter_free(data_iter);
+
+ g_variant_iter_free(attr_iter);
+ g_variant_iter_free(dataType_iter);
+ g_variant_iter_free(data_iter);
ERR("calloc() Fail(%d)", errno);
return;
DBG("AttributeId 0x%04x", records[j]->id);
j++;
}
- if (NULL != attr_iter)
- g_variant_iter_free(attr_iter);
- if (NULL != dataType_iter)
- g_variant_iter_free(dataType_iter);
+ g_variant_iter_free(attr_iter);
+ g_variant_iter_free(dataType_iter);
j = 0;
while (j < records_len) {
g_variant_iter_loop(data_iter, "(y)", &value);
records[j]->value[i] = value;
}
- if (NULL != data_iter)
- g_variant_iter_free(data_iter);
+ g_variant_iter_free(data_iter);
break;
case ZB_ZCL_LONG_OCTAT_STRING:
case ZB_ZCL_LONG_CHRACTER_STRING:
dsizeIndex++;
records[j]->value[dsizeIndex] = dSize[dsizeIndex];
dsizeIndex++;
+
for (i = dsizeIndex; i < data_size - 2; i++) {
g_variant_iter_loop(data_iter, "(y)", &value);
records[j]->value[i] = value;
}
- if (NULL != data_iter)
- g_variant_iter_free(data_iter);
+ g_variant_iter_free(data_iter);
break;
/* Array, set and bag */
case ZB_ZCL_ARRAY:
DBG("value[%d] 0x%02X", i, records[j]->value[i]);
}
}
- if (NULL != data_iter)
- g_variant_iter_free(data_iter);
+ g_variant_iter_free(data_iter);
}
DBG("DataType = 0x%02X Data Size = %d", records[j]->type, data_size);
j++;
gchar *name_owner = g_dbus_proxy_get_name_owner(proxy);
zigbee_h handle = (zigbee_h)user_data;
- if (name_owner)
- return;
+ DBG("Name owner notify [%s]", name_owner);
- zbl_dbus_stop(handle);
+ if (NULL == name_owner)
+ zbl_dbus_stop(handle);
+
+ g_free(name_owner);
}
static void _zbl_request_cleanup(gpointer data)
GVariantIter *mac_iter = NULL;
g_variant_get(parameters, "(ya(y)qyy)", &status, &mac_iter, &addr16, &num, &start_idx);
+ RETM_IF(NULL == mac_iter, "Invalid parameter !");
+
while (g_variant_iter_loop(mac_iter, "(y)", &value)) {
addr64[j] = value;
j++;
}
+ g_variant_iter_free(mac_iter);
cb(status, addr64, addr16, num, start_idx, NULL, container->userdata);
- if (NULL != mac_iter)
- g_variant_iter_free(mac_iter);
}
break;
case ZBL_ZDO_NWK_ADDR_EXT_REQ: {
g_variant_get(parameters, "(ya(y)qyyaq)", &status, &mac_iter,
&addr16, &num, &start_idx, &assoc_iter);
+ RETM_IF(NULL == mac_iter, "Invalid parameter !");
+
while (g_variant_iter_loop(mac_iter, "(y)", &value)) {
addr64[j] = value;
j++;
}
- if (NULL != mac_iter)
- g_variant_iter_free(mac_iter);
+ g_variant_iter_free(mac_iter);
if (NULL != assoc_iter)
g_variant_iter_free(assoc_iter);
unsigned char *ep_list;
g_variant_get(parameters, "(yqa(y)y)", &status, &addr16, &ep_iter, &count);
+ RETM_IF(NULL == ep_iter, "Invalid parameter !");
+
ep_list = calloc(count+1, sizeof(unsigned char));
RETM_IF(NULL == ep_list, "calloc() Fail(%d)", errno);
ep_list[j] = value;
j++;
}
- if (NULL != ep_iter)
- g_variant_iter_free(ep_iter);
+ g_variant_iter_free(ep_iter);
cb(status, addr16, count, ep_list, container->userdata);
free(ep_list);
&records->ep, &records->profile_id, &records->device_id,
&records->num_of_in_clusters, &records->num_of_out_clusters,
&in_iter, &out_iter);
+ if (NULL == in_iter || NULL == out_iter) {
+ ERR("Invalid parameter !");
+ free(records);
+ return;
+ }
#if 0
records->in_clusters = calloc(records->num_of_in_clusters, sizeof(unsigned short));
if (NULL == records->in_clusters) {
ERR("calloc() Fail(%d)", errno);
- if (NULL != in_iter)
- g_variant_iter_free(in_iter);
- if (NULL != out_iter)
- g_variant_iter_free(out_iter);
+ g_variant_iter_free(in_iter);
+ g_variant_iter_free(out_iter);
return;
}
records->out_clusters = calloc(records->num_of_out_clusters, sizeof(unsigned short));
if (NULL == records->out_clusters) {
ERR("calloc() Fail(%d)", errno);
free(records->in_clusters);
- if (NULL != in_iter)
- g_variant_iter_free(in_iter);
- if (NULL != out_iter)
- g_variant_iter_free(out_iter);
+ g_variant_iter_free(in_iter);
+ g_variant_iter_free(out_iter);
return;
}
#endif
records->in_clusters[j] = value;
j++;
}
- if (NULL != in_iter)
- g_variant_iter_free(in_iter);
+ g_variant_iter_free(in_iter);
j = 0;
while (g_variant_iter_loop(out_iter, "q", &value)) {
records->out_clusters[j] = value;
j++;
}
- if (NULL != out_iter)
- g_variant_iter_free(out_iter);
+ g_variant_iter_free(out_iter);
DBG("addr16=0x%x, count=%d, records->ep=%d, records->device_id=0x%x",
addr16, count, records->ep, records->device_id);
g_variant_get(parameters, "(yqya(y))", &status, &addr16, &value, &ml_iter);
match_len = value;
+ RETM_IF(NULL == ml_iter, "Invalid parameter !");
+
if (match_len > 0) {
match_list = calloc(match_len+1, sizeof(unsigned char));
RETM_IF(NULL == match_list, "calloc() Fail(%d)", errno);
DBG("match_list[i]=%d", j, match_list[j]);
j++;
}
- if (NULL != ml_iter)
- g_variant_iter_free(ml_iter);
}
DBG("Match count : [%d]", match_len);
unsigned char *complex_desc = NULL;
g_variant_get(parameters, "(yqya(y))", &status, &addr16, &length, &comp_iter);
+ RETM_IF(NULL == comp_iter, "Invalid parameter !");
+
if (length > 0) {
complex_desc = calloc(length, sizeof(char));
if (NULL == complex_desc) {
- if (NULL != comp_iter)
- g_variant_iter_free(comp_iter);
+ g_variant_iter_free(comp_iter);
ERR("calloc() Fail(%d)", errno);
return;
}
complex_desc[j] = value;
j++;
}
- if (NULL != comp_iter)
- g_variant_iter_free(comp_iter);
+ g_variant_iter_free(comp_iter);
}
cb(status, addr16, length, complex_desc, container->userdata);
unsigned char *complex_desc = NULL;
g_variant_get(parameters, "(yqya(y))", &status, &addr16, &length, &comp_iter);
+ RETM_IF(NULL == comp_iter, "Invalid parameter !");
+
if (length > 0) {
complex_desc = calloc(length, sizeof(char));
if (NULL == complex_desc) {
- if (NULL != comp_iter)
- g_variant_iter_free(comp_iter);
+ g_variant_iter_free(comp_iter);
ERR("calloc() Fail(%d)", errno);
return;
}
+
while (g_variant_iter_loop(comp_iter, "(y)", &value)) {
complex_desc[j] = value;
j++;
}
- if (NULL != comp_iter)
- g_variant_iter_free(comp_iter);
+ g_variant_iter_free(comp_iter);
}
cb(status, addr16, length, complex_desc, container->userdata);
g_variant_get(parameters, "(yyyya(ayyqyqayy))", &status,
&binding_table_enteries, &start_index,
&binding_table_list_count, &rsp_iter);
+ RETM_IF(NULL == rsp_iter, "Invalid parameter !");
if (binding_table_list_count > 0) {
records = calloc(binding_table_list_count, sizeof(zb_zdo_binding_table_h));
for (i = 0; i < binding_table_list_count; i++) {
records[i] = calloc(binding_table_list_count, sizeof(struct zb_zdo_binding_table_s));
if (NULL == records[i]) {
- if (NULL != mac_iter)
- g_variant_iter_free(mac_iter);
- if (NULL != rsp_iter)
- g_variant_iter_free(rsp_iter);
- if (NULL != destep_iter)
- g_variant_iter_free(destep_iter);
+ g_variant_iter_free(rsp_iter);
ERR("calloc() Fail(%d)", errno);
goto MGMT_NWK_BIND_REQ_OUT;
}
}
}
+
for (i = 0; i < binding_table_list_count; i++) {
g_variant_iter_loop(rsp_iter, "(ayyqyqayy)", &mac_iter,
&records[i]->src_ep, &records[i]->cluster_id,
&records[i]->dst_addr_mode, &dst_addr16,
&destep_iter, &dst_ep);
+ if (NULL == mac_iter) {
+ ERR("Invalid parameter !");
+ goto MGMT_NWK_BIND_REQ_OUT;
+ }
+ if (NULL == destep_iter) {
+ ERR("Invalid parameter !");
+ goto MGMT_NWK_BIND_REQ_OUT;
+ }
+
for (j = 0; j < 8; j++) {
g_variant_iter_loop(mac_iter, "y", &value);
records[i]->src_addr64[j] = value;
}
- if (NULL != mac_iter)
- g_variant_iter_free(mac_iter);
+ g_variant_iter_free(mac_iter);
if (0x03 == records[i]->dst_addr_mode) {
for (j = 0; j < 8; j++) {
g_variant_iter_loop(destep_iter, "y", &value);
records[i]->dst_addr64[j] = value;
}
+ g_variant_iter_free(destep_iter);
+
records[i]->dst_ep = dst_ep;
DBG("Destination MAC Addr : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
records[i]->dst_addr64[7], records[i]->dst_addr64[6],
} else if (0x01 == records[i]->dst_addr_mode) {
records[i]->dst_addr16 = dst_addr16;
}
- if (NULL != destep_iter)
- g_variant_iter_free(destep_iter);
}
- if (NULL != rsp_iter)
- g_variant_iter_free(rsp_iter);
+ g_variant_iter_free(rsp_iter);
cb(status, binding_table_enteries, start_index, binding_table_list_count,
(void **)records, container->userdata);
g_variant_get(parameters, "(yyyya(ayayyqyyyyy))", &status, &neighbor_table_enteries,
&start_index, &neighbor_table_list_count, &resp_iter);
+ RETM_IF(NULL == resp_iter, "Invalid parameter !");
if (neighbor_table_list_count > 0) {
records = calloc(neighbor_table_list_count, sizeof(zb_zdo_neighbor_table_desc_h));
&records[i]->rx_on_when_idle, &records[i]->relationship,
&records[i]->permit_joining, &records[i]->depth,
&records[i]->lqi);
+ RETM_IF(NULL == mac_iter, "Invalid parameter !");
+ RETM_IF(NULL == mac_iter1, "Invalid parameter !");
+
for (j = 0; j < 8; j++) {
g_variant_iter_loop(mac_iter, "y", &value);
records[i]->extended_pan_id[j] = value;
g_variant_iter_loop(mac_iter1, "y", &value);
records[i]->addr64[j] = value;
}
- if (NULL != mac_iter)
- g_variant_iter_free(mac_iter);
- if (NULL != mac_iter1)
- g_variant_iter_free(mac_iter1);
+ g_variant_iter_free(mac_iter);
+ g_variant_iter_free(mac_iter1);
DBG("ext PAN ID = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
records[i]->extended_pan_id[0], records[i]->extended_pan_id[1],
records[i]->addr64[0], records[i]->addr64[1], records[i]->addr64[2], records[i]->addr64[3],
records[i]->addr64[4], records[i]->addr64[5], records[i]->addr64[6], records[i]->addr64[7]);
}
- if (NULL != resp_iter)
- g_variant_iter_free(resp_iter);
+ g_variant_iter_free(resp_iter);
cb(status, neighbor_table_enteries, start_index, neighbor_table_list_count,
(void **)records, container->userdata);
g_variant_get(parameters, "(yyyya(qyyyyq))", &status, &routing_table_enteries,
&start_index, &routing_table_list_count, &rsp_iter);
+ RETM_IF(NULL == rsp_iter, "Invalid parameter !");
if (routing_table_list_count > 0) {
records = calloc(routing_table_list_count, sizeof(zb_zdo_routing_table_h));
&records[i]->route_record_required,
&records[i]->many_to_one, &records[i]->next_hop_addr);
}
- if (NULL != rsp_iter)
- g_variant_iter_free(rsp_iter);
+ g_variant_iter_free(rsp_iter);
cb(status, routing_table_enteries, start_index, routing_table_list_count,
(void **)records, container->userdata);
g_variant_get(parameters, "(yyyya(ayyyyyyy))", &status, &nwk_count,
&start_index, &nwk_list_count, &resp_iter);
+ RETM_IF(NULL == resp_iter, "Invalid parameter !");
struct zb_zdo_network_list_record_s **records = NULL;
g_variant_iter_loop(resp_iter, "(ayyyyyyy)", &mac_iter, &records[i]->logical_channel,
&records[i]->stack_profile, &records[i]->zigbee_version, &records[i]->beacon_order,
&records[i]->superframe_order, &records[i]->permit_joining);
+ if (NULL == mac_iter) {
+ ERR("Invalid parameter !");
+ goto MGMT_NWK_DISC_REQ_OUT;
+ }
+
for (j = 0; j < 8; j++) {
g_variant_iter_loop(mac_iter, "y", &value);
records[i]->extended_pan_id[j] = value;
}
- if (NULL != mac_iter)
- g_variant_iter_free(mac_iter);
+ g_variant_iter_free(mac_iter);
}
- if (NULL != resp_iter)
- g_variant_iter_free(resp_iter);
+ g_variant_iter_free(resp_iter);
}
cb(status, nwk_count, start_index, nwk_list_count, (void **)records, container->userdata);
g_variant_get(parameters, "(qyyqqqa(y))", &addr16, &src_ep, &dst_ep,
&cluster_id, &profile_id, &payload_len, &payload_iter);
+ RETM_IF(NULL == payload_iter, "Invalid parameter !");
if (payload_len > 0) {
payload = calloc(payload_len+1, sizeof(unsigned char));
+
while (g_variant_iter_loop(payload_iter, "(y)", &value))
payload[i++] = value;
- if (NULL != payload_iter)
- g_variant_iter_free(payload_iter);
+ g_variant_iter_free(payload_iter);
}
cb(addr16, src_ep, dst_ep, cluster_id, profile_id, payload_len, payload,
g_variant_get(parameters, "(qyyqqqa(y))", &addr16, &src_ep, &dst_ep,
&cluster_id, &profile_id, &payload_len, &payload_iter);
+ RETM_IF(NULL == payload_iter, "Invalid parameter !");
if (payload_len > 0) {
payload = calloc(payload_len + 1, sizeof(unsigned char));
+
while (g_variant_iter_loop(payload_iter, "(y)", &value))
payload[i++] = value;
- if (NULL != payload_iter)
- g_variant_iter_free(payload_iter);
+ g_variant_iter_free(payload_iter);
}
cb(addr16, src_ep, dst_ep, cluster_id, profile_id, payload_len, payload,
int i = 0;
g_variant_get(parameters, "(qa(y))", &length, &payload_iter);
+ RETM_IF(NULL == payload_iter, "Invalid parameter !");
if (length > 0) {
data = calloc(length, sizeof(unsigned char));
+
while (g_variant_iter_loop(payload_iter, "(y)", &value))
data[i++] = value;
- if (NULL != payload_iter)
- g_variant_iter_free(payload_iter);
+ g_variant_iter_free(payload_iter);
}
cb(length, data, container->userdata);
struct read_attribute_status_record_s *records = NULL;
zb_global_record_data_s *data;
- data = calloc(1, sizeof(zb_global_record_data_s));
- records = calloc(1, sizeof(struct read_attribute_status_record_s));
-
- if (!records || !data) {
- ERR("calloc() Fail(%d)", errno);
- goto GLOBAL_READ_ATTRIBUTE_REQ_OUT;
- }
-
g_variant_get(parameters, "(qya(y)qqyyqi)",
&addr16, &ep, &iter, &attr_id, &cluster_id, &status, &type, &records_len, &isString);
+ RETM_IF(NULL == iter, "Invalid parameter !");
+
if (!isString) {
while (g_variant_iter_loop(iter, "(y)", &value)) {
attr_value[j] = value;
DBG("attr_value[%d] = 0x%02X", j, value);
j++;
}
- if (NULL != iter)
- g_variant_iter_free(iter);
+ g_variant_iter_free(iter);
} else {
while (g_variant_iter_loop(iter, "(y)", &value)) {
if (j == 0)
DBG("attr_value[%d] = 0x%02X", j, value);
j++;
}
- if (NULL != iter)
- g_variant_iter_free(iter);
+ g_variant_iter_free(iter);
+ }
+
+ data = calloc(1, sizeof(zb_global_record_data_s));
+ records = calloc(1, sizeof(struct read_attribute_status_record_s));
+
+ if (!records || !data) {
+ ERR("calloc() Fail(%d)", errno);
+ goto GLOBAL_READ_ATTRIBUTE_REQ_OUT;
}
records->id = attr_id;
g_variant_get(parameters, "(qya(y)aqqi)",
&addr16, &ep, &stat_iter, &attr_iter, &cluster_id, &records_len);
+ RETM_IF(NULL == stat_iter, "Invalid parameter !");
+ RETM_IF(NULL == attr_iter, "Invalid parameter !");
records = calloc(records_len, sizeof(struct write_attribute_status_record_s));
data = calloc(1, sizeof(zb_global_record_data_s));
if (!records || !data) {
- if (NULL != stat_iter)
- g_variant_iter_free(stat_iter);
- if (NULL != attr_iter)
- g_variant_iter_free(attr_iter);
+ g_variant_iter_free(stat_iter);
+ g_variant_iter_free(attr_iter);
ERR("calloc() Fail(%d)", errno);
goto GLOBAL_WRITE_ATTRIBUTE_REQ_OUT;
}
records[i].status = value;
i++;
}
- if (NULL != stat_iter)
- g_variant_iter_free(stat_iter);
+ g_variant_iter_free(stat_iter);
i = 0;
while (g_variant_iter_loop(attr_iter, "q", &attribute_id)) {
DBG("Attribute Id 0x%04X", attribute_id);
i++;
}
- if (NULL != attr_iter)
- g_variant_iter_free(attr_iter);
+ g_variant_iter_free(attr_iter);
data->type = ZB_GLOBAL_WRITE_ATTR;
data->record.write_attr = (void **)&records;
g_variant_get(parameters, "(a(y)aqa(y)qiqy)",
&stat_iter, &attr_iter, &dir_iter, &cluster_id, &rec_len, &addr16, &ep);
+ RETM_IF(NULL == stat_iter, "Invalid parameter !");
+ RETM_IF(NULL == attr_iter, "Invalid parameter !");
+ RETM_IF(NULL == dir_iter, "Invalid parameter !");
records = calloc(rec_len, sizeof(struct reporting_configuration_response_record_s));
data = calloc(1, sizeof(zb_global_record_data_s));
if (!data || !records) {
- if (NULL != stat_iter)
- g_variant_iter_free(stat_iter);
- if (NULL != attr_iter)
- g_variant_iter_free(attr_iter);
- if (NULL != dir_iter)
- g_variant_iter_free(dir_iter);
+ g_variant_iter_free(stat_iter);
+ g_variant_iter_free(attr_iter);
+ g_variant_iter_free(dir_iter);
ERR("calloc() Fail(%d)", errno);
goto GLOBAL_CONFIGURE_REPORTING_REQ_OUT;
}
records[j].status = value;
j++;
}
- if (NULL != stat_iter)
- g_variant_iter_free(stat_iter);
+ g_variant_iter_free(stat_iter);
while (g_variant_iter_loop(attr_iter, "q", &attIdVal)) {
if (records[l].status != ZB_ZCL_SUCCESS)
records[l].id = attIdVal;
l++;
}
- if (NULL != attr_iter)
- g_variant_iter_free(attr_iter);
+ g_variant_iter_free(attr_iter);
while (g_variant_iter_loop(dir_iter, "(y)", &value)) {
if (records[k].status != ZB_ZCL_SUCCESS)
records[k].dir = value;
k++;
}
- if (NULL != dir_iter)
- g_variant_iter_free(dir_iter);
+ g_variant_iter_free(dir_iter);
data->type = ZB_GLOBAL_CONFIG_REPORT;
data->record.report_config_rsp = (void **)&records;
g_variant_get(parameters, "(qya(y)aqqii)", &addr16, &ep, &stat_iter,
&attr_iter, &cluster_id, &records_len, &discovery_complete);
+ RETM_IF(NULL == stat_iter, "Invalid parameter !");
+ RETM_IF(NULL == attr_iter, "Invalid parameter !");
+
records = calloc(records_len, sizeof(discover_attr_info_record_h));
RETM_IF(NULL == records, "calloc() Fail(%d)", errno);
for (j = 0; j < records_len; j++) {
for (l = 0; l < j; l++)
free(records[l]);
free(records);
- if (NULL != stat_iter)
- g_variant_iter_free(stat_iter);
- if (NULL != attr_iter)
- g_variant_iter_free(attr_iter);
+ g_variant_iter_free(stat_iter);
+ g_variant_iter_free(attr_iter);
return;
}
}
DBG("Attribute Type 0x%02X", value);
j++;
}
- if (NULL != stat_iter)
- g_variant_iter_free(stat_iter);
+ g_variant_iter_free(stat_iter);
while (g_variant_iter_loop(attr_iter, "q", &attribute_id)) {
records[l]->id = attribute_id;
DBG("Attribute Id 0x%04X", attribute_id);
l++;
}
- if (NULL != attr_iter)
- g_variant_iter_free(attr_iter);
+ g_variant_iter_free(attr_iter);
cb(addr16, ep, cluster_id, discovery_complete, (void *)records, records_len,
container->userdata);
unsigned char discoveryComplete;
GVariantIter *cmd_iter = NULL;
- g_variant_get(parameters, "(a(y)qqqyy)", &cmd_iter, &cluster_id, &cmd_len,
+ g_variant_get(parameters, "(a(y)qqqyy)", &cmd_iter, &cluster_id, &cmd_len,
&addr16, &ep, &discoveryComplete);
+ RETM_IF(NULL == cmd_iter, "Invalid parameter !");
cmd_data = calloc(cmd_len+1, sizeof(char));
if (NULL == cmd_data) {
ERR("calloc() Fail(%d)", errno);
- if (NULL != cmd_iter)
- g_variant_iter_free(cmd_iter);
+ g_variant_iter_free(cmd_iter);
return;
}
cmd_data[j] = value;
j++;
}
- if (NULL != cmd_iter)
- g_variant_iter_free(cmd_iter);
+ g_variant_iter_free(cmd_iter);
cb(addr16, ep, cluster_id, discoveryComplete, cmd_data, cmd_len, container->userdata);
free(cmd_data);
g_variant_get(parameters, "(aqa(y)a(y)qqqyy)", &attr_iter, &type_iter, &ac_iter,
&cluster_id, &rec_len, &addr16, &ep, &discoveryComplete);
+ RETM_IF(NULL == attr_iter, "Invalid parameter !");
+ RETM_IF(NULL == type_iter, "Invalid parameter !");
+ RETM_IF(NULL == ac_iter, "Invalid parameter !");
DBG("records length 0x%04X", rec_len);
for (i = 0; i < j; i++)
free(records[i]);
free(records);
- if (NULL != attr_iter)
- g_variant_iter_free(attr_iter);
- if (NULL != type_iter)
- g_variant_iter_free(type_iter);
- if (NULL != ac_iter)
- g_variant_iter_free(ac_iter);
+
+ g_variant_iter_free(attr_iter);
+ g_variant_iter_free(type_iter);
+ g_variant_iter_free(ac_iter);
ERR("calloc() Fail(%d)", errno);
return;
records[j]->acl = ac_value;
j++;
}
- if (NULL != attr_iter)
- g_variant_iter_free(attr_iter);
- if (NULL != type_iter)
- g_variant_iter_free(type_iter);
- if (NULL != ac_iter)
- g_variant_iter_free(ac_iter);
+ g_variant_iter_free(attr_iter);
+ g_variant_iter_free(type_iter);
+ g_variant_iter_free(ac_iter);
cb(addr16, ep, cluster_id, discoveryComplete, (void *)records, rec_len, container->userdata);
g_variant_get(parameters, "(qyqqa(yyqyqqayq))",
&addr16, &ep, &cluster_id, &record_length, &resp_iter);
+ RETM_IF(NULL == resp_iter, "Invalid parameter !");
records = calloc(record_length, sizeof(report_config_record_h));
for (i = 0; i < record_length; i++) {
g_variant_iter_loop(resp_iter, "(yyqyqqayq)", &status[i], &records[i]->dir,
&records[i]->id, &records[i]->type, &records[i]->max_i, &records[i]->min_i,
&data_iter, &records[i]->to);
+ if (NULL == data_iter) {
+ ERR("Invalid parameter !");
+ goto GLOBAL_READ_CONFIGURE_REPORTING_REQ_OUT;
+ }
+
if (records[i]->dir != ZCL_REPORTING_DIRECTION_REPORTED &&
(zb_get_analog_or_discret(records[i]->type) == DATA_TYPE_ANALOG)) {
data_size[i] = zb_get_data_size(records[j]->type);
if (!change) {
ERR("calloc() Fail(%d)", errno);
records[i]->change = NULL;
- if (NULL != data_iter)
- g_variant_iter_free(data_iter);
- continue;
+ g_variant_iter_free(data_iter);
+ goto GLOBAL_READ_CONFIGURE_REPORTING_REQ_OUT;
}
+
while (g_variant_iter_loop(data_iter, "y", &value)) {
change[j] = value;
j++;
}
- if (NULL != data_iter)
- g_variant_iter_free(data_iter);
+ g_variant_iter_free(data_iter);
records[i]->change = change;
} else
records[i]->change = NULL;
} else
records[i]->change = NULL;
}
- if (NULL != resp_iter)
- g_variant_iter_free(resp_iter);
+ g_variant_iter_free(resp_iter);
data->type = ZB_GLOBAL_READ_REPORT_CONFIG;
data->record.report_config = (void **)records;
GLOBAL_READ_CONFIGURE_REPORTING_REQ_OUT:
free(data_size);
free(status);
- for (i = 0; i < record_length; i++)
- free(records[i]);
+ for (i = 0; i < record_length; i++) {
+ if (records[i] && records[i]->change)
+ free(records[i]->change);
+ if (records[i])
+ free(records[i]);
+ }
free(records);
free(data);
}
GVariantIter *grpNameiter = NULL;
g_variant_get(parameters, "(qyyqay)", &addr16, &ep, &status, &group_id, &grpNameiter);
+ if (NULL == grpNameiter) {
+ ERR("Invalid grpNameiter");
+ goto GROUP_VIEW_GROUP_REQ_OUT;
+ }
+
g_variant_iter_loop(grpNameiter, "y", &value);
/* first byte indicates the length of the string */
if ((value - '0') > 0) {
DBG("Value %d ", (value - '0'));
group_name = calloc((value - '0') + 1, sizeof(char));
if (NULL == group_name) {
- if (NULL != grpNameiter)
- g_variant_iter_free(grpNameiter);
+ g_variant_iter_free(grpNameiter);
ERR("calloc() Fail(%d)", errno);
goto GROUP_VIEW_GROUP_REQ_OUT;
}
DBG("Name %c", group_name[j]);
j++;
}
- if (NULL != grpNameiter)
- g_variant_iter_free(grpNameiter);
+ g_variant_iter_free(grpNameiter);
} else {
group_name = calloc(1, sizeof(char));
if (NULL == group_name) {
- if (NULL != grpNameiter)
- g_variant_iter_free(grpNameiter);
+ g_variant_iter_free(grpNameiter);
ERR("calloc() Fail(%d)", errno);
goto GROUP_VIEW_GROUP_REQ_OUT;
}
DBG("GroupName = %s", group_name);
cb(addr16, ep, status, group_id, group_name, container->userdata);
+
GROUP_VIEW_GROUP_REQ_OUT:
- free(group_name);
+ if (group_name)
+ free(group_name);
}
break;
case ZBL_ZCL_GROUP_GET_GROUP_MEMBERSHIP_REQ: {
GVariantIter *grpListiter = NULL;
g_variant_get(parameters, "(qyyyaq)", &addr16, &ep, &capacity, &group_count, &grpListiter);
+ RETM_IF(NULL == grpListiter, "Invalid parameter !");
if (group_count > 0) {
grouplist = calloc(group_count+1, sizeof(unsigned short));
if (NULL == grouplist) {
- if (NULL != grpListiter)
- g_variant_iter_free(grpListiter);
+ g_variant_iter_free(grpListiter);
ERR("calloc() Fail(%d)", errno);
return;
}
grouplist[j] = gl_value;
j++;
}
- if (NULL != grpListiter)
- g_variant_iter_free(grpListiter);
+ g_variant_iter_free(grpListiter);
}
cb(addr16, ep, capacity, group_count, grouplist, container->userdata);
g_variant_get(variant, "(ia(y)qqyy)", &result, &iter,
&_nodeid, &_panid, &_radio_channel, &_radio_tx_power);
+ RETVM_IF(NULL == iter, ZIGBEE_ERROR_IO_ERROR, "Invalid parameter !");
/* Get EUI */
i = 0;
addr64[i] = value;
i++;
}
+ g_variant_iter_free(iter);
DBG(" Result: [%X]", result);
DBG(" EUI(%d) : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", i,
if (tx_power)
*tx_power = _radio_tx_power;
- if (iter)
- g_variant_iter_free(iter);
g_variant_unref(variant);
return result;
return result;
}
g_variant_get(variant, "(ia(y))", &result, &iter);
+ RETVM_IF(NULL == iter, ZIGBEE_ERROR_IO_ERROR, "Invalid parameter !");
while (g_variant_iter_loop(iter, "(y)", &value)) {
addr64[j] = value;
j++;
}
+ g_variant_iter_free(iter);
DBG("IEEE ADDR 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X, Ret=%d ",
addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5],
addr64[6], addr64[7], result);
- if (iter)
- g_variant_iter_free(iter);
g_variant_unref(variant);
return result;
if (variant) {
g_variant_get(variant, "(iaqaq)", &result, &in_cluster_iter, &out_cluster_iter);
+ RETVM_IF(NULL == in_cluster_iter, ZIGBEE_ERROR_IO_ERROR, "Invalid parameter !");
+ RETVM_IF(NULL == out_cluster_iter, ZIGBEE_ERROR_IO_ERROR, "Invalid parameter !");
+
DBG("ret = [0x%x]", result);
/* In clusters */
DBG("In Cluster 0x%04X", cluster);
in_cluster_list[i++] = cluster;
}
+ g_variant_iter_free(in_cluster_iter);
*in_cluster_count = i;
if (0 == i)
ERR("No In Clusters for Endpoint %0X", endpoint);
DBG("Out Cluster 0x%04X", cluster);
out_cluster_list[i++] = cluster;
}
+ g_variant_iter_free(out_cluster_iter);
*out_cluster_count = i;
if (0 == i)
ERR("No Out Clusters for Endpoint %0X", endpoint);
- if (NULL != in_cluster_iter)
- g_variant_iter_free(in_cluster_iter);
- if (NULL != out_cluster_iter)
- g_variant_iter_free(out_cluster_iter);
g_variant_unref(variant);
} else {
ERR("No In/Out Clusters for Endpoint %0X [%s]", endpoint, dbus_err->message);
if (variant) {
g_variant_get(variant, "(ia(y))", &result, &iter);
+ RETVM_IF(NULL == iter, ZIGBEE_ERROR_IO_ERROR, "Invalid parameter !");
+
DBG("ret = [0x%x]", result);
while (g_variant_iter_loop(iter, "(y)", &endpoint)) {
DBG("Endpoint 0x%X", endpoint);
list[i++] = endpoint;
}
+ g_variant_iter_free(iter);
+
if (i > 0) {
*count = i;
DBG("Endpoint Count %d", i);
ERR("No Endpoints");
*count = 0;
}
- if (NULL != iter)
- g_variant_iter_free(iter);
g_variant_unref(variant);
} else {
if (variant) {
g_variant_get(variant, "(ia(qyayyay))", &result, &iter);
+ RETVM_IF(NULL == iter, ZIGBEE_ERROR_IO_ERROR, "Invalid parameter !");
+
DBG("ret = [0x%x]", result);
list = calloc(MAX_DEVICE_LIST+1, sizeof(zb_end_device_info_h));
for (i = 0; i < MAX_DEVICE_LIST && list; i++) {
list[i] = calloc(1, sizeof(struct zb_end_device_info_s));
if (NULL == list[i]) {
- for (j = 0; j < i; j++)
- free(list[j]);
+ for (j = 0; j < i; j++) {
+ if (list[j])
+ free(list[j]);
+ }
free(list);
g_variant_unref(variant);
return ZIGBEE_ERROR_OUT_OF_MEMORY;
i = 0;
while (g_variant_iter_loop(iter, "(qyayyay)", &node_id, &node_type, &mac_iter,
&endpoint_cnt, &endpoint_iter)) {
+ if (NULL == mac_iter || NULL == endpoint_iter) {
+ ERR("Invalid parameter !");
+ for (j = 0; j <= MAX_DEVICE_LIST; j++) {
+ if (list[j])
+ free(list[j]);
+ }
+ free(list);
+ g_variant_iter_free(iter);
+ if (NULL != mac_iter)
+ g_variant_iter_free(mac_iter);
+ if (NULL != endpoint_iter)
+ g_variant_iter_free(endpoint_iter);
+ g_variant_unref(variant);
+ return ZIGBEE_ERROR_IO_ERROR;
+ }
+
j = 0;
k = 0;
/* Get Network Address */
/* Get End-Point count */
list[i]->num_of_ep = endpoint_cnt;
DBG("Endpoint Count: 0x%X", endpoint_cnt);
+
/* Get End-Point list */
list[i]->num_of_ep = endpoint_cnt;
while (g_variant_iter_loop(endpoint_iter, "y", &value_endpoint)) {
DBG("Endpoint : %d", value_endpoint);
k++;
}
+ g_variant_iter_free(endpoint_iter);
+
/* Get IEEE address */
while (g_variant_iter_loop(mac_iter, "y", &value)) {
node_mac_address[j] = value;
j++;
}
+ g_variant_iter_free(mac_iter);
+
memcpy(list[i]->addr64, node_mac_address, sizeof(ieee_addr));
DBG("Node MAC Addr : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
node_mac_address[0], node_mac_address[1], node_mac_address[2],
node_mac_address[3], node_mac_address[4], node_mac_address[5],
node_mac_address[6], node_mac_address[7]);
i++;
-
}
if (0 == i)
ERR("No attached nodes");
*num = i;
*dev_list = (void **)list;
- if (NULL != iter)
- g_variant_iter_free(iter);
+
+ g_variant_iter_free(iter);
g_variant_unref(variant);
} else {
ERR("NULL Variant [%s]", dbus_err->message);