From 841fc7c6443f0fab36498aff5f29c6f0274a97d2 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 17 Oct 2023 14:31:53 +0100 Subject: [PATCH] t/common: Refactor QWERTY builder [NFC] --- .../targets/common/target_builder_qwerty.c | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/xrt/targets/common/target_builder_qwerty.c b/src/xrt/targets/common/target_builder_qwerty.c index 50c964dde..c02704d28 100644 --- a/src/xrt/targets/common/target_builder_qwerty.c +++ b/src/xrt/targets/common/target_builder_qwerty.c @@ -87,21 +87,33 @@ qwerty_open_system(struct xrt_builder *xb, return xret; } - struct u_system_devices *usysd = u_system_devices_allocate(); - usysd->base.roles.head = head; - usysd->base.roles.left = left; - usysd->base.roles.right = right; + struct xrt_system_devices *xsysd = NULL; + { + struct u_system_devices *usysds = u_system_devices_allocate(); + xsysd = &usysds->base; + } - usysd->base.xdevs[usysd->base.xdev_count++] = head; + // Add to device list. + xsysd->xdevs[xsysd->xdev_count++] = head; if (left != NULL) { - usysd->base.xdevs[usysd->base.xdev_count++] = left; + xsysd->xdevs[xsysd->xdev_count++] = left; } if (right != NULL) { - usysd->base.xdevs[usysd->base.xdev_count++] = right; + xsysd->xdevs[xsysd->xdev_count++] = right; } - *out_xsysd = &usysd->base; - u_builder_create_space_overseer(&usysd->base, out_xso); + // Assign to role(s). + xsysd->roles.head = head; + xsysd->roles.left = left; + xsysd->roles.right = right; + + + /* + * Done. + */ + + *out_xsysd = xsysd; + u_builder_create_space_overseer(xsysd, out_xso); return XRT_SUCCESS; }