From: Christophe CURIS <christophe.cu...@free.fr> The original code merely assumed that an XOpenDisplay failure was caused only by incapacity to connect to the X server, but if $DISPLAY was not set then the fprintf would be given a NULL pointer which it may not appreciate (depending on the libc in use). Let's avoid that case and try to provide more info to help the user.
Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> --- wmix/wmix.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/wmix/wmix.c b/wmix/wmix.c index 5e31b5d..eed28b6 100644 --- a/wmix/wmix.c +++ b/wmix/wmix.c @@ -161,8 +161,20 @@ int main(int argc, char **argv) mixer_init(mixer_device, verbose, (const char **)exclude); mixer_set_channel(0); - if ((display = XOpenDisplay(display_name)) == NULL) { - fprintf(stderr, "Unable to open display \"%s\"\n", display_name); + display = XOpenDisplay(display_name); + if (display == NULL) { + const char *name; + + if (display_name) { + name = display_name; + } else { + name = getenv("DISPLAY"); + if (name == NULL) { + fprintf(stderr, "wmix:error: Unable to open display, variable $DISPLAY not set\n"); + return EXIT_FAILURE; + } + } + fprintf(stderr, "wmix:error: Unable to open display \"%s\"\n", name); return EXIT_FAILURE; } display_width = (float)DisplayWidth(display, DefaultScreen(display)) / 4.0; -- 1.9.2 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.