mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-29 23:24:20 +08:00
android/health: Fix queue creation for mdeps and devices
Create queue for mdeps, devices and channels when creating app and device struct. It is simpler to read code than on demand creation.
This commit is contained in:
parent
8050837e01
commit
8ec0f87fea
@ -678,6 +678,14 @@ static struct health_app *create_health_app(const char *app_name,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
app->mdeps = queue_new();
|
||||
if (!app->mdeps)
|
||||
goto fail;
|
||||
|
||||
app->devices = queue_new();
|
||||
if (!app->devices)
|
||||
goto fail;
|
||||
|
||||
return app;
|
||||
|
||||
fail:
|
||||
@ -784,14 +792,6 @@ static void bt_health_mdep_cfg_data(const void *buf, uint16_t len)
|
||||
memcpy(mdep->descr, cmd->descr, cmd->descr_len);
|
||||
}
|
||||
|
||||
if (app->num_of_mdep > 0 && !app->mdeps) {
|
||||
app->mdeps = queue_new();
|
||||
if (!app->mdeps) {
|
||||
status = HAL_STATUS_FAILED;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (!queue_push_tail(app->mdeps, mdep)) {
|
||||
status = HAL_STATUS_FAILED;
|
||||
goto fail;
|
||||
@ -1102,6 +1102,11 @@ static struct health_device *create_device(uint16_t app_id, const uint8_t *addr)
|
||||
|
||||
android2bdaddr(addr, &dev->dst);
|
||||
dev->app_id = app_id;
|
||||
dev->channels = queue_new();
|
||||
if (!dev->channels) {
|
||||
free_health_device(dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return dev;
|
||||
}
|
||||
@ -1159,21 +1164,9 @@ static void bt_health_connect_channel(const void *buf, uint16_t len)
|
||||
|
||||
channel->dev = dev;
|
||||
|
||||
if (!app->devices) {
|
||||
app->devices = queue_new();
|
||||
if (!app->devices)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!queue_push_tail(app->devices, dev))
|
||||
goto fail;
|
||||
|
||||
if (!dev->channels) {
|
||||
dev->channels = queue_new();
|
||||
if (!dev->channels)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!queue_push_tail(dev->channels, channel)) {
|
||||
queue_remove(app->devices, dev);
|
||||
goto fail;
|
||||
|
Loading…
Reference in New Issue
Block a user