Commit afe14829b8aa8d3a159c5ab85f8c07b9121a5fc1

Sam Lantinga 2014-06-25T00:43:10

Fixed bug 2556 - add compilation flag -Wshadow Sylvain here's the full patch for Blit + RLE.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
diff --git a/configure b/configure
index 799d175..efca355 100755
--- a/configure
+++ b/configure
@@ -23374,7 +23374,7 @@ $as_echo "#define SDL_FILESYSTEM_NACL 1" >>confdefs.h
 esac
 
 CheckWarnAll
-#CheckWarnShadow
+CheckWarnShadow
 
 # Verify that we have all the platform specific files we need
 
diff --git a/configure.in b/configure.in
index 2ea3818..e0dfac1 100644
--- a/configure.in
+++ b/configure.in
@@ -3238,7 +3238,7 @@ esac
 
 dnl Do this on all platforms, after everything else.
 CheckWarnAll
-#CheckWarnShadow
+CheckWarnShadow
 
 # Verify that we have all the platform specific files we need
 
diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c
index 6cd9333..3724f4f 100644
--- a/src/thread/SDL_thread.c
+++ b/src/thread/SDL_thread.c
@@ -442,10 +442,10 @@ SDL_DetachThread(SDL_Thread * thread)
         SDL_SYS_DetachThread(thread);
     } else {
         /* all other states are pretty final, see where we landed. */
-        const int state = SDL_AtomicGet(&thread->state);
-        if ((state == SDL_THREAD_STATE_DETACHED) || (state == SDL_THREAD_STATE_CLEANED)) {
+        const int thread_state = SDL_AtomicGet(&thread->state);
+        if ((thread_state == SDL_THREAD_STATE_DETACHED) || (thread_state == SDL_THREAD_STATE_CLEANED)) {
             return;  /* already detached (you shouldn't call this twice!) */
-        } else if (state == SDL_THREAD_STATE_ZOMBIE) {
+        } else if (thread_state == SDL_THREAD_STATE_ZOMBIE) {
             SDL_WaitThread(thread, NULL);  /* already done, clean it up. */
         } else {
             SDL_assert(0 && "Unexpected thread state");
diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c
index a464dec..5829367 100644
--- a/src/video/SDL_RLEaccel.c
+++ b/src/video/SDL_RLEaccel.c
@@ -376,10 +376,10 @@
  * right. Top clipping has already been taken care of.
  */
 static void
-RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
+RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst,
             Uint8 * dstbuf, SDL_Rect * srcrect, unsigned alpha)
 {
-    SDL_PixelFormat *fmt = dst->format;
+    SDL_PixelFormat *fmt = surf_dst->format;
 
 #define RLECLIPBLIT(bpp, Type, do_blit)                    \
     do {                                   \
@@ -418,7 +418,7 @@ RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
         break;                             \
         if(ofs == w) {                         \
         ofs = 0;                           \
-        dstbuf += dst->pitch;                      \
+        dstbuf += surf_dst->pitch;                      \
         if(!--linecount)                       \
             break;                         \
         }                                  \
@@ -434,18 +434,18 @@ RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
 
 /* blit a colorkeyed RLE surface */
 int
-SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
-            SDL_Surface * dst, SDL_Rect * dstrect)
+SDL_RLEBlit(SDL_Surface * surf_src, SDL_Rect * srcrect,
+            SDL_Surface * surf_dst, SDL_Rect * dstrect)
 {
     Uint8 *dstbuf;
     Uint8 *srcbuf;
     int x, y;
-    int w = src->w;
+    int w = surf_src->w;
     unsigned alpha;
 
     /* Lock the destination if necessary */
-    if (SDL_MUSTLOCK(dst)) {
-        if (SDL_LockSurface(dst) < 0) {
+    if (SDL_MUSTLOCK(surf_dst)) {
+        if (SDL_LockSurface(surf_dst) < 0) {
             return (-1);
         }
     }
@@ -453,9 +453,9 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
     /* Set up the source and destination pointers */
     x = dstrect->x;
     y = dstrect->y;
-    dstbuf = (Uint8 *) dst->pixels
-        + y * dst->pitch + x * src->format->BytesPerPixel;
-    srcbuf = (Uint8 *) src->map->data;
+    dstbuf = (Uint8 *) surf_dst->pixels
+        + y * surf_dst->pitch + x * surf_src->format->BytesPerPixel;
+    srcbuf = (Uint8 *) surf_src->map->data;
 
     {
         /* skip lines at the top if necessary */
@@ -481,7 +481,7 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
             }               \
         }
 
-            switch (src->format->BytesPerPixel) {
+            switch (surf_src->format->BytesPerPixel) {
             case 1:
                 RLESKIP(1, Uint8);
                 break;
@@ -501,12 +501,12 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
         }
     }
 
-    alpha = src->map->info.a;
+    alpha = surf_src->map->info.a;
     /* if left or right edge clipping needed, call clip blit */
-    if (srcrect->x || srcrect->w != src->w) {
-        RLEClipBlit(w, srcbuf, dst, dstbuf, srcrect, alpha);
+    if (srcrect->x || srcrect->w != surf_src->w) {
+        RLEClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect, alpha);
     } else {
-        SDL_PixelFormat *fmt = src->format;
+        SDL_PixelFormat *fmt = surf_src->format;
 
 #define RLEBLIT(bpp, Type, do_blit)                       \
         do {                                  \
@@ -525,7 +525,7 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
             break;                            \
             if(ofs == w) {                        \
             ofs = 0;                          \
-            dstbuf += dst->pitch;                     \
+            dstbuf += surf_dst->pitch;                     \
             if(!--linecount)                      \
                 break;                        \
             }                                 \
@@ -539,8 +539,8 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
 
   done:
     /* Unlock the destination if necessary */
-    if (SDL_MUSTLOCK(dst)) {
-        SDL_UnlockSurface(dst);
+    if (SDL_MUSTLOCK(surf_dst)) {
+        SDL_UnlockSurface(surf_dst);
     }
     return (0);
 }
@@ -620,10 +620,10 @@ typedef struct
 
 /* blit a pixel-alpha RLE surface clipped at the right and/or left edges */
 static void
-RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
+RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst,
                  Uint8 * dstbuf, SDL_Rect * srcrect)
 {
-    SDL_PixelFormat *df = dst->format;
+    SDL_PixelFormat *df = surf_dst->format;
     /*
      * clipped blitter: Ptype is the destination pixel type,
      * Ctype the translucent count type, and do_blend the macro
@@ -693,7 +693,7 @@ RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
             ofs += run;                       \
         }                             \
         } while(ofs < w);                         \
-        dstbuf += dst->pitch;                     \
+        dstbuf += surf_dst->pitch;                     \
     } while(--linecount);                         \
     } while(0)
 
@@ -712,25 +712,25 @@ RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
 
 /* blit a pixel-alpha RLE surface */
 int
-SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
-                 SDL_Surface * dst, SDL_Rect * dstrect)
+SDL_RLEAlphaBlit(SDL_Surface * surf_src, SDL_Rect * srcrect,
+                 SDL_Surface * surf_dst, SDL_Rect * dstrect)
 {
     int x, y;
-    int w = src->w;
+    int w = surf_src->w;
     Uint8 *srcbuf, *dstbuf;
-    SDL_PixelFormat *df = dst->format;
+    SDL_PixelFormat *df = surf_dst->format;
 
     /* Lock the destination if necessary */
-    if (SDL_MUSTLOCK(dst)) {
-        if (SDL_LockSurface(dst) < 0) {
+    if (SDL_MUSTLOCK(surf_dst)) {
+        if (SDL_LockSurface(surf_dst) < 0) {
             return -1;
         }
     }
 
     x = dstrect->x;
     y = dstrect->y;
-    dstbuf = (Uint8 *) dst->pixels + y * dst->pitch + x * df->BytesPerPixel;
-    srcbuf = (Uint8 *) src->map->data + sizeof(RLEDestFormat);
+    dstbuf = (Uint8 *) surf_dst->pixels + y * surf_dst->pitch + x * df->BytesPerPixel;
+    srcbuf = (Uint8 *) surf_src->map->data + sizeof(RLEDestFormat);
 
     {
         /* skip lines at the top if necessary */
@@ -789,8 +789,8 @@ SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
     }
 
     /* if left or right edge clipping needed, call clip blit */
-    if (srcrect->x || srcrect->w != src->w) {
-        RLEAlphaClipBlit(w, srcbuf, dst, dstbuf, srcrect);
+    if (srcrect->x || srcrect->w != surf_src->w) {
+        RLEAlphaClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect);
     } else {
 
         /*
@@ -839,7 +839,7 @@ SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
             ofs += run;                  \
             }                            \
         } while(ofs < w);                    \
-        dstbuf += dst->pitch;                    \
+        dstbuf += surf_dst->pitch;                    \
         } while(--linecount);                    \
     } while(0)
 
@@ -859,8 +859,8 @@ SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
 
   done:
     /* Unlock the destination if necessary */
-    if (SDL_MUSTLOCK(dst)) {
-        SDL_UnlockSurface(dst);
+    if (SDL_MUSTLOCK(surf_dst)) {
+        SDL_UnlockSurface(surf_dst);
     }
     return 0;
 }
diff --git a/src/video/SDL_blit.h b/src/video/SDL_blit.h
index caf6c00..f12018d 100644
--- a/src/video/SDL_blit.h
+++ b/src/video/SDL_blit.h
@@ -402,18 +402,18 @@ do {                                                                    \
 {                                                                       \
     switch (bpp) {                                                      \
         case 1: {                                                       \
-            Uint8 Pixel;                                                \
+            Uint8 _pixel;                                               \
                                                                         \
-            PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a);                    \
-            *((Uint8 *)(buf)) = Pixel;                                  \
+            PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a);                   \
+            *((Uint8 *)(buf)) = _pixel;                                 \
         }                                                               \
         break;                                                          \
                                                                         \
         case 2: {                                                       \
-            Uint16 Pixel;                                               \
+            Uint16 _pixel;                                              \
                                                                         \
-            PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a);                    \
-            *((Uint16 *)(buf)) = Pixel;                                 \
+            PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a);                   \
+            *((Uint16 *)(buf)) = _pixel;                                \
         }                                                               \
         break;                                                          \
                                                                         \
@@ -431,10 +431,10 @@ do {                                                                    \
         break;                                                          \
                                                                         \
         case 4: {                                                       \
-            Uint32 Pixel;                                               \
+            Uint32 _pixel;                                              \
                                                                         \
-            PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a);                    \
-            *((Uint32 *)(buf)) = Pixel;                                 \
+            PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a);                   \
+            *((Uint32 *)(buf)) = _pixel;                                \
         }                                                               \
         break;                                                          \
     }                                                                   \
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index dc6cf37..11492f6 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -232,16 +232,13 @@ ShouldUseTextureFramebuffer()
 }
 
 static int
-SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
+SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
 {
     SDL_WindowTextureData *data;
-    SDL_RendererInfo info;
-    Uint32 i;
 
     data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
     if (!data) {
         SDL_Renderer *renderer = NULL;
-        SDL_RendererInfo info;
         int i;
         const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
 
@@ -249,6 +246,7 @@ SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pix
         if (hint && *hint != '0' && *hint != '1' &&
             SDL_strcasecmp(hint, "software") != 0) {
             for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
+                SDL_RendererInfo info;
                 SDL_GetRenderDriverInfo(i, &info);
                 if (SDL_strcasecmp(info.name, hint) == 0) {
                     renderer = SDL_CreateRenderer(window, i, 0);
@@ -259,6 +257,7 @@ SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pix
         
         if (!renderer) {
             for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
+                SDL_RendererInfo info;
                 SDL_GetRenderDriverInfo(i, &info);
                 if (SDL_strcmp(info.name, "software") != 0) {
                     renderer = SDL_CreateRenderer(window, i, 0);
@@ -291,17 +290,23 @@ SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pix
     SDL_free(data->pixels);
     data->pixels = NULL;
 
-    if (SDL_GetRendererInfo(data->renderer, &info) < 0) {
-        return -1;
-    }
+    {
+        SDL_RendererInfo info;
+        Uint32 i;
 
-    /* Find the first format without an alpha channel */
-    *format = info.texture_formats[0];
-    for (i = 0; i < info.num_texture_formats; ++i) {
-        if (!SDL_ISPIXELFORMAT_FOURCC(info.texture_formats[i]) &&
-            !SDL_ISPIXELFORMAT_ALPHA(info.texture_formats[i])) {
-            *format = info.texture_formats[i];
-            break;
+        if (SDL_GetRendererInfo(data->renderer, &info) < 0) {
+            return -1;
+        }
+
+        /* Find the first format without an alpha channel */
+        *format = info.texture_formats[0];
+
+        for (i = 0; i < info.num_texture_formats; ++i) {
+            if (!SDL_ISPIXELFORMAT_FOURCC(info.texture_formats[i]) &&
+                    !SDL_ISPIXELFORMAT_ALPHA(info.texture_formats[i])) {
+                *format = info.texture_formats[i];
+                break;
+            }
         }
     }
 
@@ -330,7 +335,7 @@ SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pix
 }
 
 static int
-SDL_UpdateWindowTexture(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects)
+SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, const SDL_Rect * rects, int numrects)
 {
     SDL_WindowTextureData *data;
     SDL_Rect rect;
@@ -360,7 +365,7 @@ SDL_UpdateWindowTexture(_THIS, SDL_Window * window, const SDL_Rect * rects, int 
 }
 
 static void
-SDL_DestroyWindowTexture(_THIS, SDL_Window * window)
+SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window * window)
 {
     SDL_WindowTextureData *data;
 
diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c
index 6336f0c..cd7b38c 100644
--- a/src/video/x11/SDL_x11modes.c
+++ b/src/video/x11/SDL_x11modes.c
@@ -674,7 +674,6 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
     int screen_w;
     int screen_h;
     SDL_DisplayMode mode;
-    SDL_DisplayModeData *modedata;
 
     /* Unfortunately X11 requires the window to be created with the correct
      * visual and depth ahead of time, but the SDL API allows you to create
@@ -692,6 +691,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
     if (data->use_xinerama) {
         if (data->use_vidmode && !data->xinerama_info.x_org && !data->xinerama_info.y_org &&
            (screen_w > data->xinerama_info.width || screen_h > data->xinerama_info.height)) {
+            SDL_DisplayModeData *modedata;
             /* Add the full (both screens combined) xinerama mode only on the display that starts at 0,0
              * if we're using vidmode.
              */
@@ -707,6 +707,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
         }
         else if (!data->use_xrandr)
         {
+            SDL_DisplayModeData *modedata;
             /* Add the current mode of each monitor otherwise if we can't get them from xrandr */
             mode.w = data->xinerama_info.width;
             mode.h = data->xinerama_info.height;
@@ -759,6 +760,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
     if (data->use_vidmode &&
         X11_XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) {
         int i;
+        SDL_DisplayModeData *modedata;
 
 #ifdef X11MODES_DEBUG
         printf("VidMode modes: (unsorted)\n");
@@ -787,6 +789,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
 #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
 
     if (!data->use_xrandr && !data->use_vidmode) {
+        SDL_DisplayModeData *modedata;
         /* Add the desktop mode */
         mode = sdl_display->desktop_mode;
         modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData));
diff --git a/src/video/x11/edid-parse.c b/src/video/x11/edid-parse.c
index 8608bf2..2c145e2 100644
--- a/src/video/x11/edid-parse.c
+++ b/src/video/x11/edid-parse.c
@@ -548,7 +548,6 @@ yesno (int v)
 void
 dump_monitor_info (MonitorInfo *info)
 {
-    char *s;
     int i;
     
     printf ("Checksum: %d (%s)\n",
@@ -601,6 +600,7 @@ dump_monitor_info (MonitorInfo *info)
     }
     else
     {
+       const char *s;
 	printf ("Video Signal Level: %f\n", info->analog.video_signal_level);
 	printf ("Sync Signal Level: %f\n", info->analog.sync_signal_level);
 	printf ("Total Signal Level: %f\n", info->analog.total_signal_level);