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

hwsim: Radio id was not parsed properly

When a new radio is created, the kernel returns the new radio id
in the error code. If the error < 0, then that means a real error
and other values are used as a radio id.

When a radio is destroyed, the error code 0 means a success and
other values indicate an error.
This commit is contained in:
Jukka Rissanen 2014-10-07 15:07:15 +03:00 committed by Denis Kenzior
parent 89bacdbc08
commit a052cb5d3c

View File

@ -80,25 +80,25 @@ static void create_callback(struct l_genl_msg *msg, void *user_data)
const void *data;
uint32_t radio_id = 0;
/* Note that the radio id is returned in the error field of
* the returned message.
*/
if (!l_genl_attr_init(&attr, msg)) {
l_warn("Failed to initialize create return attributes");
int err = l_genl_msg_get_error(msg);
if (err < 0) {
l_warn("Failed to initialize create return attributes"
" [%d/%s]", -err, strerror(-err));
goto done;
}
while (l_genl_attr_next(&attr, &type, &len, &data)) {
switch (type) {
case HWSIM_ATTR_RADIO_ID:
if (len != sizeof(uint32_t)) {
l_warn("Invalid radio id attribute");
return;
}
radio_id = *((uint32_t *) data);
break;
}
}
radio_id = err;
l_info("Created new radio with id %u", radio_id);
} else {
l_warn("Failed to get create return value");
goto done;
}
done:
l_main_quit();
@ -111,14 +111,19 @@ static void destroy_callback(struct l_genl_msg *msg, void *user_data)
const void *data;
if (!l_genl_attr_init(&attr, msg)) {
l_warn("Failed to initialize destroy return attributes");
int err = l_genl_msg_get_error(msg);
if (err < 0) {
l_warn("Failed to destroy radio [%d/%s]",
-err, strerror(-err));
goto done;
}
l_info("Destroyed radio");
}
while (l_genl_attr_next(&attr, &type, &len, &data)) {
}
l_info("Destroyed radio");
done:
l_main_quit();