diff options
| author | Chia-I Wu <olvaffe@gmail.com> | 2014-08-04 11:18:20 +0800 |
|---|---|---|
| committer | Chia-I Wu <olvaffe@gmail.com> | 2014-08-04 11:20:32 +0800 |
| commit | 2cc903fee5fd553daa059b915b2d36bb1c562fbb (patch) | |
| tree | e4cd9f38bed47b66ba912d6a287defdd1fb71776 /loader/loader.c | |
| parent | b24001fa07666db886737f8abc9cd07e89df026a (diff) | |
| download | usermoji-2cc903fee5fd553daa059b915b2d36bb1c562fbb.tar.xz | |
loader: refactor loader_icd_scan()
Move ICD loading to loader_icd_add().
Diffstat (limited to 'loader/loader.c')
| -rw-r--r-- | loader/loader.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/loader/loader.c b/loader/loader.c index a90d6560..b5699656 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -24,14 +24,13 @@ #include <stdio.h> #include <stdlib.h> -#include <dirent.h> #include <stdarg.h> #include <stdbool.h> #include <string.h> -#include <sys/syscall.h> +#include <sys/types.h> +#include <dirent.h> #include <unistd.h> - #include <dlfcn.h> #include <pthread.h> @@ -256,6 +255,28 @@ static XGL_RESULT loader_icd_set_global_options(const struct loader_icd *icd) return XGL_SUCCESS; } +static struct loader_icd *loader_icd_add(const char *filename) +{ + struct loader_icd *icd; + + icd = loader_icd_create(filename); + if (!icd) + return NULL; + + if (loader_icd_set_global_options(icd) != XGL_SUCCESS || + loader_icd_register_msg_callbacks(icd) != XGL_SUCCESS) { + loader_log(XGL_DBG_MSG_WARNING, 0, + "%s ignored: failed to migrate settings", filename); + loader_icd_destroy(icd); + } + + /* prepend to the list */ + icd->next = loader.icds; + loader.icds = icd; + + return icd; +} + #ifndef DEFAULT_XGL_DRIVERS_PATH // TODO: Is this a good default location? // Need to search for both 32bit and 64bit ICDs @@ -305,23 +326,8 @@ static void loader_icd_scan(void) while (dent) { /* look for ICDs starting with "libXGL_" */ if (!strncmp(dent->d_name, "libXGL_", 7)) { - struct loader_icd *icd; - snprintf(icd_library, 1024, "%s/%s",p,dent->d_name); - - icd = loader_icd_create(icd_library); - if (icd) { - if (XGL_SUCCESS == loader_icd_set_global_options(icd) && - XGL_SUCCESS == loader_icd_register_msg_callbacks(icd)) { - /* prepend to the list */ - icd->next = loader.icds; - loader.icds = icd; - } else { - loader_log(XGL_DBG_MSG_WARNING, 0, - "%s ignored: failed to migrate settings", icd_library); - loader_icd_destroy(icd); - } - } + loader_icd_add(icd_library); } dent = readdir(sysdir); |
