[PATCH:app/xlsclients] Fix check for xcb_connect failure

View: New views
2 Messages — Rating Filter:   Alert me  

[PATCH:app/xlsclients] Fix check for xcb_connect failure

by Alan Coopersmith :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Prevents core dump when display can't be opened

Signed-off-by: Alan Coopersmith <alan.coopersmith@...>
---
 xlsclients.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/xlsclients.c b/xlsclients.c
index 049bc4c..00657aa 100644
--- a/xlsclients.c
+++ b/xlsclients.c
@@ -178,7 +178,7 @@ main(int argc, char *argv[])
     }
 
     dpy = xcb_connect(displayname, &screen_number);
-    if (!dpy) {
+    if (xcb_connection_has_error(dpy)) {
  char *name = displayname;
  if (!name)
     name = getenv("DISPLAY");
--
1.5.6.5

_______________________________________________
Xcb mailing list
Xcb@...
http://lists.freedesktop.org/mailman/listinfo/xcb

Re: [PATCH:app/xlsclients] Fix check for xcb_connect failure

by Alan Coopersmith :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I got no feedback, but it worked for me, so I went ahead and pushed.
I couldn't see an example of this in the tutorial or documentation,
perhaps that should be added?

        -alan

Alan Coopersmith wrote:

> Prevents core dump when display can't be opened
>
> Signed-off-by: Alan Coopersmith <alan.coopersmith@...>
> ---
>  xlsclients.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/xlsclients.c b/xlsclients.c
> index 049bc4c..00657aa 100644
> --- a/xlsclients.c
> +++ b/xlsclients.c
> @@ -178,7 +178,7 @@ main(int argc, char *argv[])
>      }
>  
>      dpy = xcb_connect(displayname, &screen_number);
> -    if (!dpy) {
> +    if (xcb_connection_has_error(dpy)) {
>   char *name = displayname;
>   if (!name)
>      name = getenv("DISPLAY");

--
        -Alan Coopersmith-           alan.coopersmith@...
         Sun Microsystems, Inc. - X Window System Engineering

_______________________________________________
Xcb mailing list
Xcb@...
http://lists.freedesktop.org/mailman/listinfo/xcb