Don't create contexts with no include paths
authorDaniel Stone <daniel@fooishbar.org>
Wed, 25 Jul 2012 08:53:36 +0000 (10:53 +0200)
committerDaniel Stone <daniel@fooishbar.org>
Fri, 27 Jul 2012 09:59:55 +0000 (11:59 +0200)
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>
src/context.c

index 2f2301ba8fccdc39981fb430d634b71373f9bab3..e373d1ab068443625892e102c7e93c9bf34e35a9 100644 (file)
@@ -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;
     }