Fixes for -Wdeclaration-after-statement
authorGabriel Jacobo <gabomdq@gmail.com>
Wed, 21 Aug 2013 10:12:16 -0300
changeset 7679 b1fe132bc6a4
parent 7678 286c42d7c5ed
child 7680 6ab959ebea26
Fixes for -Wdeclaration-after-statement
src/render/opengles/SDL_render_gles.c
src/timer/unix/SDL_systimer.c
src/video/SDL_egl.c
src/video/SDL_fillrect.c
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11opengl.c
src/video/x11/SDL_x11shape.c
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11xinput2.c
--- a/src/render/opengles/SDL_render_gles.c	Wed Aug 21 09:47:10 2013 -0300
+++ b/src/render/opengles/SDL_render_gles.c	Wed Aug 21 10:12:16 2013 -0300
@@ -864,6 +864,8 @@
     GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
     GLfloat minx, miny, maxx, maxy;
     GLfloat minu, maxu, minv, maxv;
+    GLfloat vertices[8];
+    GLfloat texCoords[8];
 
     GLES_ActivateRenderer(renderer);
 
@@ -924,9 +926,6 @@
         maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
         maxv *= texturedata->texh;
 
-        GLfloat vertices[8];
-        GLfloat texCoords[8];
-
         vertices[0] = minx;
         vertices[1] = miny;
         vertices[2] = maxx;
@@ -965,6 +964,9 @@
     GLfloat minx, miny, maxx, maxy;
     GLfloat minu, maxu, minv, maxv;
     GLfloat centerx, centery;
+    GLfloat vertices[8];
+    GLfloat texCoords[8];
+
 
     GLES_ActivateRenderer(renderer);
 
@@ -1015,9 +1017,6 @@
     maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
     maxv *= texturedata->texh;
 
-    GLfloat vertices[8];
-    GLfloat texCoords[8];
-
     vertices[0] = minx;
     vertices[1] = miny;
     vertices[2] = maxx;
--- a/src/timer/unix/SDL_systimer.c	Wed Aug 21 09:47:10 2013 -0300
+++ b/src/timer/unix/SDL_systimer.c	Wed Aug 21 10:12:16 2013 -0300
@@ -86,11 +86,11 @@
 Uint32
 SDL_GetTicks(void)
 {
+    Uint32 ticks;
     if (!ticks_started) {
         SDL_InitTicks();
     }
 
-    Uint32 ticks;
     if (has_monotonic_time) {
 #if HAVE_CLOCK_GETTIME
         struct timespec now;
@@ -115,11 +115,11 @@
 Uint64
 SDL_GetPerformanceCounter(void)
 {
+    Uint64 ticks;
     if (!ticks_started) {
         SDL_InitTicks();
     }
 
-    Uint64 ticks;
     if (has_monotonic_time) {
 #if HAVE_CLOCK_GETTIME
         struct timespec now;
--- a/src/video/SDL_egl.c	Wed Aug 21 09:47:10 2013 -0300
+++ b/src/video/SDL_egl.c	Wed Aug 21 10:12:16 2013 -0300
@@ -305,12 +305,12 @@
 int
 SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context)
 {
+    EGLContext egl_context = (EGLContext) context;
+
     if (!_this->egl_data) {
         return SDL_SetError("OpenGL not initialized");
     }
     
-    EGLContext egl_context = (EGLContext) context;
-    
     /* The android emulator crashes badly if you try to eglMakeCurrent 
      * with a valid context and invalid surface, so we have to check for both here.
      */
@@ -330,11 +330,12 @@
 int
 SDL_EGL_SetSwapInterval(_THIS, int interval)
 {
+    EGLBoolean status;
+    
     if (_this->egl_data) {
         return SDL_SetError("OpenGL ES context not active");
     }
     
-    EGLBoolean status;
     status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval);
     if (status == EGL_TRUE) {
         _this->egl_data->egl_swapinterval = interval;
@@ -363,13 +364,13 @@
 void
 SDL_EGL_DeleteContext(_THIS, SDL_GLContext context)
 {
+    EGLContext egl_context = (EGLContext) context;
+
     /* Clean up GLES and EGL */
     if (!_this->egl_data) {
         return;
     }
     
-    EGLContext egl_context = (EGLContext) context;
-    
     if (!egl_context && egl_context != EGL_NO_CONTEXT) {
         SDL_EGL_MakeCurrent(_this, NULL, NULL);
         _this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context);
--- a/src/video/SDL_fillrect.c	Wed Aug 21 09:47:10 2013 -0300
+++ b/src/video/SDL_fillrect.c	Wed Aug 21 10:12:16 2013 -0300
@@ -36,12 +36,13 @@
     c128.m128_u32[3] = color;
 #else
 #define SSE_BEGIN \
+    __m128 c128; \
     DECLARE_ALIGNED(Uint32, cccc[4], 16); \
     cccc[0] = color; \
     cccc[1] = color; \
     cccc[2] = color; \
     cccc[3] = color; \
-    __m128 c128 = *(__m128 *)cccc;
+    c128 = *(__m128 *)cccc;
 #endif
 
 #define SSE_WORK \
@@ -59,11 +60,14 @@
 static void \
 SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
 { \
+    int i, n; \
+    Uint8 *p = NULL; \
+ \
     SSE_BEGIN; \
  \
     while (h--) { \
-        int i, n = w * bpp; \
-        Uint8 *p = pixels; \
+        n = w * bpp; \
+        p = pixels; \
  \
         if (n > 63) { \
             int adjust = 16 - ((uintptr_t)p & 15); \
@@ -94,11 +98,13 @@
 static void
 SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
 {
+    int i, n;
+    Uint8 *p = NULL;
+    
     SSE_BEGIN;
-
     while (h--) {
-        int i, n = w;
-        Uint8 *p = pixels;
+        n = w;
+        p = pixels;
 
         if (n > 63) {
             int adjust = 16 - ((uintptr_t)p & 15);
@@ -152,11 +158,14 @@
 static void \
 SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
 { \
+    int i, n; \
+    Uint8 *p = NULL; \
+ \
     MMX_BEGIN; \
  \
     while (h--) { \
-        int i, n = w * bpp; \
-        Uint8 *p = pixels; \
+        n = w * bpp; \
+        p = pixels; \
  \
         if (n > 63) { \
             int adjust = 8 - ((uintptr_t)p & 7); \
--- a/src/video/x11/SDL_x11events.c	Wed Aug 21 09:47:10 2013 -0300
+++ b/src/video/x11/SDL_x11events.c	Wed Aug 21 10:12:16 2013 -0300
@@ -173,11 +173,12 @@
 */
 static char* X11_URIToLocal(char* uri) {
     char *file = NULL;
+    SDL_bool local;
 
     if (memcmp(uri,"file:/",6) == 0) uri += 6;      /* local file? */
     else if (strstr(uri,":/") != NULL) return file; /* wrong scheme */
 
-    SDL_bool local = uri[0] != '/' || ( uri[0] != '\0' && uri[1] == '/' );
+    local = uri[0] != '/' || ( uri[0] != '\0' && uri[1] == '/' );
 
     /* got a hostname? */
     if ( !local && uri[0] == '/' && uri[2] != '/' ) {
@@ -267,6 +268,7 @@
     SDL_WindowData *data;
     XEvent xevent;
     int i;
+    XClientMessageEvent m;
 
     SDL_zero(xevent);           /* valgrind fix. --ryan. */
     XNextEvent(display, &xevent);
@@ -549,7 +551,6 @@
             else if (xevent.xclient.message_type == videodata->XdndPosition) {
 
                 /* reply with status */
-                XClientMessageEvent m;
                 memset(&m, 0, sizeof(XClientMessageEvent));
                 m.type = ClientMessage;
                 m.display = xevent.xclient.display;
@@ -568,7 +569,6 @@
             else if(xevent.xclient.message_type == videodata->XdndDrop) {
                 if (data->xdnd_req == None) {
                     /* say again - not interested! */
-                    XClientMessageEvent m;
                     memset(&m, 0, sizeof(XClientMessageEvent));
                     m.type = ClientMessage;
                     m.display = xevent.xclient.display;
@@ -841,7 +841,6 @@
                 XFree(p.data);
 
                 /* send reply */
-                XClientMessageEvent m;
                 SDL_memset(&m, 0, sizeof(XClientMessageEvent));
                 m.type = ClientMessage;
                 m.display = display;
--- a/src/video/x11/SDL_x11opengl.c	Wed Aug 21 09:47:10 2013 -0300
+++ b/src/video/x11/SDL_x11opengl.c	Wed Aug 21 10:12:16 2013 -0300
@@ -564,6 +564,7 @@
     XVisualInfo v, *vinfo;
     int n;
     GLXContext context = NULL, share_context;
+    PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = NULL;
 
     if (_this->gl_config.share_with_current_context) {
         share_context = (GLXContext)SDL_GL_GetCurrentContext();
@@ -617,7 +618,7 @@
                 attribs[iattr++] = 0;
 
                 /* Get a pointer to the context creation function for GL 3.0 */
-                PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs =
+                glXCreateContextAttribs =
                     (PFNGLXCREATECONTEXTATTRIBSARBPROC) _this->gl_data->
                     glXGetProcAddress((GLubyte *)
                                       "glXCreateContextAttribsARB");
--- a/src/video/x11/SDL_x11shape.c	Wed Aug 21 09:47:10 2013 -0300
+++ b/src/video/x11/SDL_x11shape.c	Wed Aug 21 10:12:16 2013 -0300
@@ -36,6 +36,8 @@
 SDL_WindowShaper*
 X11_CreateShaper(SDL_Window* window) {
     SDL_WindowShaper* result = NULL;
+    SDL_ShapeData* data = NULL;
+    int resized_properly;
 
 #if SDL_VIDEO_DRIVER_X11_XSHAPE
     if (SDL_X11_HAVE_XSHAPE) {  /* Make sure X server supports it. */
@@ -44,12 +46,12 @@
         result->mode.mode = ShapeModeDefault;
         result->mode.parameters.binarizationCutoff = 1;
         result->userx = result->usery = 0;
-        SDL_ShapeData* data = SDL_malloc(sizeof(SDL_ShapeData));
+        data = SDL_malloc(sizeof(SDL_ShapeData));
         result->driverdata = data;
         data->bitmapsize = 0;
         data->bitmap = NULL;
         window->shaper = result;
-        int resized_properly = X11_ResizeWindowShape(window);
+        resized_properly = X11_ResizeWindowShape(window);
         SDL_assert(resized_properly == 0);
     }
 #endif
@@ -60,9 +62,9 @@
 int
 X11_ResizeWindowShape(SDL_Window* window) {
     SDL_ShapeData* data = window->shaper->driverdata;
+    unsigned int bitmapsize = window->w / 8;
     SDL_assert(data != NULL);
 
-    unsigned int bitmapsize = window->w / 8;
     if(window->w % 8 > 0)
         bitmapsize += 1;
     bitmapsize *= window->h;
@@ -86,6 +88,10 @@
 
 int
 X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
+    SDL_ShapeData *data = NULL;
+    SDL_WindowData *windowdata = NULL;
+    Pixmap shapemask = NULL;
+    
     if(shaper == NULL || shape == NULL || shaper->driverdata == NULL)
         return -1;
 
@@ -94,13 +100,13 @@
         return -2;
     if(shape->w != shaper->window->w || shape->h != shaper->window->h)
         return -3;
-    SDL_ShapeData *data = shaper->driverdata;
+    data = shaper->driverdata;
 
     /* Assume that shaper->alphacutoff already has a value, because SDL_SetWindowShape() should have given it one. */
     SDL_CalculateShapeBitmap(shaper->mode,shape,data->bitmap,8);
 
-    SDL_WindowData *windowdata = (SDL_WindowData*)(shaper->window->driverdata);
-    Pixmap shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h);
+    windowdata = (SDL_WindowData*)(shaper->window->driverdata);
+    shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h);
 
     XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet);
     XSync(windowdata->videodata->display,False);
--- a/src/video/x11/SDL_x11video.c	Wed Aug 21 09:47:10 2013 -0300
+++ b/src/video/x11/SDL_x11video.c	Wed Aug 21 10:12:16 2013 -0300
@@ -259,10 +259,11 @@
 static int
 X11_SafetyNetErrHandler(Display * d, XErrorEvent * e)
 {
+    SDL_VideoDevice *device = NULL;
     /* if we trigger an error in our error handler, don't try again. */
     if (!safety_net_triggered) {
         safety_net_triggered = SDL_TRUE;
-        SDL_VideoDevice *device = SDL_GetVideoDevice();
+        device = SDL_GetVideoDevice();
         if (device != NULL) {
             int i;
             for (i = 0; i < device->num_displays; i++) {
--- a/src/video/x11/SDL_x11xinput2.c	Wed Aug 21 09:47:10 2013 -0300
+++ b/src/video/x11/SDL_x11xinput2.c	Wed Aug 21 10:12:16 2013 -0300
@@ -206,14 +206,17 @@
 X11_Xinput2SelectTouch(_THIS, SDL_Window *window)
 {
 #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH
+    SDL_VideoData *data = NULL;
+    XIEventMask eventmask;
+    unsigned char mask[3] = { 0,0,0 };
+    SDL_WindowData *window_data = NULL;
+    
     if (!X11_Xinput2IsMultitouchSupported()) {
         return;
     }
 
-    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    XIEventMask eventmask;
-    unsigned char mask[3] = { 0,0,0 };
-    SDL_WindowData *window_data = (SDL_WindowData*)window->driverdata;
+    data = (SDL_VideoData *) _this->driverdata;
+    window_data = (SDL_WindowData*)window->driverdata;
 
     eventmask.deviceid = XIAllMasterDevices;
     eventmask.mask_len = sizeof(mask);