[PATCH:libxtrans 5/7] Add const qualifiers to TRANS(Connect) args

Alan Coopersmith alan.coopersmith at oracle.com
Mon Aug 25 18:21:22 PDT 2014


Also required constifying UnixHostReallyLocal, since SocketUNIXConnect
passes the host arg through to it.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 Xtrans.c       |    2 +-
 Xtrans.h       |    2 +-
 Xtransint.h    |    4 ++--
 Xtranslcl.c    |    3 ++-
 Xtranssock.c   |    8 +++++---
 doc/xtrans.xml |   10 +++++-----
 6 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/Xtrans.c b/Xtrans.c
index 86ccdd0..81c8d2d 100644
--- a/Xtrans.c
+++ b/Xtrans.c
@@ -852,7 +852,7 @@ TRANS(Accept) (XtransConnInfo ciptr, int *status)
 #ifdef TRANS_CLIENT
 
 int
-TRANS(Connect) (XtransConnInfo ciptr, char *address)
+TRANS(Connect) (XtransConnInfo ciptr, const char *address)
 
 {
     char	*protocol;
diff --git a/Xtrans.h b/Xtrans.h
index 7706621..a1fb923 100644
--- a/Xtrans.h
+++ b/Xtrans.h
@@ -330,7 +330,7 @@ XtransConnInfo TRANS(Accept)(
 
 int TRANS(Connect)(
     XtransConnInfo,	/* ciptr */
-    char *		/* address */
+    const char *	/* address */
 );
 
 #endif /* TRANS_CLIENT */
diff --git a/Xtransint.h b/Xtransint.h
index 285cf5b..f674e5b 100644
--- a/Xtransint.h
+++ b/Xtransint.h
@@ -252,8 +252,8 @@ typedef struct _Xtransport {
 
     int	(*Connect)(
 	XtransConnInfo,		/* connection */
-	char *,			/* host */
-	char *			/* port */
+	const char *,		/* host */
+	const char *		/* port */
     );
 
 #endif /* TRANS_CLIENT */
diff --git a/Xtranslcl.c b/Xtranslcl.c
index dec8124..4f04927 100644
--- a/Xtranslcl.c
+++ b/Xtranslcl.c
@@ -2217,7 +2217,8 @@ TRANS(LocalAccept)(XtransConnInfo ciptr, int *status)
 #ifdef TRANS_CLIENT
 
 static int
-TRANS(LocalConnect)(XtransConnInfo ciptr, char *host _X_UNUSED, char *port)
+TRANS(LocalConnect)(XtransConnInfo ciptr,
+                    const char *host _X_UNUSED, const char *port)
 
 {
     prmsg(2,"LocalConnect(%p->%d,%s)\n", ciptr, ciptr->fd, port);
diff --git a/Xtranssock.c b/Xtranssock.c
index 87efd1b..65ffa6f 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -1432,7 +1432,8 @@ static struct addrlist  *addrlist = NULL;
 
 
 static int
-TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port)
+TRANS(SocketINETConnect) (XtransConnInfo ciptr,
+                          const char *host, const char *port)
 
 {
     struct sockaddr *	socketaddr = NULL;
@@ -1814,7 +1815,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port)
  */
 
 static int
-UnixHostReallyLocal (char *host)
+UnixHostReallyLocal (const char *host)
 
 {
     char hostnamebuf[256];
@@ -1945,7 +1946,8 @@ UnixHostReallyLocal (char *host)
 }
 
 static int
-TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
+TRANS(SocketUNIXConnect) (XtransConnInfo ciptr,
+                          const char *host, const char *port)
 
 {
     struct sockaddr_un	sockname;
diff --git a/doc/xtrans.xml b/doc/xtrans.xml
index 2e16e79..5c99629 100644
--- a/doc/xtrans.xml
+++ b/doc/xtrans.xml
@@ -240,8 +240,8 @@ typedef struct _Xtransport {
 
     int     (*Connect)(
      XtransConnInfo,          /* connection */
-     char *,               /* host */
-     char *               /* port */
+     const char *,            /* host */
+     const char *             /* port */
     );
 
     int     (*BytesReadable)(
@@ -542,7 +542,7 @@ new opaque transport connection object upon success,
       <funcprototype>
         <funcdef>int <function>TRANS(Connect)</function></funcdef>
         <paramdef>XtransConnInfo <parameter>connection</parameter></paramdef>
-        <paramdef>char *<parameter>address</parameter></paramdef>
+        <paramdef>const char *<parameter>address</parameter></paramdef>
       </funcprototype>
     </funcsynopsis>
     <para>
@@ -987,8 +987,8 @@ structure describing the new endpoint is returned from this function
       <funcprototype>
         <funcdef>int <function>Connect</function></funcdef>
         <paramdef>struct _Xtransport *<parameter>thistrans</parameter></paramdef>
-        <paramdef>char *<parameter>host</parameter></paramdef>
-        <paramdef>char *<parameter>port</parameter></paramdef>
+        <paramdef>const char *<parameter>host</parameter></paramdef>
+        <paramdef>const char *<parameter>port</parameter></paramdef>
       </funcprototype>
     </funcsynopsis>
     <para>
-- 
1.7.9.2



More information about the xorg-devel mailing list