[PATCH wayland 1/2] client: require XDG_RUNTIME_DIR
Pekka Paalanen
ppaalanen at gmail.com
Wed Jun 6 04:30:18 PDT 2012
An arbitrary fallback to the current directory is only confusing.
Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
src/wayland-client.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/wayland-client.c b/src/wayland-client.c
index ecedd99..bba972e 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -308,16 +308,15 @@ connect_to_socket(struct wl_display *display, const char *name)
const char *runtime_dir;
size_t name_size;
- display->fd = wl_os_socket_cloexec(PF_LOCAL, SOCK_STREAM, 0);
- if (display->fd < 0)
- return -1;
-
runtime_dir = getenv("XDG_RUNTIME_DIR");
- if (runtime_dir == NULL) {
- runtime_dir = ".";
+ if (!runtime_dir) {
fprintf(stderr,
- "XDG_RUNTIME_DIR not set, falling back to %s\n",
- runtime_dir);
+ "error: XDG_RUNTIME_DIR not set in the environment.\n");
+
+ /* to prevent programs reporting
+ * "failed to create display: Success" */
+ errno = ENOENT;
+ return -1;
}
if (name == NULL)
@@ -325,6 +324,10 @@ connect_to_socket(struct wl_display *display, const char *name)
if (name == NULL)
name = "wayland-0";
+ display->fd = wl_os_socket_cloexec(PF_LOCAL, SOCK_STREAM, 0);
+ if (display->fd < 0)
+ return -1;
+
memset(&addr, 0, sizeof addr);
addr.sun_family = AF_LOCAL;
name_size =
--
1.7.3.4
More information about the wayland-devel
mailing list