Replace remaining errno-based errors to proper brei_results

This commit is contained in:
Peter Hutterer 2023-02-21 11:01:14 +10:00
parent a6565fd86b
commit 403e40597d
3 changed files with 13 additions and 8 deletions

View file

@ -284,8 +284,10 @@ client_msg_disconnect(struct eis_connection *connection)
static struct brei_result *
client_msg_sync(struct eis_connection *connection, uint32_t new_id)
{
if (new_id == 0)
return brei_result_new_from_neg_errno(-EINVAL);
if (new_id == 0) {
return brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_VALUE,
"Invalid object id zero for ei_connection.sync");
}
struct eis_client *client = eis_connection_get_client(connection);
struct eis_callback *callback = eis_callback_new(client, new_id, client->interface_versions.ei_callback);

View file

@ -91,7 +91,8 @@ client_msg_done(struct eis_connection_setup *setup)
if (setup->client_versions.ei_connection == 0 ||
setup->client_versions.ei_callback == 0 ||
setup->client_versions.ei_pingpong == 0)
return brei_result_new_from_neg_errno(-EPROTO);
return brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_PROTOCOL,
"Missing versions for required interfaces");
/* ei_callback needs a client-created object, so tell the client
* about our version */
@ -124,7 +125,7 @@ static struct brei_result *
client_msg_name(struct eis_connection_setup *setup, const char *name)
{
if (setup->name)
return brei_result_new_from_neg_errno(-EPROTO);
return brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_PROTOCOL, "Duplicate client name");
setup->name = xstrdup(name);
@ -141,7 +142,7 @@ client_msg_context_type(struct eis_connection_setup *setup, uint32_t type)
return 0;
}
return brei_result_new_from_neg_errno(-EPROTO);
return brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_VALUE, "Invalid context type %u", type);
}
static struct brei_result *
@ -174,14 +175,15 @@ client_msg_interface_version(struct eis_connection_setup *setup, const char *nam
log_debug(eis, "client %#x supports %s version %u", client->id, name, version);
if (version == 0)
return brei_result_new_from_neg_errno(-EPROTO);
return brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_VALUE, "Invalid %s version %u", name, version);
struct v *v;
ARRAY_FOR_EACH(version_map, v) {
if (streq(v->name, name)) {
/* Versions must not be set twice */
if (*v->client_version != 0)
return brei_result_new_from_neg_errno(-EPROTO);
return brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_PROTOCOL,
"Duplicate %s version", name);
*v->client_version = min(*v->server_version, version);
return 0;
}

View file

@ -106,7 +106,8 @@ client_msg_bind(struct eis_seat *seat, uint32_t caps)
allowed_caps |= EIS_SEAT_CAPABILITIES_TOUCHSCREEN;
if (caps & ~allowed_caps)
return brei_result_new_from_neg_errno(-EINVAL);
return brei_result_new(EIS_CONNECTION_DISCONNECT_REASON_VALUE,
"Invalid capabilities %#x", caps);
eis_seat_bind(seat, caps);