From 3f314bc183a62f44fcc89bc2d33201932cb27f7d Mon Sep 17 00:00:00 2001 From: xurui Date: Thu, 24 Oct 2024 18:47:33 +0800 Subject: [PATCH] output-power-management-v1: use enum_is_valid functions Signed-off-by: xurui --- types/wlr_output_power_management_v1.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/types/wlr_output_power_management_v1.c b/types/wlr_output_power_management_v1.c index 96e0b6028..25b92e40d 100644 --- a/types/wlr_output_power_management_v1.c +++ b/types/wlr_output_power_management_v1.c @@ -77,11 +77,8 @@ static void output_power_handle_set_mode(struct wl_client *client, return; } - switch (mode) { - case ZWLR_OUTPUT_POWER_V1_MODE_OFF: - case ZWLR_OUTPUT_POWER_V1_MODE_ON: - break; - default: + uint32_t version = wl_resource_get_version(output_power_resource); + if (!zwlr_output_power_v1_mode_is_valid(mode, version)) { wlr_log(WLR_ERROR, "Invalid power mode %d", mode); wl_resource_post_error(output_power_resource, ZWLR_OUTPUT_POWER_V1_ERROR_INVALID_MODE,