test: move the unhandled event type assertion out of the switch

All the switch cases return early, moving it here means we can drop the
default case and have the compiler warn us about missing cases.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2021-08-23 12:58:22 +10:00
parent 5ae3b78689
commit ae6dbbe61c
3 changed files with 14 additions and 9 deletions

View file

@ -134,6 +134,8 @@ log_wire_message(struct ei *ei, const ClientMessage *msg, int error)
case CLIENT_MESSAGE__MSG_##_name: message = #_name; break;
switch (msg->msg_case) {
case _CLIENT_MESSAGE__MSG_IS_INT_SIZE: /* protobuf-internal thing */
return;
case CLIENT_MESSAGE__MSG__NOT_SET:
abort();
MSG_STRING_CASE(CONNECT);
@ -152,10 +154,10 @@ log_wire_message(struct ei *ei, const ClientMessage *msg, int error)
MSG_STRING_CASE(TOUCH_UP);
MSG_STRING_CASE(CONFIGURE_NAME);
MSG_STRING_CASE(CONFIGURE_CAPS);
default:
assert(!"Unimplemented message type");
break;
}
if (message == NULL)
assert(!"Unimplemented message type");
log_debug(ei, "sending wire message %s (%s)\n", message,
strerror(-error));

View file

@ -34,6 +34,8 @@
static void
eis_event_destroy(struct eis_event *event)
{
bool handled = false;
switch (event->type) {
case EIS_EVENT_CLIENT_CONNECT:
case EIS_EVENT_CLIENT_DISCONNECT:
@ -49,10 +51,13 @@ eis_event_destroy(struct eis_event *event)
case EIS_EVENT_TOUCH_DOWN:
case EIS_EVENT_TOUCH_MOTION:
case EIS_EVENT_TOUCH_UP:
handled = true;
break;
default:
abort(); /* not yet implemented */
}
if (!handled)
abort(); /* not yet implemented */
event->device = eis_device_unref(event->device);
event->seat = eis_seat_unref(event->seat);
event->client = eis_client_unref(event->client);

View file

@ -943,10 +943,9 @@ peck_ei_event_type_name(enum ei_event_type type)
CASE_STRING(DEVICE_REMOVED);
CASE_STRING(DEVICE_PAUSED);
CASE_STRING(DEVICE_RESUMED);
default:
assert(!"Unhandled ei event type");
}
#undef CASE_STRING
assert(!"Unhandled ei event type");
}
const char *
@ -974,8 +973,7 @@ peck_eis_event_type_name(enum eis_event_type type)
CASE_STRING(TOUCH_DOWN);
CASE_STRING(TOUCH_UP);
CASE_STRING(TOUCH_MOTION);
default:
assert(!"Unhandled EIS event type");
}
#undef CASE_STRING
assert(!"Unhandled EIS event type");
}