Fixes for -Wdeclaration-after-statement

This commit is contained in:
Gabriel Jacobo 2013-08-21 10:12:16 -03:00
parent 1e49b1ed6e
commit 2490166d2d
9 changed files with 56 additions and 37 deletions

View File

@ -864,6 +864,8 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
GLfloat minx, miny, maxx, maxy; GLfloat minx, miny, maxx, maxy;
GLfloat minu, maxu, minv, maxv; GLfloat minu, maxu, minv, maxv;
GLfloat vertices[8];
GLfloat texCoords[8];
GLES_ActivateRenderer(renderer); GLES_ActivateRenderer(renderer);
@ -924,9 +926,6 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
maxv *= texturedata->texh; maxv *= texturedata->texh;
GLfloat vertices[8];
GLfloat texCoords[8];
vertices[0] = minx; vertices[0] = minx;
vertices[1] = miny; vertices[1] = miny;
vertices[2] = maxx; vertices[2] = maxx;
@ -965,6 +964,9 @@ GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
GLfloat minx, miny, maxx, maxy; GLfloat minx, miny, maxx, maxy;
GLfloat minu, maxu, minv, maxv; GLfloat minu, maxu, minv, maxv;
GLfloat centerx, centery; GLfloat centerx, centery;
GLfloat vertices[8];
GLfloat texCoords[8];
GLES_ActivateRenderer(renderer); GLES_ActivateRenderer(renderer);
@ -1015,9 +1017,6 @@ GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
maxv *= texturedata->texh; maxv *= texturedata->texh;
GLfloat vertices[8];
GLfloat texCoords[8];
vertices[0] = minx; vertices[0] = minx;
vertices[1] = miny; vertices[1] = miny;
vertices[2] = maxx; vertices[2] = maxx;

View File

@ -86,11 +86,11 @@ SDL_InitTicks(void)
Uint32 Uint32
SDL_GetTicks(void) SDL_GetTicks(void)
{ {
Uint32 ticks;
if (!ticks_started) { if (!ticks_started) {
SDL_InitTicks(); SDL_InitTicks();
} }
Uint32 ticks;
if (has_monotonic_time) { if (has_monotonic_time) {
#if HAVE_CLOCK_GETTIME #if HAVE_CLOCK_GETTIME
struct timespec now; struct timespec now;
@ -115,11 +115,11 @@ SDL_GetTicks(void)
Uint64 Uint64
SDL_GetPerformanceCounter(void) SDL_GetPerformanceCounter(void)
{ {
Uint64 ticks;
if (!ticks_started) { if (!ticks_started) {
SDL_InitTicks(); SDL_InitTicks();
} }
Uint64 ticks;
if (has_monotonic_time) { if (has_monotonic_time) {
#if HAVE_CLOCK_GETTIME #if HAVE_CLOCK_GETTIME
struct timespec now; struct timespec now;

View File

@ -305,12 +305,12 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
int int
SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context) SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context)
{ {
EGLContext egl_context = (EGLContext) context;
if (!_this->egl_data) { if (!_this->egl_data) {
return SDL_SetError("OpenGL not initialized"); return SDL_SetError("OpenGL not initialized");
} }
EGLContext egl_context = (EGLContext) context;
/* The android emulator crashes badly if you try to eglMakeCurrent /* 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. * with a valid context and invalid surface, so we have to check for both here.
*/ */
@ -330,11 +330,12 @@ SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context)
int int
SDL_EGL_SetSwapInterval(_THIS, int interval) SDL_EGL_SetSwapInterval(_THIS, int interval)
{ {
EGLBoolean status;
if (_this->egl_data) { if (_this->egl_data) {
return SDL_SetError("OpenGL ES context not active"); return SDL_SetError("OpenGL ES context not active");
} }
EGLBoolean status;
status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval); status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval);
if (status == EGL_TRUE) { if (status == EGL_TRUE) {
_this->egl_data->egl_swapinterval = interval; _this->egl_data->egl_swapinterval = interval;
@ -363,13 +364,13 @@ SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface)
void void
SDL_EGL_DeleteContext(_THIS, SDL_GLContext context) SDL_EGL_DeleteContext(_THIS, SDL_GLContext context)
{ {
EGLContext egl_context = (EGLContext) context;
/* Clean up GLES and EGL */ /* Clean up GLES and EGL */
if (!_this->egl_data) { if (!_this->egl_data) {
return; return;
} }
EGLContext egl_context = (EGLContext) context;
if (!egl_context && egl_context != EGL_NO_CONTEXT) { if (!egl_context && egl_context != EGL_NO_CONTEXT) {
SDL_EGL_MakeCurrent(_this, NULL, NULL); SDL_EGL_MakeCurrent(_this, NULL, NULL);
_this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context); _this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context);

View File

@ -36,12 +36,13 @@
c128.m128_u32[3] = color; c128.m128_u32[3] = color;
#else #else
#define SSE_BEGIN \ #define SSE_BEGIN \
__m128 c128; \
DECLARE_ALIGNED(Uint32, cccc[4], 16); \ DECLARE_ALIGNED(Uint32, cccc[4], 16); \
cccc[0] = color; \ cccc[0] = color; \
cccc[1] = color; \ cccc[1] = color; \
cccc[2] = color; \ cccc[2] = color; \
cccc[3] = color; \ cccc[3] = color; \
__m128 c128 = *(__m128 *)cccc; c128 = *(__m128 *)cccc;
#endif #endif
#define SSE_WORK \ #define SSE_WORK \
@ -59,11 +60,14 @@
static void \ static void \
SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
{ \ { \
int i, n; \
Uint8 *p = NULL; \
\
SSE_BEGIN; \ SSE_BEGIN; \
\ \
while (h--) { \ while (h--) { \
int i, n = w * bpp; \ n = w * bpp; \
Uint8 *p = pixels; \ p = pixels; \
\ \
if (n > 63) { \ if (n > 63) { \
int adjust = 16 - ((uintptr_t)p & 15); \ int adjust = 16 - ((uintptr_t)p & 15); \
@ -94,11 +98,13 @@ SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
static void static void
SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
{ {
SSE_BEGIN; int i, n;
Uint8 *p = NULL;
SSE_BEGIN;
while (h--) { while (h--) {
int i, n = w; n = w;
Uint8 *p = pixels; p = pixels;
if (n > 63) { if (n > 63) {
int adjust = 16 - ((uintptr_t)p & 15); int adjust = 16 - ((uintptr_t)p & 15);
@ -152,11 +158,14 @@ DEFINE_SSE_FILLRECT(4, Uint32)
static void \ static void \
SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
{ \ { \
int i, n; \
Uint8 *p = NULL; \
\
MMX_BEGIN; \ MMX_BEGIN; \
\ \
while (h--) { \ while (h--) { \
int i, n = w * bpp; \ n = w * bpp; \
Uint8 *p = pixels; \ p = pixels; \
\ \
if (n > 63) { \ if (n > 63) { \
int adjust = 8 - ((uintptr_t)p & 7); \ int adjust = 8 - ((uintptr_t)p & 7); \

View File

@ -173,11 +173,12 @@ static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks)
*/ */
static char* X11_URIToLocal(char* uri) { static char* X11_URIToLocal(char* uri) {
char *file = NULL; char *file = NULL;
SDL_bool local;
if (memcmp(uri,"file:/",6) == 0) uri += 6; /* local file? */ if (memcmp(uri,"file:/",6) == 0) uri += 6; /* local file? */
else if (strstr(uri,":/") != NULL) return file; /* wrong scheme */ 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? */ /* got a hostname? */
if ( !local && uri[0] == '/' && uri[2] != '/' ) { if ( !local && uri[0] == '/' && uri[2] != '/' ) {
@ -267,6 +268,7 @@ X11_DispatchEvent(_THIS)
SDL_WindowData *data; SDL_WindowData *data;
XEvent xevent; XEvent xevent;
int i; int i;
XClientMessageEvent m;
SDL_zero(xevent); /* valgrind fix. --ryan. */ SDL_zero(xevent); /* valgrind fix. --ryan. */
XNextEvent(display, &xevent); XNextEvent(display, &xevent);
@ -549,7 +551,6 @@ X11_DispatchEvent(_THIS)
else if (xevent.xclient.message_type == videodata->XdndPosition) { else if (xevent.xclient.message_type == videodata->XdndPosition) {
/* reply with status */ /* reply with status */
XClientMessageEvent m;
memset(&m, 0, sizeof(XClientMessageEvent)); memset(&m, 0, sizeof(XClientMessageEvent));
m.type = ClientMessage; m.type = ClientMessage;
m.display = xevent.xclient.display; m.display = xevent.xclient.display;
@ -568,7 +569,6 @@ X11_DispatchEvent(_THIS)
else if(xevent.xclient.message_type == videodata->XdndDrop) { else if(xevent.xclient.message_type == videodata->XdndDrop) {
if (data->xdnd_req == None) { if (data->xdnd_req == None) {
/* say again - not interested! */ /* say again - not interested! */
XClientMessageEvent m;
memset(&m, 0, sizeof(XClientMessageEvent)); memset(&m, 0, sizeof(XClientMessageEvent));
m.type = ClientMessage; m.type = ClientMessage;
m.display = xevent.xclient.display; m.display = xevent.xclient.display;
@ -841,7 +841,6 @@ X11_DispatchEvent(_THIS)
XFree(p.data); XFree(p.data);
/* send reply */ /* send reply */
XClientMessageEvent m;
SDL_memset(&m, 0, sizeof(XClientMessageEvent)); SDL_memset(&m, 0, sizeof(XClientMessageEvent));
m.type = ClientMessage; m.type = ClientMessage;
m.display = display; m.display = display;

View File

@ -564,6 +564,7 @@ X11_GL_CreateContext(_THIS, SDL_Window * window)
XVisualInfo v, *vinfo; XVisualInfo v, *vinfo;
int n; int n;
GLXContext context = NULL, share_context; GLXContext context = NULL, share_context;
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = NULL;
if (_this->gl_config.share_with_current_context) { if (_this->gl_config.share_with_current_context) {
share_context = (GLXContext)SDL_GL_GetCurrentContext(); share_context = (GLXContext)SDL_GL_GetCurrentContext();
@ -617,7 +618,7 @@ X11_GL_CreateContext(_THIS, SDL_Window * window)
attribs[iattr++] = 0; attribs[iattr++] = 0;
/* Get a pointer to the context creation function for GL 3.0 */ /* Get a pointer to the context creation function for GL 3.0 */
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = glXCreateContextAttribs =
(PFNGLXCREATECONTEXTATTRIBSARBPROC) _this->gl_data-> (PFNGLXCREATECONTEXTATTRIBSARBPROC) _this->gl_data->
glXGetProcAddress((GLubyte *) glXGetProcAddress((GLubyte *)
"glXCreateContextAttribsARB"); "glXCreateContextAttribsARB");

View File

@ -36,6 +36,8 @@ X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned
SDL_WindowShaper* SDL_WindowShaper*
X11_CreateShaper(SDL_Window* window) { X11_CreateShaper(SDL_Window* window) {
SDL_WindowShaper* result = NULL; SDL_WindowShaper* result = NULL;
SDL_ShapeData* data = NULL;
int resized_properly;
#if SDL_VIDEO_DRIVER_X11_XSHAPE #if SDL_VIDEO_DRIVER_X11_XSHAPE
if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */ if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */
@ -44,12 +46,12 @@ X11_CreateShaper(SDL_Window* window) {
result->mode.mode = ShapeModeDefault; result->mode.mode = ShapeModeDefault;
result->mode.parameters.binarizationCutoff = 1; result->mode.parameters.binarizationCutoff = 1;
result->userx = result->usery = 0; result->userx = result->usery = 0;
SDL_ShapeData* data = SDL_malloc(sizeof(SDL_ShapeData)); data = SDL_malloc(sizeof(SDL_ShapeData));
result->driverdata = data; result->driverdata = data;
data->bitmapsize = 0; data->bitmapsize = 0;
data->bitmap = NULL; data->bitmap = NULL;
window->shaper = result; window->shaper = result;
int resized_properly = X11_ResizeWindowShape(window); resized_properly = X11_ResizeWindowShape(window);
SDL_assert(resized_properly == 0); SDL_assert(resized_properly == 0);
} }
#endif #endif
@ -60,9 +62,9 @@ X11_CreateShaper(SDL_Window* window) {
int int
X11_ResizeWindowShape(SDL_Window* window) { X11_ResizeWindowShape(SDL_Window* window) {
SDL_ShapeData* data = window->shaper->driverdata; SDL_ShapeData* data = window->shaper->driverdata;
unsigned int bitmapsize = window->w / 8;
SDL_assert(data != NULL); SDL_assert(data != NULL);
unsigned int bitmapsize = window->w / 8;
if(window->w % 8 > 0) if(window->w % 8 > 0)
bitmapsize += 1; bitmapsize += 1;
bitmapsize *= window->h; bitmapsize *= window->h;
@ -86,6 +88,10 @@ X11_ResizeWindowShape(SDL_Window* window) {
int int
X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { 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) if(shaper == NULL || shape == NULL || shaper->driverdata == NULL)
return -1; return -1;
@ -94,13 +100,13 @@ X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMo
return -2; return -2;
if(shape->w != shaper->window->w || shape->h != shaper->window->h) if(shape->w != shaper->window->w || shape->h != shaper->window->h)
return -3; 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. */ /* 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_CalculateShapeBitmap(shaper->mode,shape,data->bitmap,8);
SDL_WindowData *windowdata = (SDL_WindowData*)(shaper->window->driverdata); windowdata = (SDL_WindowData*)(shaper->window->driverdata);
Pixmap shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h); 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); XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet);
XSync(windowdata->videodata->display,False); XSync(windowdata->videodata->display,False);

View File

@ -259,10 +259,11 @@ static int (*orig_x11_errhandler) (Display *, XErrorEvent *) = NULL;
static int static int
X11_SafetyNetErrHandler(Display * d, XErrorEvent * e) X11_SafetyNetErrHandler(Display * d, XErrorEvent * e)
{ {
SDL_VideoDevice *device = NULL;
/* if we trigger an error in our error handler, don't try again. */ /* if we trigger an error in our error handler, don't try again. */
if (!safety_net_triggered) { if (!safety_net_triggered) {
safety_net_triggered = SDL_TRUE; safety_net_triggered = SDL_TRUE;
SDL_VideoDevice *device = SDL_GetVideoDevice(); device = SDL_GetVideoDevice();
if (device != NULL) { if (device != NULL) {
int i; int i;
for (i = 0; i < device->num_displays; i++) { for (i = 0; i < device->num_displays; i++) {

View File

@ -206,14 +206,17 @@ void
X11_Xinput2SelectTouch(_THIS, SDL_Window *window) X11_Xinput2SelectTouch(_THIS, SDL_Window *window)
{ {
#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH #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()) { if (!X11_Xinput2IsMultitouchSupported()) {
return; return;
} }
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; data = (SDL_VideoData *) _this->driverdata;
XIEventMask eventmask; window_data = (SDL_WindowData*)window->driverdata;
unsigned char mask[3] = { 0,0,0 };
SDL_WindowData *window_data = (SDL_WindowData*)window->driverdata;
eventmask.deviceid = XIAllMasterDevices; eventmask.deviceid = XIAllMasterDevices;
eventmask.mask_len = sizeof(mask); eventmask.mask_len = sizeof(mask);