3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 14:49:24 +01:00

device: Rework device_hidden_network_scan_results

Rework the logic slightly to simplify the need for error labels.  Also
the connect_pending variable might not have been properly reset to NULL
in case of error, so make sure we reset it prior to calling into
network_connect_new_hidden_network
This commit is contained in:
Denis Kenzior 2018-07-11 15:59:26 -05:00
parent d8c8ebdf3a
commit d744915534

View File

@ -2150,21 +2150,24 @@ static bool device_hidden_network_scan_results(uint32_t wiphy_id,
struct network *network;
const char *ssid;
uint8_t ssid_len;
struct l_dbus_message *reply;
struct l_dbus_message *msg;
struct timespec now;
struct scan_bss *bss;
l_debug("");
msg = device->connect_pending;
device->connect_pending = NULL;
if (err) {
reply = dbus_error_failed(device->connect_pending);
goto bss_list_not_owned_error;
dbus_pending_reply(&msg, dbus_error_failed(msg));
return false;
}
if (!l_dbus_message_get_arguments(device->connect_pending, "s",
&ssid)) {
reply = dbus_error_invalid_args(device->connect_pending);
goto bss_list_not_owned_error;
dbus_pending_reply(&msg, dbus_error_invalid_args(msg));
return false;
}
clock_gettime(CLOCK_REALTIME, &now);
@ -2191,32 +2194,21 @@ next:
network_open = device_network_find(device, ssid, SECURITY_NONE);
if (!network_psk && !network_open) {
reply = dbus_error_not_found(device->connect_pending);
goto bss_list_owned_error;
dbus_pending_reply(&msg, dbus_error_not_found(msg));
return true;
}
if (network_psk && network_open) {
reply = dbus_error_service_set_overlap(device->connect_pending);
goto bss_list_owned_error;
dbus_pending_reply(&msg, dbus_error_service_set_overlap(msg));
return true;
}
network = network_psk ? : network_open;
network_connect_new_hidden_network(network, device->connect_pending);
l_dbus_message_unref(device->connect_pending);
l_dbus_message_unref(msg);
return true;
bss_list_owned_error:
dbus_pending_reply(&device->connect_pending, reply);
return true;
bss_list_not_owned_error:
dbus_pending_reply(&device->connect_pending, reply);
return false;
}
static struct l_dbus_message *device_connect_hidden_network(struct l_dbus *dbus,