[PATCH libX11 2/2] Fix various build warnings

Dan Nicholson dbn.lists at gmail.com
Tue Feb 2 19:41:26 PST 2010


On Tue, Feb 2, 2010 at 5:03 PM, Jeremy Huddleston
<jeremyhu at freedesktop.org> wrote:
>
> 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);

How about just changing the specifier to %zu?

>
>  /* 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;
>     }

Since a Status of 0 is Success, how about using that? It would make
the code clearer.

--
Dan


More information about the xorg-devel mailing list