From 4e72541e3a5c403def461ad0b6140d0c8d4f534c Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 13 Oct 2011 01:08:30 -0400 Subject: [PATCH] Fixed a whole slew of compiler warnings that -Wall exposed. --- src/cpuinfo/SDL_cpuinfo.c | 3 +++ src/events/SDL_gesture.c | 3 ++- src/events/SDL_mouse.c | 1 - src/power/linux/SDL_syspower.c | 8 -------- src/render/opengl/SDL_render_gl.c | 2 -- src/render/software/SDL_blendline.c | 4 ---- src/render/software/SDL_draw.h | 8 ++++---- src/thread/pthread/SDL_syssem.c | 1 + src/thread/pthread/SDL_systhread.c | 3 +++ src/video/x11/SDL_x11events.c | 9 ++++++--- src/video/x11/SDL_x11framebuffer.c | 3 +++ src/video/x11/SDL_x11mouse.c | 2 +- src/video/x11/SDL_x11opengl.c | 8 +++++--- src/video/x11/SDL_x11shape.c | 1 + src/video/x11/SDL_x11sym.h | 22 +++++++++++----------- src/video/x11/SDL_x11touch.c | 3 +-- src/video/x11/SDL_x11window.c | 29 +---------------------------- 17 files changed, 42 insertions(+), 68 deletions(-) diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index b3f56f979..379511c3a 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -384,6 +384,8 @@ SDL_GetCPUType(void) return SDL_CPUType; } + +#ifdef TEST_MAIN /* !!! FIXME: only used for test at the moment. */ static const char * SDL_GetCPUName(void) { @@ -455,6 +457,7 @@ SDL_GetCPUName(void) } return SDL_CPUName; } +#endif int SDL_GetCPUCacheLineSize(void) diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index 92db36618..2d6185355 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -390,10 +390,11 @@ int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) { 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++) { diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index d4104c571..a514e38d9 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -349,7 +349,6 @@ SDL_Cursor * 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; diff --git a/src/power/linux/SDL_syspower.c b/src/power/linux/SDL_syspower.c index f84e9d3e9..9852b789e 100644 --- a/src/power/linux/SDL_syspower.c +++ b/src/power/linux/SDL_syspower.c @@ -128,7 +128,6 @@ check_proc_acpi_battery(const char * node, SDL_bool * have_battery, 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 @@ check_proc_acpi_ac_adapter(const char * node, SDL_bool * have_ac) 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; diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index d478fb537..320044645 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -348,8 +348,6 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) 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; diff --git a/src/render/software/SDL_blendline.c b/src/render/software/SDL_blendline.c index 19d6431fa..796bd91eb 100644 --- a/src/render/software/SDL_blendline.c +++ b/src/render/software/SDL_blendline.c @@ -124,7 +124,6 @@ SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2, 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_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2, 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_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2, 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_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2, 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) { diff --git a/src/render/software/SDL_draw.h b/src/render/software/SDL_draw.h index bbf69936e..12cd6849c 100644 --- a/src/render/software/SDL_draw.h +++ b/src/render/software/SDL_draw.h @@ -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 @@ do { \ #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 @@ do { \ #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); \ diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index 5980c3b76..9940c5f27 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "SDL_thread.h" #include "SDL_timer.h" diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index 334d33abc..bb4296add 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -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 @@ -31,6 +32,8 @@ #include #include #include +#include +extern int pthread_setname_np (pthread_t __target_thread, __const char *__name) __THROW __nonnull ((2)); #endif #include "SDL_platform.h" diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 1079199e3..84daaa8bf 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -234,7 +234,6 @@ X11_DispatchEvent(_THIS) 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 @@ X11_DispatchEvent(_THIS) #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 @@ X11_Pending(Display * display) return (0); } + +/* !!! FIXME: this should be exposed in a header, or something. */ +int SDL_GetNumTouch(void); + + void X11_PumpEvents(_THIS) { @@ -545,7 +549,6 @@ X11_PumpEvents(_THIS) #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); diff --git a/src/video/x11/SDL_x11framebuffer.c b/src/video/x11/SDL_x11framebuffer.c index cab8b8f64..b54a48cfc 100644 --- a/src/video/x11/SDL_x11framebuffer.c +++ b/src/video/x11/SDL_x11framebuffer.c @@ -183,7 +183,10 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects, rect->x, rect->y, rect->w, rect->h); } } + XSync(display, False); + + return 0; } void diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 2eb162163..396bb9ff4 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -136,7 +136,7 @@ X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y) /* 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) { diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 49ed345ea..2e6d0130f 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -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 @@ X11_GL_GetVisual(_THIS, Display * display, int screen) 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) { diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index 073a73c3f..b98ad554b 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -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) { diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h index 6d2d70a8b..390dfa1d4 100644 --- a/src/video/x11/SDL_x11sym.h +++ b/src/video/x11/SDL_x11sym.h @@ -178,17 +178,17 @@ SDL_X11_SYM(int,ipUnallocateAndSendData,(ChannelPtr a,IPCard b),(a,b),return) /* 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 @@ SDL_X11_SYM(void,XShapeCombineMask,(Display *dpy,Window dest,int dest_kind,int x #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* */ diff --git a/src/video/x11/SDL_x11touch.c b/src/video/x11/SDL_x11touch.c index 327648d7b..c9f65c783 100644 --- a/src/video/x11/SDL_x11touch.c +++ b/src/video/x11/SDL_x11touch.c @@ -39,7 +39,6 @@ X11_InitTouch(_THIS) FILE *fd; fd = fopen("/proc/bus/input/devices","r"); - char c; int i = 0; int tsfd; char line[256]; @@ -111,7 +110,7 @@ X11_InitTouch(_THIS) } } - close(fd); + fclose(fd); #endif } diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 6421a1fbd..57c19fecc 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -86,31 +86,6 @@ X11_GetWMStateProperty(_THIS, SDL_Window * window, Atom atoms[3]) 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 @@ X11_CreateWindow(_THIS, SDL_Window * window) xattr.border_pixel = 0; if (visual->class == DirectColor) { - Status status; XColor *colorcells; int i; int ncolors; @@ -757,7 +731,6 @@ X11_SetWindowPosition(_THIS, SDL_Window * window) { 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 @@ X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) 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");