From d561e064a8940e14901cadc4ca5b9e26ab1e7f0e Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Wed, 7 Sep 2016 16:36:51 +0100 Subject: loader: separate USE_DRICONF code into separate function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improves readability and allows us to do further cleanups a lot easier. Signed-off-by: Emil Velikov Reviewed-by: Axel Davy Reviewed-by: Nicolai Hähnle --- src/loader/loader.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/loader/loader.c') diff --git a/src/loader/loader.c b/src/loader/loader.c index 320a393ecca..0aa86344603 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) { -- cgit v1.2.3