[Xcb] [PATCH] Delete a useless level of indirection from _xcb_out_send's parameters.

Jamey Sharp jamey at minilop.net
Sun Mar 28 10:58:16 PDT 2010


_xcb_out_send needs _xcb_conn_wait to store back its progress so it can
be reinvoked to pick up where it left off---but then _xcb_out_send
guarantees that it leaves either an empty output vector or a shut-down
connection, so *its* callers never care how much progress was made.

Signed-off-by: Jamey Sharp <jamey at minilop.net>
---

Ideally, every patch would be reviewed by somebody. Someone mind
reviewing this one for me?

 src/xcb_conn.c |    5 +----
 src/xcb_out.c  |   15 +++++++--------
 src/xcbint.h   |    2 +-
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index ed2153d..95e7bb8 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -102,10 +102,7 @@ static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
     assert(count <= (int) (sizeof(parts) / sizeof(*parts)));
 
     pthread_mutex_lock(&c->iolock);
-    {
-        struct iovec *parts_ptr = parts;
-        ret = _xcb_out_send(c, &parts_ptr, &count);
-    }
+    ret = _xcb_out_send(c, parts, count);
     pthread_mutex_unlock(&c->iolock);
     return ret;
 }
diff --git a/src/xcb_out.c b/src/xcb_out.c
index b3050fe..afc12c1 100644
--- a/src/xcb_out.c
+++ b/src/xcb_out.c
@@ -52,7 +52,7 @@ static int write_block(xcb_connection_t *c, struct iovec *vector, int count)
     vector[0].iov_base = c->out.queue;
     vector[0].iov_len = c->out.queue_len;
     c->out.queue_len = 0;
-    return _xcb_out_send(c, &vector, &count);
+    return _xcb_out_send(c, vector, count);
 }
 
 static void get_socket_back(xcb_connection_t *c)
@@ -283,7 +283,7 @@ int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t re
         return 0;
     pthread_mutex_lock(&c->iolock);
     c->out.request += requests;
-    ret = _xcb_out_send(c, &vector, &count);
+    ret = _xcb_out_send(c, vector, count);
     pthread_mutex_unlock(&c->iolock);
     return ret;
 }
@@ -331,11 +331,11 @@ void _xcb_out_destroy(_xcb_out *out)
     pthread_mutex_destroy(&out->reqlenlock);
 }
 
-int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count)
+int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count)
 {
     int ret = 1;
-    while(ret && *count)
-        ret = _xcb_conn_wait(c, &c->out.cond, vector, count);
+    while(ret && count)
+        ret = _xcb_conn_wait(c, &c->out.cond, &vector, &count);
     c->out.request_written = c->out.request;
     pthread_cond_broadcast(&c->out.cond);
     return ret;
@@ -348,12 +348,11 @@ int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request)
         return 1;
     if(c->out.queue_len)
     {
-        struct iovec vec, *vec_ptr = &vec;
-        int count = 1;
+        struct iovec vec;
         vec.iov_base = c->out.queue;
         vec.iov_len = c->out.queue_len;
         c->out.queue_len = 0;
-        return _xcb_out_send(c, &vec_ptr, &count);
+        return _xcb_out_send(c, &vec, 1);
     }
     while(c->out.writing)
         pthread_cond_wait(&c->out.cond, &c->iolock);
diff --git a/src/xcbint.h b/src/xcbint.h
index 154cca0..9d44238 100644
--- a/src/xcbint.h
+++ b/src/xcbint.h
@@ -106,7 +106,7 @@ typedef struct _xcb_out {
 int _xcb_out_init(_xcb_out *out);
 void _xcb_out_destroy(_xcb_out *out);
 
-int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count);
+int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count);
 int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request);
 
 
-- 
1.7.0



More information about the Xcb mailing list