[PATCH libX11 2/2] Fix various build warnings

Jeremy Huddleston jeremyhu at freedesktop.org
Tue Feb 2 17:03:57 PST 2010


imLcIm.c: In function '_XimCachedFileName':
imLcIm.c:361: warning: format '%03x' expects type 'unsigned int', but argument 8 has type 'long unsigned int'
imLcIm.c:364: warning: format '%03x' expects type 'unsigned int', but argument 8 has type 'long unsigned int'

imRm.c: In function '_XimDefaultArea':
imRm.c:597: warning: cast from pointer to integer of different size
imRm.c: In function '_XimDefaultColormap':
imRm.c:626: warning: cast from pointer to integer of different size

lcFile.c:224: warning: no previous prototype for 'xlocaledir'

lcUTF8.c: In function 'iconv_cstombs':
lcUTF8.c:1841: warning: assignment discards qualifiers from pointer target type
lcUTF8.c:1869: warning: pointer targets in passing argument 1 of 'wctomb' differ in signedness
lcUTF8.c:1873: warning: pointer targets in passing argument 1 of 'wctomb' differ in signedness
lcUTF8.c: In function 'iconv_mbstocs':
lcUTF8.c:1935: warning: pointer targets in passing argument 2 of 'mbtowc' differ in signedness
lcUTF8.c: In function 'iconv_mbtocs':
lcUTF8.c:2031: warning: pointer targets in passing argument 2 of 'mbtowc' differ in signedness
lcUTF8.c: In function 'iconv_mbstostr':
lcUTF8.c:2121: warning: pointer targets in passing argument 2 of 'mbtowc' differ in signedness
lcUTF8.c: In function 'iconv_strtombs':
lcUTF8.c:2180: warning: pointer targets in passing argument 1 of 'wctomb' differ in signedness
lcUTF8.c: In function '_XlcAddGB18030LocaleConverters':
lcUTF8.c:2367: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type
lcUTF8.c:2368: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type
lcUTF8.c:2373: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type
lcUTF8.c:2374: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type
lcUTF8.c:2375: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type
lcUTF8.c:2376: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type
lcUTF8.c:2377: warning: passing argument 5 of '_XlcSetConverter' from incompatible pointer type

XlibInt.c: In function '_XGetHostname':
XlibInt.c:3441: warning: implicit declaration of function 'gethostname'
XlibInt.c:3441: warning: nested extern declaration of 'gethostname'

ConnDis.c: In function '_XDisconnectDisplay':
ConnDis.c:540: warning: old-style function definition
ConnDis.c: In function '_XSendClientPrefix':
ConnDis.c:554: warning: old-style function definition
ConnDis.c: In function 'XSetAuthorization':
ConnDis.c:677: warning: old-style function definition

Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
---
 include/X11/Xlibint.h      |    7 +++++++
 modules/im/ximcp/imLcIm.c  |    4 ++--
 modules/im/ximcp/imLcPrs.c |    5 -----
 modules/im/ximcp/imRm.c    |    4 ++--
 src/ConnDis.c              |   21 +++++++++------------
 src/XlibInt.c              |    4 ++++
 src/xlibi18n/lcUTF8.c      |   28 ++++++++++++++--------------
 7 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/include/X11/Xlibint.h b/include/X11/Xlibint.h
index 767b083..0e97fd9 100644
--- a/include/X11/Xlibint.h
+++ b/include/X11/Xlibint.h
@@ -1391,6 +1391,13 @@ extern Bool _XCopyEventCookie(
         XGenericEventCookie *in,
         XGenericEventCookie *out);
 
+/* lcFile.c */
+
+extern void xlocaledir(
+    char *buf,
+    int buf_len
+);
+
 _XFUNCPROTOEND
 
 #endif /* _XLIBINT_H_ */
diff --git a/modules/im/ximcp/imLcIm.c b/modules/im/ximcp/imLcIm.c
index eb41603..83f216a 100644
--- a/modules/im/ximcp/imLcIm.c
+++ b/modules/im/ximcp/imLcIm.c
@@ -359,10 +359,10 @@ Private int _XimCachedFileName (
 
     if (len == 0 || dir [len-1] != '/')
        sprintf (*res, "%s/%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(),
-		XIM_CACHE_VERSION, sizeof (DefTree), hash, hash2);
+		XIM_CACHE_VERSION, (unsigned int)sizeof (DefTree), hash, hash2);
     else
        sprintf (*res, "%s%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(),
-		XIM_CACHE_VERSION, sizeof (DefTree), hash, hash2);
+		XIM_CACHE_VERSION, (unsigned int)sizeof (DefTree), hash, hash2);
 
 /* fprintf (stderr, "-> %s\n", *res); */
     if ( (fd = _XOpenFile (*res, O_RDONLY)) == -1)
diff --git a/modules/im/ximcp/imLcPrs.c b/modules/im/ximcp/imLcPrs.c
index c080172..75449ef 100644
--- a/modules/im/ximcp/imLcPrs.c
+++ b/modules/im/ximcp/imLcPrs.c
@@ -44,11 +44,6 @@ OR PERFORMANCE OF THIS SOFTWARE.
 
 #define XLC_BUFSIZE 256
 
-extern void xlocaledir(
-    char *buf,
-    int buf_len
-);
-
 extern int _Xmbstowcs(
     wchar_t	*wstr,
     char	*str,
diff --git a/modules/im/ximcp/imRm.c b/modules/im/ximcp/imRm.c
index 94190e9..8e02b13 100644
--- a/modules/im/ximcp/imRm.c
+++ b/modules/im/ximcp/imRm.c
@@ -594,7 +594,7 @@ _XimDefaultArea(
     if(XGetGeometry(im->core.display, (Drawable)ic->core.focus_window,
 		&root_return, &x_return, &y_return, &width_return,
 		&height_return, &border_width_return, &depth_return)
-		== (Status)NULL) {
+		== (Status)0) {
 	return True;
     }
     area.x	= 0;
@@ -623,7 +623,7 @@ _XimDefaultColormap(
 	return True;
     }
     if(XGetWindowAttributes(im->core.display, ic->core.client_window,
-					&win_attr) == (Status)NULL) {
+					&win_attr) == (Status)0) {
 	return True;
     }
 
diff --git a/src/ConnDis.c b/src/ConnDis.c
index 7fa7998..197e14c 100644
--- a/src/ConnDis.c
+++ b/src/ConnDis.c
@@ -533,10 +533,7 @@ int _XConnectDisplay (
  * Disconnect from server.
  */
 
-int _XDisconnectDisplay (trans_conn)
-
-XtransConnInfo	trans_conn;
-
+int _XDisconnectDisplay (XtransConnInfo trans_conn)
 {
     _X11TransDisconnect(trans_conn);
     _X11TransClose(trans_conn);
@@ -546,11 +543,11 @@ XtransConnInfo	trans_conn;
 
 
 Bool
-_XSendClientPrefix (dpy, client, auth_proto, auth_string, prefix)
-     Display *dpy;
-     xConnClientPrefix *client;		/* contains count for auth_* */
-     char *auth_proto, *auth_string;	/* NOT null-terminated */
-     xConnSetupPrefix *prefix;		/* prefix information */
+_XSendClientPrefix(
+     Display *dpy,
+     xConnClientPrefix *client,			/* contains count for auth_* */
+     char *auth_proto, char *auth_string,	/* NOT null-terminated */
+     xConnSetupPrefix *prefix)			/* prefix information */
 {
     int auth_length = client->nbytesAuthProto;
     int auth_strlen = client->nbytesAuthString;
@@ -671,9 +668,9 @@ static _Xconst int  *xauth_lengths = default_xauth_lengths;
 
 static int  xauth_names_length = NUM_DEFAULT_AUTH;
 
-void XSetAuthorization (name, namelen, data, datalen)
-    int namelen, datalen;		/* lengths of name and data */
-    char *name, *data;			/* NULL or arbitrary array of bytes */
+void XSetAuthorization (
+    char *name, int namelen,		/* *len are lengths of name and data */
+    char *data, int datalen)		/* name/data are NULL or arbitrary array of bytes */
 {
     char *tmpname, *tmpdata;
 
diff --git a/src/XlibInt.c b/src/XlibInt.c
index 0f30f74..fe7802e 100644
--- a/src/XlibInt.c
+++ b/src/XlibInt.c
@@ -3411,6 +3411,10 @@ void _XData32(
 #if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(SVR4)
 #define NEED_UTSNAME
 #include <sys/utsname.h>
+#else
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #endif
 
 /*
diff --git a/src/xlibi18n/lcUTF8.c b/src/xlibi18n/lcUTF8.c
index 08906c6..3e934b7 100644
--- a/src/xlibi18n/lcUTF8.c
+++ b/src/xlibi18n/lcUTF8.c
@@ -1822,7 +1822,7 @@ iconv_cstombs(XlcConv conv, XPointer *from, int *from_left,
 	      XPointer *to, int *to_left, XPointer *args, int num_args)
 {
     XlcCharSet charset;
-    char *name;
+    char const *name;
     Utf8Conv convptr;
     int i;
     unsigned char const *src;
@@ -1866,11 +1866,11 @@ iconv_cstombs(XlcConv conv, XPointer *from, int *from_left,
 
     /* Use stdc iconv to convert widechar -> multibyte */
 
-	count = wctomb(dst, wc);
+	count = wctomb((char *)dst, wc);
 	if (count == 0)
 	    break;
 	if (count == -1) {
-	    count = wctomb(dst, BAD_WCHAR);
+	    count = wctomb((char *)dst, BAD_WCHAR);
 	    if (count == 0)
 		break;
 	    unconv_num++;
@@ -1895,7 +1895,7 @@ static XlcConvMethodsRec iconv_cstombs_methods = {
 };
 
 static XlcConv
-open_iconv_cstombs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type)
+open_iconv_cstombs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
 {
     lazy_init_all_charsets();
     return create_conv(from_lcd, &iconv_cstombs_methods);
@@ -1932,7 +1932,7 @@ iconv_mbstocs(XlcConv conv, XPointer *from, int *from_left,
 
     /* Uses stdc iconv to convert multibyte -> widechar */
 
-	consumed = mbtowc(&wc, src, srcend-src);
+	consumed = mbtowc(&wc, (const char *)src, srcend-src);
 	if (consumed == 0)
 	    break;
 	if (consumed == -1) {
@@ -1990,7 +1990,7 @@ static XlcConvMethodsRec iconv_mbstocs_methods = {
 };
 
 static XlcConv
-open_iconv_mbstocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type)
+open_iconv_mbstocs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
 {
     return create_tocs_conv(from_lcd, &iconv_mbstocs_methods);
 }
@@ -2028,7 +2028,7 @@ iconv_mbtocs(XlcConv conv, XPointer *from, int *from_left,
 
     /* Uses stdc iconv to convert multibyte -> widechar */
 
-	consumed = mbtowc(&wc, src, srcend-src);
+	consumed = mbtowc(&wc, (const char *)src, srcend-src);
 	if (consumed == 0)
 	    break;
 	if (consumed == -1) {
@@ -2085,7 +2085,7 @@ static XlcConvMethodsRec iconv_mbtocs_methods = {
 };
 
 static XlcConv
-open_iconv_mbtocs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type)
+open_iconv_mbtocs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
 {
     return create_tocs_conv(from_lcd, &iconv_mbtocs_methods );
 }
@@ -2118,7 +2118,7 @@ iconv_mbstostr(XlcConv conv, XPointer *from, int *from_left,
 
     /* Uses stdc iconv to convert multibyte -> widechar */
 
-	consumed = mbtowc(&wc, src, srcend-src);
+	consumed = mbtowc(&wc, (const char *)src, srcend-src);
 	if (consumed == 0)
 	    break;
 	if (dst == dstend)
@@ -2153,7 +2153,7 @@ static XlcConvMethodsRec iconv_mbstostr_methods = {
 };
 
 static XlcConv
-open_iconv_mbstostr(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type)
+open_iconv_mbstostr(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
 {
     return create_conv(from_lcd, &iconv_mbstostr_methods);
 }
@@ -2177,7 +2177,7 @@ iconv_strtombs(XlcConv conv, XPointer *from, int *from_left,
     dstend = dst + *to_left;
 
     while (src < srcend) {
-	int count = wctomb(dst, *src);
+	int count = wctomb((char *)dst, *src);
 	if (count < 0)
 	    break;
 	dst += count;
@@ -2199,7 +2199,7 @@ static XlcConvMethodsRec iconv_strtombs_methods= {
 };
 
 static XlcConv
-open_iconv_strtombs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type)
+open_iconv_strtombs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
 {
     return create_conv(from_lcd, &iconv_strtombs_methods);
 }
@@ -2260,7 +2260,7 @@ static XlcConvMethodsRec iconv_mbstowcs_methods = {
 } ;
 
 static XlcConv
-open_iconv_mbstowcs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type)
+open_iconv_mbstowcs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
 {
     return create_conv(from_lcd, &iconv_mbstowcs_methods);
 }
@@ -2307,7 +2307,7 @@ static XlcConvMethodsRec iconv_wcstombs_methods = {
 } ;
 
 static XlcConv
-open_iconv_wcstombs(XLCd from_lcd, char *from_type, XLCd to_lcd, char *to_type)
+open_iconv_wcstombs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
 {
     return create_conv(from_lcd, &iconv_wcstombs_methods);
 }
-- 
1.6.2




More information about the xorg-devel mailing list