summaryrefslogtreecommitdiff
path: root/src/context.c
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2012-07-25 10:53:36 +0200
committerDaniel Stone <daniel@fooishbar.org>2012-07-27 11:59:55 +0200
commitdd0f3c6dc234b1b8b4a3943cbba212de7dadbd76 (patch)
treea012a3694aab848b39243c0eb8e052c3b8ec5436 /src/context.c
parentca7927ae60ad70ebd5bef5cc3644ddcbeaa6dd06 (diff)
downloadxorg-lib-libxkbcommon-dd0f3c6dc234b1b8b4a3943cbba212de7dadbd76.tar.gz
Don't create contexts with no include paths
Clean up the return code handling from xkb_context_add_include_paths_default, and thus fail context creation if we can't add any of the default include paths, but were asked to. If this happens, dump the DFLT_XKB_CONFIG_ROOT out in the log message, so at least we know what we aren't looking at. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'src/context.c')
-rw-r--r--src/context.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/context.c b/src/context.c
index 2f2301b..e373d1a 100644
--- a/src/context.c
+++ b/src/context.c
@@ -93,19 +93,20 @@ xkb_context_include_path_append_default(struct xkb_context *ctx)
const char *home;
char *user_path;
int err;
+ int ret = 0;
- (void) xkb_context_include_path_append(ctx, DFLT_XKB_CONFIG_ROOT);
+ ret |= xkb_context_include_path_append(ctx, DFLT_XKB_CONFIG_ROOT);
home = getenv("HOME");
if (!home)
- return 1;
+ return ret;
err = asprintf(&user_path, "%s/.xkb", home);
if (err <= 0)
- return 1;
- (void) xkb_context_include_path_append(ctx, user_path);
+ return ret;
+ ret |= xkb_context_include_path_append(ctx, user_path);
free(user_path);
- return 1;
+ return ret;
}
/**
@@ -279,6 +280,8 @@ xkb_context_new(enum xkb_context_flags flags)
if (!(flags & XKB_CONTEXT_NO_DEFAULT_INCLUDES) &&
!xkb_context_include_path_append_default(ctx)) {
+ log_err(ctx, "failed to add default include path %s\n",
+ DFLT_XKB_CONFIG_ROOT);
xkb_context_unref(ctx);
return NULL;
}