From 005912d82f290aa2556a43ef86dd16b666644443 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 8 Jan 2024 13:14:06 +0100 Subject: [PATCH] xwayland/glamor/gbm: simplify render node check No need to call is_device_path_render_node() on each node, the index is the node type. Saves a couple of open()/close()/IOCTLs. Signed-off-by: Simon Ser Part-of: --- hw/xwayland/xwayland-glamor-gbm.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c index 30eb953d6..975733235 100644 --- a/hw/xwayland/xwayland-glamor-gbm.c +++ b/hw/xwayland/xwayland-glamor-gbm.c @@ -861,21 +861,17 @@ static const char * get_render_node_path_for_device(const drmDevicePtr drm_device, const char *device_path) { - char *render_node_path = NULL; - char device_found = 0; + const char *render_node_path; int i; + if (!(drm_device->available_nodes & (1 << DRM_NODE_RENDER))) + return NULL; + render_node_path = drm_device->nodes[DRM_NODE_RENDER]; + for (i = 0; i < DRM_NODE_MAX; i++) { - if ((drm_device->available_nodes & (1 << i)) == 0) - continue; - - if (!strcmp (device_path, drm_device->nodes[i])) - device_found = 1; - - if (is_device_path_render_node(drm_device->nodes[i])) - render_node_path = drm_device->nodes[i]; - - if (device_found && render_node_path) + if (!(drm_device->available_nodes & (1 << i))) + continue; + if (strcmp(device_path, drm_device->nodes[i]) == 0) return render_node_path; }