Fixed a whole slew of compiler warnings that -Wall exposed.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 13 Oct 2011 01:08:30 -0400
changeset 5981 75caa8a7d559
parent 5980 612b41c44af1
child 5982 f324bd81b52c
Fixed a whole slew of compiler warnings that -Wall exposed.
src/cpuinfo/SDL_cpuinfo.c
src/events/SDL_gesture.c
src/events/SDL_mouse.c
src/power/linux/SDL_syspower.c
src/render/opengl/SDL_render_gl.c
src/render/software/SDL_blendline.c
src/render/software/SDL_draw.h
src/thread/pthread/SDL_syssem.c
src/thread/pthread/SDL_systhread.c
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11framebuffer.c
src/video/x11/SDL_x11mouse.c
src/video/x11/SDL_x11opengl.c
src/video/x11/SDL_x11shape.c
src/video/x11/SDL_x11sym.h
src/video/x11/SDL_x11touch.c
src/video/x11/SDL_x11window.c
--- a/src/cpuinfo/SDL_cpuinfo.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/cpuinfo/SDL_cpuinfo.c	Thu Oct 13 01:08:30 2011 -0400
@@ -384,6 +384,8 @@
     return SDL_CPUType;
 }
 
+
+#ifdef TEST_MAIN  /* !!! FIXME: only used for test at the moment. */
 static const char *
 SDL_GetCPUName(void)
 {
@@ -455,6 +457,7 @@
     }
     return SDL_CPUName;
 }
+#endif
 
 int
 SDL_GetCPUCacheLineSize(void)
--- a/src/events/SDL_gesture.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/events/SDL_gesture.c	Thu Oct 13 01:08:30 2011 -0400
@@ -390,10 +390,11 @@
 float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_GestureTouch* touch) {
         
         SDL_FloatPoint points[DOLLARNPOINTS];
-        int numPoints = dollarNormalize(path,points);
         int i;
         float bestDiff = 10000;
 
+        dollarNormalize(path,points);
+
         //PrintPath(points);
         *bestTempl = -1;
         for(i = 0;i < touch->numDollarTemplates;i++) {
--- a/src/events/SDL_mouse.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/events/SDL_mouse.c	Thu Oct 13 01:08:30 2011 -0400
@@ -349,7 +349,6 @@
 SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
                  int w, int h, int hot_x, int hot_y)
 {
-    SDL_Mouse *mouse = SDL_GetMouse();
     SDL_Surface *surface;
     SDL_Cursor *cursor;
     int x, y;
--- a/src/power/linux/SDL_syspower.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/power/linux/SDL_syspower.c	Thu Oct 13 01:08:30 2011 -0400
@@ -128,7 +128,6 @@
     char *val = NULL;
     SDL_bool charge = SDL_FALSE;
     SDL_bool choose = SDL_FALSE;
-    SDL_bool is_ac = SDL_FALSE;
     int maximum = -1;
     int remaining = -1;
     int secs = -1;
@@ -214,13 +213,6 @@
     char *ptr = NULL;
     char *key = NULL;
     char *val = NULL;
-    SDL_bool charge = SDL_FALSE;
-    SDL_bool choose = SDL_FALSE;
-    SDL_bool is_ac = SDL_FALSE;
-    int maximum = -1;
-    int remaining = -1;
-    int secs = -1;
-    int pct = -1;
 
     if (!load_acpi_file(base, node, "state", state, sizeof (state))) {
         return;
--- a/src/render/opengl/SDL_render_gl.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/render/opengl/SDL_render_gl.c	Thu Oct 13 01:08:30 2011 -0400
@@ -348,8 +348,6 @@
 static void
 GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
 {
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-
     if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
         /* Rebind the context to the window area and update matrices */
         SDL_CurrentContext = NULL;
--- a/src/render/software/SDL_blendline.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/render/software/SDL_blendline.c	Thu Oct 13 01:08:30 2011 -0400
@@ -124,7 +124,6 @@
                      SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
                      SDL_bool draw_end)
 {
-    const SDL_PixelFormat *fmt = dst->format;
     unsigned r, g, b, a, inva;
 
     if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
@@ -216,7 +215,6 @@
                      SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
                      SDL_bool draw_end)
 {
-    const SDL_PixelFormat *fmt = dst->format;
     unsigned r, g, b, a, inva;
 
     if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
@@ -492,7 +490,6 @@
                      SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
                      SDL_bool draw_end)
 {
-    const SDL_PixelFormat *fmt = dst->format;
     unsigned r, g, b, a, inva;
 
     if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
@@ -584,7 +581,6 @@
                        SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
                        SDL_bool draw_end)
 {
-    const SDL_PixelFormat *fmt = dst->format;
     unsigned r, g, b, a, inva;
 
     if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
--- a/src/render/software/SDL_draw.h	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/render/software/SDL_draw.h	Thu Oct 13 01:08:30 2011 -0400
@@ -45,13 +45,13 @@
 
 #define DRAW_SETPIXEL(setpixel) \
 do { \
-    unsigned sr = r, sg = g, sb = b, sa = a; \
+    unsigned sr = r, sg = g, sb = b, sa = a; (void) sa; \
     setpixel; \
 } while (0)
 
 #define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \
 do { \
-    unsigned sr, sg, sb, sa; sa; \
+    unsigned sr, sg, sb, sa; (void) sa; \
     getpixel; \
     sr = DRAW_MUL(inva, sr) + r; \
     sg = DRAW_MUL(inva, sg) + g; \
@@ -61,7 +61,7 @@
 
 #define DRAW_SETPIXEL_ADD(getpixel, setpixel) \
 do { \
-    unsigned sr, sg, sb, sa; sa; \
+    unsigned sr, sg, sb, sa; (void) sa; \
     getpixel; \
     sr += r; if (sr > 0xff) sr = 0xff; \
     sg += g; if (sg > 0xff) sg = 0xff; \
@@ -71,7 +71,7 @@
 
 #define DRAW_SETPIXEL_MOD(getpixel, setpixel) \
 do { \
-    unsigned sr, sg, sb, sa; sa; \
+    unsigned sr, sg, sb, sa; (void) sa; \
     getpixel; \
     sr = DRAW_MUL(sr, r); \
     sg = DRAW_MUL(sg, g); \
--- a/src/thread/pthread/SDL_syssem.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/thread/pthread/SDL_syssem.c	Thu Oct 13 01:08:30 2011 -0400
@@ -23,6 +23,7 @@
 #include <errno.h>
 #include <pthread.h>
 #include <semaphore.h>
+#include <sys/time.h>
 
 #include "SDL_thread.h"
 #include "SDL_timer.h"
--- a/src/thread/pthread/SDL_systhread.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/thread/pthread/SDL_systhread.c	Thu Oct 13 01:08:30 2011 -0400
@@ -18,6 +18,7 @@
      misrepresented as being the original software.
   3. This notice may not be removed or altered from any source distribution.
 */
+
 #include "SDL_config.h"
 
 #include <pthread.h>
@@ -31,6 +32,8 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/syscall.h>
+#include <unistd.h>
+extern int pthread_setname_np (pthread_t __target_thread, __const char *__name) __THROW __nonnull ((2));
 #endif
 
 #include "SDL_platform.h"
--- a/src/video/x11/SDL_x11events.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/video/x11/SDL_x11events.c	Thu Oct 13 01:08:30 2011 -0400
@@ -234,7 +234,6 @@
     case KeyPress:{
             KeyCode keycode = xevent.xkey.keycode;
             KeySym keysym = NoSymbol;
-            SDL_Scancode scancode;
             char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
             Status status = 0;
 
@@ -243,7 +242,7 @@
 #endif
             SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
 #if 1
-            if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
+            if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN) {
                 int min_keycode, max_keycode;
                 XDisplayKeycodes(display, &min_keycode, &max_keycode);
                 keysym = XKeycodeToKeysym(display, keycode, 0);
@@ -522,6 +521,11 @@
     return (0);
 }
 
+
+/* !!! FIXME: this should be exposed in a header, or something. */
+int SDL_GetNumTouch(void);
+
+
 void
 X11_PumpEvents(_THIS)
 {
@@ -545,7 +549,6 @@
 #ifdef SDL_INPUT_LINUXEV
     /* Process Touch events - TODO When X gets touch support, use that instead*/
     int i = 0,rd;
-    char name[256];
     struct input_event ev[64];
     int size = sizeof (struct input_event);
 
--- a/src/video/x11/SDL_x11framebuffer.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/video/x11/SDL_x11framebuffer.c	Thu Oct 13 01:08:30 2011 -0400
@@ -183,7 +183,10 @@
                   rect->x, rect->y, rect->w, rect->h);
         }
     }
+
     XSync(display, False);
+
+    return 0;
 }
 
 void
--- a/src/video/x11/SDL_x11mouse.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/video/x11/SDL_x11mouse.c	Thu Oct 13 01:08:30 2011 -0400
@@ -136,7 +136,7 @@
     /* Code below assumes ARGB pixel format */
     SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
 
-    rfg = gfg = bfg = rbg = gbg = bbg = fgBits = 0;
+    rfg = gfg = bfg = rbg = gbg = bbg = fgBits = bgBits = 0;
     for (y = 0; y < surface->h; ++y) {
         ptr = (Uint32 *)((Uint8 *)surface->pixels + y * surface->pitch);
         for (x = 0; x < surface->w; ++x) {
--- a/src/video/x11/SDL_x11opengl.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/video/x11/SDL_x11opengl.c	Thu Oct 13 01:08:30 2011 -0400
@@ -19,8 +19,8 @@
   3. This notice may not be removed or altered from any source distribution.
 */
 #include "SDL_config.h"
-
 #include "SDL_x11video.h"
+#include "SDL_assert.h"
 
 /* GLX implementation of SDL OpenGL support */
 
@@ -388,8 +388,10 @@
     XVisualInfo *vinfo;
 
     /* 64 seems nice. */
-    int attribs[64];
-    int i = X11_GL_GetAttributes(_this,display,screen,attribs,64);
+    const int max_attrs = 64;
+    int attribs[max_attrs];
+    const int i = X11_GL_GetAttributes(_this,display,screen,attribs,max_attrs);
+    SDL_assert(i <= max_attrs);
 
     vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs);
     if (!vinfo) {
--- a/src/video/x11/SDL_x11shape.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/video/x11/SDL_x11shape.c	Thu Oct 13 01:08:30 2011 -0400
@@ -26,6 +26,7 @@
 #include "SDL_x11video.h"
 #include "SDL_x11shape.h"
 #include "SDL_x11window.h"
+#include "../SDL_shape_internals.h"
 
 SDL_Window*
 X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
--- a/src/video/x11/SDL_x11sym.h	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/video/x11/SDL_x11sym.h	Thu Oct 13 01:08:30 2011 -0400
@@ -178,17 +178,17 @@
 /* XCursor support */
 #if SDL_VIDEO_DRIVER_X11_XCURSOR
 SDL_X11_MODULE(XCURSOR)
-SDL_X11_SYM(XcursorImage*,XcursorImageCreate,(int a,int b),(a,b),)
+SDL_X11_SYM(XcursorImage*,XcursorImageCreate,(int a,int b),(a,b),return)
 SDL_X11_SYM(void,XcursorImageDestroy,(XcursorImage *a),(a),)
-SDL_X11_SYM(Cursor,XcursorImageLoadCursor,(Display *a,const XcursorImage *b),(a,b),)
+SDL_X11_SYM(Cursor,XcursorImageLoadCursor,(Display *a,const XcursorImage *b),(a,b),return)
 #endif
 
 /* Xinerama support */
 #if SDL_VIDEO_DRIVER_X11_XINERAMA
 SDL_X11_MODULE(XINERAMA)
-SDL_X11_SYM(Bool,XineramaIsActive,(Display *a),(a),)
-SDL_X11_SYM(Bool,XineramaQueryExtension,(Display *a,int *b,int *c),(a,b,c),)
-SDL_X11_SYM(XineramaScreenInfo*,XineramaQueryScreens,(Display *a, int *b),(a,b),)
+SDL_X11_SYM(Bool,XineramaIsActive,(Display *a),(a),return)
+SDL_X11_SYM(Bool,XineramaQueryExtension,(Display *a,int *b,int *c),(a,b,c),return)
+SDL_X11_SYM(XineramaScreenInfo*,XineramaQueryScreens,(Display *a, int *b),(a,b),return)
 #endif
 
 /* XInput support for multiple mice, tablets, etc. */
@@ -229,12 +229,12 @@
 
 #if SDL_VIDEO_DRIVER_X11_XVIDMODE
 SDL_X11_MODULE(XVIDMODE)
-SDL_X11_SYM(Bool,XF86VidModeGetAllModeLines,(Display *a,int b,int *c,XF86VidModeModeInfo ***d),(a,b,c,d),)
-SDL_X11_SYM(Bool,XF86VidModeGetModeLine,(Display *a,int b,int *c,XF86VidModeModeLine *d),(a,b,c,d),)
-SDL_X11_SYM(Bool,XF86VidModeGetViewPort,(Display *a,int b,int *c,int *d),(a,b,c,d),)
-SDL_X11_SYM(Bool,XF86VidModeQueryExtension,(Display *a,int *b,int *c),(a,b,c),)
-SDL_X11_SYM(Bool,XF86VidModeQueryVersion,(Display *a,int *b,int *c),(a,b,c),)
-SDL_X11_SYM(Bool,XF86VidModeSwitchToMode,(Display *a,int b,XF86VidModeModeInfo *c),(a,b,c),)
+SDL_X11_SYM(Bool,XF86VidModeGetAllModeLines,(Display *a,int b,int *c,XF86VidModeModeInfo ***d),(a,b,c,d),return)
+SDL_X11_SYM(Bool,XF86VidModeGetModeLine,(Display *a,int b,int *c,XF86VidModeModeLine *d),(a,b,c,d),return)
+SDL_X11_SYM(Bool,XF86VidModeGetViewPort,(Display *a,int b,int *c,int *d),(a,b,c,d),return)
+SDL_X11_SYM(Bool,XF86VidModeQueryExtension,(Display *a,int *b,int *c),(a,b,c),return)
+SDL_X11_SYM(Bool,XF86VidModeQueryVersion,(Display *a,int *b,int *c),(a,b,c),return)
+SDL_X11_SYM(Bool,XF86VidModeSwitchToMode,(Display *a,int b,XF86VidModeModeInfo *c),(a,b,c),return)
 #endif
 
 /* *INDENT-ON* */
--- a/src/video/x11/SDL_x11touch.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/video/x11/SDL_x11touch.c	Thu Oct 13 01:08:30 2011 -0400
@@ -39,7 +39,6 @@
   FILE *fd;
   fd = fopen("/proc/bus/input/devices","r");
 
-  char c;
   int i = 0;
   int tsfd;
   char line[256];
@@ -111,7 +110,7 @@
     }
   }
 
-  close(fd);
+  fclose(fd);
 #endif
 }
 
--- a/src/video/x11/SDL_x11window.c	Wed Oct 12 20:01:09 2011 -0400
+++ b/src/video/x11/SDL_x11window.c	Thu Oct 13 01:08:30 2011 -0400
@@ -86,31 +86,6 @@
     return count;
 }
 
-static void
-X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h)
-{
-    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *displaydata =
-        (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
-    XWindowAttributes attr;
-
-    XGetWindowAttributes(data->display, RootWindow(data->display, displaydata->screen), &attr);
-    if (window->flags & SDL_WINDOW_FULLSCREEN) {
-        /* The bounds when this window is visible is the fullscreen mode */
-        SDL_DisplayMode fullscreen_mode;
-        if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
-            attr.width = fullscreen_mode.w;
-            attr.height = fullscreen_mode.h;
-        }
-    }
-    if (w) {
-        *w = attr.width;
-    }
-    if (h) {
-        *h = attr.height;
-    }
-}
-
 static int
 SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
 {
@@ -320,7 +295,6 @@
     xattr.border_pixel = 0;
 
     if (visual->class == DirectColor) {
-        Status status;
         XColor *colorcells;
         int i;
         int ncolors;
@@ -757,7 +731,6 @@
 {
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     Display *display = data->videodata->display;
-    int x, y;
 
     XMoveWindow(display, data->xwindow, window->x, window->y);
     XFlush(display);
@@ -952,7 +925,7 @@
     int ncolors;
     int rmask, gmask, bmask;
     int rshift, gshift, bshift;
-    int i, j;
+    int i;
 
     if (visual->class != DirectColor) {
         SDL_SetError("Window doesn't have DirectColor visual");