Should fix type-punning compiler warnings.
authorRyan C. Gordon
Fri, 20 Jul 2012 13:52:25 -0400
changeset 6376f7ec45572c54
parent 6375 93f9a24d1c02
child 6377 3d868ca4782f
Should fix type-punning compiler warnings.
src/video/x11/SDL_x11dyn.c
     1.1 --- a/src/video/x11/SDL_x11dyn.c	Fri Jul 20 13:33:15 2012 -0400
     1.2 +++ b/src/video/x11/SDL_x11dyn.c	Fri Jul 20 13:52:25 2012 -0400
     1.3 @@ -77,35 +77,38 @@
     1.4      {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE}
     1.5  };
     1.6  
     1.7 -static void
     1.8 -X11_GetSym(const char *fnname, int *rc, void **fn)
     1.9 +static void *
    1.10 +X11_GetSym(const char *fnname, int *pHasModule)
    1.11  {
    1.12      int i;
    1.13 +    void *fn = NULL;
    1.14      for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
    1.15          if (x11libs[i].lib != NULL) {
    1.16 -            *fn = SDL_LoadFunction(x11libs[i].lib, fnname);
    1.17 -            if (*fn != NULL)
    1.18 +            fn = SDL_LoadFunction(x11libs[i].lib, fnname);
    1.19 +            if (fn != NULL)
    1.20                  break;
    1.21          }
    1.22      }
    1.23  
    1.24  #if DEBUG_DYNAMIC_X11
    1.25 -    if (*fn != NULL)
    1.26 -        printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname,
    1.27 -               *fn);
    1.28 +    if (fn != NULL)
    1.29 +        printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname, fn);
    1.30      else
    1.31          printf("X11: Symbol '%s' NOT FOUND!\n", fnname);
    1.32  #endif
    1.33  
    1.34 -    if (*fn == NULL)
    1.35 -        *rc = 0;                /* kill this module. */
    1.36 +    if (fn == NULL)
    1.37 +        *pHasModule = 0;  /* kill this module. */
    1.38 +
    1.39 +    return fn;
    1.40  }
    1.41  
    1.42  
    1.43  /* Define all the function pointers and wrappers... */
    1.44  #define SDL_X11_MODULE(modname)
    1.45  #define SDL_X11_SYM(rc,fn,params,args,ret) \
    1.46 -	static rc (*p##fn) params = NULL; \
    1.47 +	typedef rc (*SDL_DYNX11FN_##fn) params; \
    1.48 +	static SDL_DYNX11FN_##fn p##fn = NULL; \
    1.49  	rc fn params { ret p##fn args ; }
    1.50  #include "SDL_x11sym.h"
    1.51  #undef SDL_X11_MODULE
    1.52 @@ -114,8 +117,10 @@
    1.53  
    1.54  /* Annoying varargs entry point... */
    1.55  #ifdef X_HAVE_UTF8_STRING
    1.56 -XIC(*pXCreateIC) (XIM,...) = NULL;
    1.57 -char *(*pXGetICValues) (XIC, ...) = NULL;
    1.58 +typedef XIC(*SDL_DYNX11FN_XCreateIC) (XIM,...);
    1.59 +SDL_DYNX11FN_XCreateIC pXCreateIC = NULL;
    1.60 +typedef char *(*SDL_DYNX11FN_XGetICValues) (XIC, ...);
    1.61 +SDL_DYNX11FN_XGetICValues pXGetICValues = NULL;
    1.62  #endif
    1.63  
    1.64  /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
    1.65 @@ -184,15 +189,16 @@
    1.66  #undef SDL_X11_SYM
    1.67  
    1.68  #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
    1.69 -#define SDL_X11_SYM(a,fn,x,y,z) X11_GetSym(#fn,thismod,(void**)&p##fn);
    1.70 +#define SDL_X11_SYM(a,fn,x,y,z) p##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod);
    1.71  #include "SDL_x11sym.h"
    1.72  #undef SDL_X11_MODULE
    1.73  #undef SDL_X11_SYM
    1.74  
    1.75  #ifdef X_HAVE_UTF8_STRING
    1.76 -        X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8, (void **) &pXCreateIC);
    1.77 -        X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8,
    1.78 -                   (void **) &pXGetICValues);
    1.79 +        pXCreateIC = (SDL_DYNX11FN_XCreateIC)
    1.80 +                        X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8);
    1.81 +        pXGetICValues = (SDL_DYNX11FN_XGetICValues)
    1.82 +                        X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8);
    1.83  #endif
    1.84  
    1.85          if (SDL_X11_HAVE_BASEXLIB) {