From dd0f3c6dc234b1b8b4a3943cbba212de7dadbd76 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 25 Jul 2012 10:53:36 +0200 Subject: 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 --- src/context.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/context.c') 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; } -- cgit v1.2.1