[Mesa-dev] [PATCH 03/16] loader: separate USE_DRICONF code into separate function

Emil Velikov emil.l.velikov at gmail.com
Tue Oct 11 18:31:47 UTC 2016


From: Emil Velikov <emil.velikov at collabora.com>

Improves readability and allows us to do further cleanups a lot easier.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/loader/loader.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/loader/loader.c b/src/loader/loader.c
index 41ea016..72b510f 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -303,15 +303,27 @@ DRI_CONF_BEGIN
         DRI_CONF_DEVICE_ID_PATH_TAG()
     DRI_CONF_SECTION_END
 DRI_CONF_END;
-#endif
 
-int loader_get_user_preferred_fd(int default_fd, int *different_device)
+static char *loader_get_dri_config_device_id(void)
 {
-   struct udev *udev;
-#ifdef USE_DRICONF
    driOptionCache defaultInitOptions;
    driOptionCache userInitOptions;
+   char *prime = NULL;
+
+   driParseOptionInfo(&defaultInitOptions, __driConfigOptionsLoader);
+   driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0, "loader");
+   if (driCheckOption(&userInitOptions, "device_id", DRI_STRING))
+      prime = strdup(driQueryOptionstr(&userInitOptions, "device_id"));
+   driDestroyOptionCache(&userInitOptions);
+   driDestroyOptionInfo(&defaultInitOptions);
+
+   return prime;
+}
 #endif
+
+int loader_get_user_preferred_fd(int default_fd, int *different_device)
+{
+   struct udev *udev;
    const char *dri_prime = getenv("DRI_PRIME");
    char *prime = NULL;
    int is_different_device = 0, fd = default_fd;
@@ -324,14 +336,8 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device)
    if (dri_prime)
       prime = strdup(dri_prime);
 #ifdef USE_DRICONF
-   else {
-      driParseOptionInfo(&defaultInitOptions, __driConfigOptionsLoader);
-      driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0, "loader");
-      if (driCheckOption(&userInitOptions, "device_id", DRI_STRING))
-         prime = strdup(driQueryOptionstr(&userInitOptions, "device_id"));
-      driDestroyOptionCache(&userInitOptions);
-      driDestroyOptionInfo(&defaultInitOptions);
-   }
+   else
+      prime = loader_get_dri_config_device_id();
 #endif
 
    if (prime == NULL) {
-- 
2.10.0



More information about the mesa-dev mailing list