From fca4ac41e5f3fdfd70869aadc0434f913b8cbcde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20L=C3=BCssing?= Date: Thu, 8 Jun 2023 21:46:13 +0200 Subject: [PATCH] d/wmr: avoid using non-self-explanatory numbers for input allocations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By using an extra, final entry in the according inputs enum instead of using a hard coded number it should be slightly safer and easier to verify that the to be allocated inputs array is of correct size. No functional change. Signed-off-by: Linus Lüssing --- src/xrt/drivers/wmr/wmr_controller_hp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/xrt/drivers/wmr/wmr_controller_hp.c b/src/xrt/drivers/wmr/wmr_controller_hp.c index 5c7034e96..d94fbf080 100644 --- a/src/xrt/drivers/wmr/wmr_controller_hp.c +++ b/src/xrt/drivers/wmr/wmr_controller_hp.c @@ -50,6 +50,8 @@ enum wmr_controller_hp_input_index WMR_CONTROLLER_INDEX_AIM_POSE, WMR_CONTROLLER_INDEX_X_A_CLICK, WMR_CONTROLLER_INDEX_Y_B_CLICK, + /* keep as last: */ + WMR_CONTROLLER_INDEX_COUNT }; #define SET_INPUT(wcb, INDEX, NAME) \ @@ -315,7 +317,8 @@ wmr_controller_hp_create(struct wmr_controller_connection *conn, DRV_TRACE_MARKER(); enum u_device_alloc_flags flags = U_DEVICE_ALLOC_TRACKING_NONE; - struct wmr_controller_hp *ctrl = U_DEVICE_ALLOCATE(struct wmr_controller_hp, flags, 11, 1); + struct wmr_controller_hp *ctrl = + U_DEVICE_ALLOCATE(struct wmr_controller_hp, flags, WMR_CONTROLLER_INDEX_COUNT, 1); struct wmr_controller_base *wcb = (struct wmr_controller_base *)(ctrl); if (!wmr_controller_base_init(wcb, conn, controller_type, log_level)) {