On Fri, May 14, 2010 at 13:10:36 -0700, Jeremy Huddleston wrote:

> @@ -164,10 +164,32 @@ XOpenDisplay (
>  
>  #if USE_XCB
>       if(!_XConnectXCB(dpy, display, &fullname, &iscreen)) {
> +             /* Try falling back on other transports if no transport 
> specified */
> +             const char *slash = strrchr(display_name, '/');
> +             if(slash == NULL) {
> +                     const char *protocols[] = {"local", "unix", "tcp", 
> "inet6", "inet", NULL};
> +                     const char **s;
> +                     size_t buf_size = strlen(display_name) + 7; // max 
> strlen + 2 (null + /)
> +                     char *buf = (char *)Xcalloc(buf_size, sizeof(char));
> +

The cast is not necessary, and I think Xmalloc(buf_size) would be enough
since we'll initialize that buffer with snprintf below anyway.

> +                     if(!buf) {
> +                             dpy->display_name = fullname;
> +                             OutOfMemory(dpy, NULL);
> +                             return NULL;
> +                     }
> +                     
> +                     for(s = protocols; *s; s++) {
> +                             snprintf(buf, buf_size, "%s/%s", *s, 
> display_name);
> +                             if(_XConnectXCB(dpy, buf, &fullname, &iscreen))
> +                                     goto fallback_success;
> +                     }
> +             }
> +
>               dpy->display_name = fullname;
>               OutOfMemory(dpy, NULL);
>               return NULL;
>       }
> +fallback_success:
>  #else /* !USE_XCB */
>       if ((dpy->trans_conn = _X11TransConnectDisplay (
>                                        display_name, &fullname, &idisplay,

Cheers,
Julien
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to