tools/l2cap-tester: Fix checking for write() return values

This commit is contained in:
Johan Hedberg 2013-12-20 10:26:18 +02:00
parent a663775dbf
commit 33eb51c937

View File

@ -608,12 +608,17 @@ static gboolean l2cap_connect_cb(GIOChannel *io, GIOCondition cond,
return FALSE;
} else if (l2data->write_data) {
struct bthost *bthost;
ssize_t ret;
bthost = hciemu_client_get_host(data->hciemu);
bthost_add_cid_hook(bthost, data->handle, data->dcid,
bthost_received_data, NULL);
write(sk, l2data->write_data, l2data->data_len);
ret = write(sk, l2data->write_data, l2data->data_len);
if (ret != l2data->data_len) {
tester_warn("Unable to write all data");
tester_test_failed();
}
return FALSE;
}
@ -780,14 +785,20 @@ static gboolean l2cap_listen_cb(GIOChannel *io, GIOCondition cond,
return FALSE;
} else if (l2data->write_data) {
struct bthost *bthost;
ssize_t ret;
bthost = hciemu_client_get_host(data->hciemu);
bthost_add_cid_hook(bthost, data->handle, data->scid,
server_bthost_received_data, NULL);
write(new_sk, l2data->write_data, l2data->data_len);
ret = write(new_sk, l2data->write_data, l2data->data_len);
close(new_sk);
if (ret != l2data->data_len) {
tester_warn("Unable to write all data");
tester_test_failed();
}
return FALSE;
}