[Xcb-commit] 3 commits - configure.ac src

Alan Coopersmith alanc at kemper.freedesktop.org
Wed Aug 29 22:01:36 PDT 2012


 configure.ac    |    7 +++++++
 src/c_client.py |    3 +++
 src/xcb.h       |    4 ++++
 src/xcb_conn.c  |    9 +++++++++
 src/xcb_ext.c   |    4 ++++
 src/xcb_in.c    |    4 ++++
 src/xcb_list.c  |    4 ++++
 src/xcb_out.c   |    4 ++++
 src/xcb_util.c  |   15 ++++++++++++++-
 src/xcb_xid.c   |    4 ++++
 10 files changed, 57 insertions(+), 1 deletion(-)

New commits:
commit ff53285ae3f604e9f2cc5f4837255220459b5e44
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Aug 25 13:53:37 2012 -0700

    Return connection failure if display string specifies non-existent screen
    
    Matches the behaviour of Xlib - if you set DISPLAY to :0.1 but only have
    one screen, closes connection and returns error.
    
    This introduces a new connection error code:
    XCB_CONN_CLOSED_INVALID_SCREEN
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    Reviewed-by: Josh Triplett <josh at joshtriplett.org>

diff --git a/src/xcb.h b/src/xcb.h
index 179af84..f7dc6af 100644
--- a/src/xcb.h
+++ b/src/xcb.h
@@ -84,6 +84,9 @@ extern "C" {
 /** Connection closed, error during parsing display string. */
 #define XCB_CONN_CLOSED_PARSE_ERR 5
 
+/** Connection closed because the server does not have a screen matching the display. */
+#define XCB_CONN_CLOSED_INVALID_SCREEN 6
+
 #define XCB_TYPE_PAD(T,I) (-(I) & (sizeof(T) > 4 ? 3 : sizeof(T) - 1))
 
 /* Opaque structures */
@@ -423,6 +426,7 @@ int xcb_get_file_descriptor(xcb_connection_t *c);
  * @return XCB_CONN_CLOSED_MEM_INSUFFICIENT, when memory not available.
  * @return XCB_CONN_CLOSED_REQ_LEN_EXCEED, exceeding request length that server accepts.
  * @return XCB_CONN_CLOSED_PARSE_ERR, error during parsing display string.
+ * @return XCB_CONN_CLOSED_INVALID_SCREEN, because the server does not have a screen matching the display.
  */
 int xcb_connection_has_error(xcb_connection_t *c);
 
diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index 7202cc5..7979491 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -66,6 +66,7 @@ typedef struct {
 static const int xcb_con_error = XCB_CONN_ERROR;
 static const int xcb_con_closed_mem_er = XCB_CONN_CLOSED_MEM_INSUFFICIENT;
 static const int xcb_con_closed_parse_er = XCB_CONN_CLOSED_PARSE_ERR;
+static const int xcb_con_closed_screen_er = XCB_CONN_CLOSED_INVALID_SCREEN;
 
 static int set_fd_flags(const int fd)
 {
@@ -349,6 +350,10 @@ xcb_connection_t *_xcb_conn_ret_error(int err)
         {
             return (xcb_connection_t *) &xcb_con_closed_parse_er;
         }
+        case XCB_CONN_CLOSED_INVALID_SCREEN:
+        {
+            return (xcb_connection_t *) &xcb_con_closed_screen_er;
+        }
         case XCB_CONN_ERROR:
         default:
         {
diff --git a/src/xcb_util.c b/src/xcb_util.c
index e480d75..463d085 100644
--- a/src/xcb_util.c
+++ b/src/xcb_util.c
@@ -467,6 +467,16 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname,
     else
         c = xcb_connect_to_fd(fd, 0);
 
+    if(c->has_error)
+        goto out;
+
+    /* Make sure requested screen number is in bounds for this server */
+    if((screenp != NULL) && (*screenp >= (int) c->setup->roots_len)) {
+        xcb_disconnect(c);
+        c = _xcb_conn_ret_error(XCB_CONN_CLOSED_INVALID_SCREEN);
+        goto out;
+    }
+
 out:
     free(host);
     free(protocol);
commit 90889794ad882a6847bcffe52c4cc5dfd168f1f4
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Fri Aug 24 23:35:41 2012 -0700

    Add AC_USE_SYSTEM_EXTENSIONS to allow use of more system functionality
    
    Copied from libX11 configure.ac
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/configure.ac b/configure.ac
index e94e32c..d6b9531 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,11 +1,18 @@
 #                                               -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
 
+# Initialize Autoconf
 AC_PREREQ(2.57)
 AC_INIT([libxcb],
         1.8.1,
         [xcb at lists.freedesktop.org])
 AC_CONFIG_SRCDIR([xcb.pc.in])
+# Set common system defines for POSIX extensions, such as _GNU_SOURCE
+# Must be called before any macros that run the compiler (like AC_PROG_LIBTOOL)
+# to avoid autoconf errors.
+AC_USE_SYSTEM_EXTENSIONS
+
+# Initialize Automake
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
commit b52790e8ed4bb077eabdeca803935d2910558acc
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Fri Aug 24 23:32:32 2012 -0700

    Always include "config.h" at the start of all C source files.
    
    Allows configure to set defines such as _POSIX_SOURCE in config.h
    that affect functions exposed by system headers and get consistent
    results across all the source files.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/src/c_client.py b/src/c_client.py
index 31ed3b5..27a01b1 100644
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -176,6 +176,9 @@ def c_open(self):
     _h('')
     _h('#include "xcb.h"')
 
+    _c('#ifdef HAVE_CONFIG_H')
+    _c('#include "config.h"')
+    _c('#endif')
     _c('#include <stdlib.h>')
     _c('#include <string.h>')
     _c('#include <assert.h>')
diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index 725502a..7202cc5 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -25,6 +25,10 @@
 
 /* Connection management: the core of XCB. */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <assert.h>
 #include <string.h>
 #include <stdio.h>
diff --git a/src/xcb_ext.c b/src/xcb_ext.c
index 68bb29b..831f283 100644
--- a/src/xcb_ext.c
+++ b/src/xcb_ext.c
@@ -25,6 +25,10 @@
 
 /* A cache for QueryExtension results. */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/src/xcb_in.c b/src/xcb_in.c
index 4998cdd..b810783 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -25,6 +25,10 @@
 
 /* Stuff that reads stuff from the server. */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <assert.h>
 #include <string.h>
 #include <stdlib.h>
diff --git a/src/xcb_list.c b/src/xcb_list.c
index 3a18d90..6f5c611 100644
--- a/src/xcb_list.c
+++ b/src/xcb_list.c
@@ -25,6 +25,10 @@
 
 /* A generic implementation of a list of void-pointers. */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdlib.h>
 
 #include "xcb.h"
diff --git a/src/xcb_out.c b/src/xcb_out.c
index c0601f2..405f963 100644
--- a/src/xcb_out.c
+++ b/src/xcb_out.c
@@ -25,6 +25,10 @@
 
 /* Stuff that sends stuff to the server. */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <assert.h>
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/src/xcb_util.c b/src/xcb_util.c
index 45f66cb..e480d75 100644
--- a/src/xcb_util.c
+++ b/src/xcb_util.c
@@ -25,6 +25,10 @@
 
 /* Utility functions implementable using only public APIs. */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <assert.h>
 #include <sys/types.h>
 #include <limits.h>
@@ -51,7 +55,6 @@
 #include "xcbext.h"
 #include "xcbint.h"
 
-/* must be after "xcbint.h" to get autoconf #defines */
 #if defined(HAVE_TSOL_LABEL_H) && defined(HAVE_IS_SYSTEM_LABELED)
 # include <tsol/label.h>
 # include <sys/stat.h>
diff --git a/src/xcb_xid.c b/src/xcb_xid.c
index 3df5dbe..79a9a27 100644
--- a/src/xcb_xid.c
+++ b/src/xcb_xid.c
@@ -25,6 +25,10 @@
 
 /* XID allocators. */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <assert.h>
 #include <stdlib.h>
 #include "xcb.h"


More information about the xcb-commit mailing list