[Mesa-dev] [PATCH] mesa: silence some compilation warnings.

Patrick Baggett baggett.patrick at gmail.com
Thu May 12 06:49:06 PDT 2011


I would be wary of assuming you can typecast long -> pointer, or pointer ->
long. On 64-bit Windows,  sizeof(int) == sizeof(long) == 4 but sizeof(void*)
== 8. On 64-bit Linux (gcc), sizeof(int) == 4, sizeof(long) == sizeof(void*)
== 8. It would be better to use <stdint.h> with uintptr_t -- it was designed
to solve this problem exactly. If you insist on using long, why not use long
long (C99) which is 64-bits on both platforms.



On Thu, May 12, 2011 at 3:49 AM, zhigang gong <zhigang.gong at gmail.com>wrote:

> glu.h: typedef void (GLAPIENTRYP _GLUfuncptr)(); causes the following
>       warning: function declaration isn't a prototype.
> egl:   When convert a (void *) to a int type, it's better to
>       convert to long firstly, otherwise in 64 bit envirnonment, it
>       causes compilation warning.
> ---
>  include/GL/glu.h                    |    2 +-
>  src/egl/drivers/dri2/egl_dri2.c     |    4 ++--
>  src/egl/drivers/dri2/platform_drm.c |    4 ++--
>  src/egl/drivers/dri2/platform_x11.c |    2 +-
>  src/egl/main/eglapi.c               |    2 +-
>  5 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/include/GL/glu.h b/include/GL/glu.h
> index cd967ac..ba2228d 100644
> --- a/include/GL/glu.h
> +++ b/include/GL/glu.h
> @@ -284,7 +284,7 @@ typedef GLUtesselator GLUtriangulatorObj;
>  #define GLU_TESS_MAX_COORD 1.0e150
>
>  /* Internal convenience typedefs */
> -typedef void (GLAPIENTRYP _GLUfuncptr)();
> +typedef void (GLAPIENTRYP _GLUfuncptr)(void);
>
>  GLAPI void GLAPIENTRY gluBeginCurve (GLUnurbs* nurb);
>  GLAPI void GLAPIENTRY gluBeginPolygon (GLUtesselator* tess);
> diff --git a/src/egl/drivers/dri2/egl_dri2.c
> b/src/egl/drivers/dri2/egl_dri2.c
> index afab679..f5f5ac3 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -835,7 +835,7 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay
> *disp, _EGLContext *ctx,
>    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
>    struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
>    struct dri2_egl_image *dri2_img;
> -   GLuint renderbuffer = (GLuint) buffer;
> +   GLuint renderbuffer =  (unsigned long) buffer;
>
>    if (renderbuffer == 0) {
>       _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr");
> @@ -870,7 +870,7 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay
> *disp, _EGLContext *ctx,
>
>    (void) ctx;
>
> -   name = (EGLint) buffer;
> +   name = (unsigned long) buffer;
>
>    err = _eglParseImageAttribList(&attrs, disp, attr_list);
>    if (err != EGL_SUCCESS)
> diff --git a/src/egl/drivers/dri2/platform_drm.c
> b/src/egl/drivers/dri2/platform_drm.c
> index 68912e3..cea8418 100644
> --- a/src/egl/drivers/dri2/platform_drm.c
> +++ b/src/egl/drivers/dri2/platform_drm.c
> @@ -596,7 +596,7 @@ dri2_get_device_name(int fd)
>       goto out;
>    }
>
> -   device_name = udev_device_get_devnode(device);
> +   device_name = (char*)udev_device_get_devnode(device);
>    if (!device_name)
>           goto out;
>    device_name = strdup(device_name);
> @@ -690,7 +690,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
>    memset(dri2_dpy, 0, sizeof *dri2_dpy);
>
>    disp->DriverData = (void *) dri2_dpy;
> -   dri2_dpy->fd = (int) disp->PlatformDisplay;
> +   dri2_dpy->fd = (long) disp->PlatformDisplay;
>
>    dri2_dpy->driver_name = dri2_get_driver_for_fd(dri2_dpy->fd);
>    if (dri2_dpy->driver_name == NULL)
> diff --git a/src/egl/drivers/dri2/platform_x11.c
> b/src/egl/drivers/dri2/platform_x11.c
> index 5d4ac6a..90136f4 100644
> --- a/src/egl/drivers/dri2/platform_x11.c
> +++ b/src/egl/drivers/dri2/platform_x11.c
> @@ -784,7 +784,7 @@ dri2_create_image_khr_pixmap(_EGLDisplay *disp,
> _EGLContext *ctx,
>
>    (void) ctx;
>
> -   drawable = (xcb_drawable_t) buffer;
> +   drawable = (xcb_drawable_t) (long)buffer;
>    xcb_dri2_create_drawable (dri2_dpy->conn, drawable);
>    attachments[0] = XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT;
>    buffers_cookie =
> diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
> index 336ec23..9063752 100644
> --- a/src/egl/main/eglapi.c
> +++ b/src/egl/main/eglapi.c
> @@ -1168,7 +1168,7 @@ eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA
> mode)
>  EGLDisplay EGLAPIENTRY
>  eglGetDRMDisplayMESA(int fd)
>  {
> -   _EGLDisplay *dpy = _eglFindDisplay(_EGL_PLATFORM_DRM, (void *) fd);
> +   _EGLDisplay *dpy = _eglFindDisplay(_EGL_PLATFORM_DRM, (void *)
> (long)fd);
>    return _eglGetDisplayHandle(dpy);
>  }
>
> --
> 1.7.3.1
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110512/4c17b316/attachment.htm>


More information about the mesa-dev mailing list