Fixed bug 2556 - add compilation flag -Wshadow
authorSam Lantinga <slouken@libsdl.org>
Wed, 25 Jun 2014 00:43:10 -0700
changeset 8922dfb6f8611ebe
parent 8921 4a9feef61c85
child 8923 b627c37a25e8
Fixed bug 2556 - add compilation flag -Wshadow

Sylvain

here's the full patch for Blit + RLE.
configure
configure.in
src/thread/SDL_thread.c
src/video/SDL_RLEaccel.c
src/video/SDL_blit.h
src/video/SDL_video.c
src/video/x11/SDL_x11modes.c
src/video/x11/edid-parse.c
     1.1 --- a/configure	Wed Jun 25 00:20:21 2014 -0700
     1.2 +++ b/configure	Wed Jun 25 00:43:10 2014 -0700
     1.3 @@ -23374,7 +23374,7 @@
     1.4  esac
     1.5  
     1.6  CheckWarnAll
     1.7 -#CheckWarnShadow
     1.8 +CheckWarnShadow
     1.9  
    1.10  # Verify that we have all the platform specific files we need
    1.11  
     2.1 --- a/configure.in	Wed Jun 25 00:20:21 2014 -0700
     2.2 +++ b/configure.in	Wed Jun 25 00:43:10 2014 -0700
     2.3 @@ -3238,7 +3238,7 @@
     2.4  
     2.5  dnl Do this on all platforms, after everything else.
     2.6  CheckWarnAll
     2.7 -#CheckWarnShadow
     2.8 +CheckWarnShadow
     2.9  
    2.10  # Verify that we have all the platform specific files we need
    2.11  
     3.1 --- a/src/thread/SDL_thread.c	Wed Jun 25 00:20:21 2014 -0700
     3.2 +++ b/src/thread/SDL_thread.c	Wed Jun 25 00:43:10 2014 -0700
     3.3 @@ -442,10 +442,10 @@
     3.4          SDL_SYS_DetachThread(thread);
     3.5      } else {
     3.6          /* all other states are pretty final, see where we landed. */
     3.7 -        const int state = SDL_AtomicGet(&thread->state);
     3.8 -        if ((state == SDL_THREAD_STATE_DETACHED) || (state == SDL_THREAD_STATE_CLEANED)) {
     3.9 +        const int thread_state = SDL_AtomicGet(&thread->state);
    3.10 +        if ((thread_state == SDL_THREAD_STATE_DETACHED) || (thread_state == SDL_THREAD_STATE_CLEANED)) {
    3.11              return;  /* already detached (you shouldn't call this twice!) */
    3.12 -        } else if (state == SDL_THREAD_STATE_ZOMBIE) {
    3.13 +        } else if (thread_state == SDL_THREAD_STATE_ZOMBIE) {
    3.14              SDL_WaitThread(thread, NULL);  /* already done, clean it up. */
    3.15          } else {
    3.16              SDL_assert(0 && "Unexpected thread state");
     4.1 --- a/src/video/SDL_RLEaccel.c	Wed Jun 25 00:20:21 2014 -0700
     4.2 +++ b/src/video/SDL_RLEaccel.c	Wed Jun 25 00:43:10 2014 -0700
     4.3 @@ -376,10 +376,10 @@
     4.4   * right. Top clipping has already been taken care of.
     4.5   */
     4.6  static void
     4.7 -RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
     4.8 +RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst,
     4.9              Uint8 * dstbuf, SDL_Rect * srcrect, unsigned alpha)
    4.10  {
    4.11 -    SDL_PixelFormat *fmt = dst->format;
    4.12 +    SDL_PixelFormat *fmt = surf_dst->format;
    4.13  
    4.14  #define RLECLIPBLIT(bpp, Type, do_blit)                    \
    4.15      do {                                   \
    4.16 @@ -418,7 +418,7 @@
    4.17          break;                             \
    4.18          if(ofs == w) {                         \
    4.19          ofs = 0;                           \
    4.20 -        dstbuf += dst->pitch;                      \
    4.21 +        dstbuf += surf_dst->pitch;                      \
    4.22          if(!--linecount)                       \
    4.23              break;                         \
    4.24          }                                  \
    4.25 @@ -434,18 +434,18 @@
    4.26  
    4.27  /* blit a colorkeyed RLE surface */
    4.28  int
    4.29 -SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
    4.30 -            SDL_Surface * dst, SDL_Rect * dstrect)
    4.31 +SDL_RLEBlit(SDL_Surface * surf_src, SDL_Rect * srcrect,
    4.32 +            SDL_Surface * surf_dst, SDL_Rect * dstrect)
    4.33  {
    4.34      Uint8 *dstbuf;
    4.35      Uint8 *srcbuf;
    4.36      int x, y;
    4.37 -    int w = src->w;
    4.38 +    int w = surf_src->w;
    4.39      unsigned alpha;
    4.40  
    4.41      /* Lock the destination if necessary */
    4.42 -    if (SDL_MUSTLOCK(dst)) {
    4.43 -        if (SDL_LockSurface(dst) < 0) {
    4.44 +    if (SDL_MUSTLOCK(surf_dst)) {
    4.45 +        if (SDL_LockSurface(surf_dst) < 0) {
    4.46              return (-1);
    4.47          }
    4.48      }
    4.49 @@ -453,9 +453,9 @@
    4.50      /* Set up the source and destination pointers */
    4.51      x = dstrect->x;
    4.52      y = dstrect->y;
    4.53 -    dstbuf = (Uint8 *) dst->pixels
    4.54 -        + y * dst->pitch + x * src->format->BytesPerPixel;
    4.55 -    srcbuf = (Uint8 *) src->map->data;
    4.56 +    dstbuf = (Uint8 *) surf_dst->pixels
    4.57 +        + y * surf_dst->pitch + x * surf_src->format->BytesPerPixel;
    4.58 +    srcbuf = (Uint8 *) surf_src->map->data;
    4.59  
    4.60      {
    4.61          /* skip lines at the top if necessary */
    4.62 @@ -481,7 +481,7 @@
    4.63              }               \
    4.64          }
    4.65  
    4.66 -            switch (src->format->BytesPerPixel) {
    4.67 +            switch (surf_src->format->BytesPerPixel) {
    4.68              case 1:
    4.69                  RLESKIP(1, Uint8);
    4.70                  break;
    4.71 @@ -501,12 +501,12 @@
    4.72          }
    4.73      }
    4.74  
    4.75 -    alpha = src->map->info.a;
    4.76 +    alpha = surf_src->map->info.a;
    4.77      /* if left or right edge clipping needed, call clip blit */
    4.78 -    if (srcrect->x || srcrect->w != src->w) {
    4.79 -        RLEClipBlit(w, srcbuf, dst, dstbuf, srcrect, alpha);
    4.80 +    if (srcrect->x || srcrect->w != surf_src->w) {
    4.81 +        RLEClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect, alpha);
    4.82      } else {
    4.83 -        SDL_PixelFormat *fmt = src->format;
    4.84 +        SDL_PixelFormat *fmt = surf_src->format;
    4.85  
    4.86  #define RLEBLIT(bpp, Type, do_blit)                       \
    4.87          do {                                  \
    4.88 @@ -525,7 +525,7 @@
    4.89              break;                            \
    4.90              if(ofs == w) {                        \
    4.91              ofs = 0;                          \
    4.92 -            dstbuf += dst->pitch;                     \
    4.93 +            dstbuf += surf_dst->pitch;                     \
    4.94              if(!--linecount)                      \
    4.95                  break;                        \
    4.96              }                                 \
    4.97 @@ -539,8 +539,8 @@
    4.98  
    4.99    done:
   4.100      /* Unlock the destination if necessary */
   4.101 -    if (SDL_MUSTLOCK(dst)) {
   4.102 -        SDL_UnlockSurface(dst);
   4.103 +    if (SDL_MUSTLOCK(surf_dst)) {
   4.104 +        SDL_UnlockSurface(surf_dst);
   4.105      }
   4.106      return (0);
   4.107  }
   4.108 @@ -620,10 +620,10 @@
   4.109  
   4.110  /* blit a pixel-alpha RLE surface clipped at the right and/or left edges */
   4.111  static void
   4.112 -RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst,
   4.113 +RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * surf_dst,
   4.114                   Uint8 * dstbuf, SDL_Rect * srcrect)
   4.115  {
   4.116 -    SDL_PixelFormat *df = dst->format;
   4.117 +    SDL_PixelFormat *df = surf_dst->format;
   4.118      /*
   4.119       * clipped blitter: Ptype is the destination pixel type,
   4.120       * Ctype the translucent count type, and do_blend the macro
   4.121 @@ -693,7 +693,7 @@
   4.122              ofs += run;                       \
   4.123          }                             \
   4.124          } while(ofs < w);                         \
   4.125 -        dstbuf += dst->pitch;                     \
   4.126 +        dstbuf += surf_dst->pitch;                     \
   4.127      } while(--linecount);                         \
   4.128      } while(0)
   4.129  
   4.130 @@ -712,25 +712,25 @@
   4.131  
   4.132  /* blit a pixel-alpha RLE surface */
   4.133  int
   4.134 -SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
   4.135 -                 SDL_Surface * dst, SDL_Rect * dstrect)
   4.136 +SDL_RLEAlphaBlit(SDL_Surface * surf_src, SDL_Rect * srcrect,
   4.137 +                 SDL_Surface * surf_dst, SDL_Rect * dstrect)
   4.138  {
   4.139      int x, y;
   4.140 -    int w = src->w;
   4.141 +    int w = surf_src->w;
   4.142      Uint8 *srcbuf, *dstbuf;
   4.143 -    SDL_PixelFormat *df = dst->format;
   4.144 +    SDL_PixelFormat *df = surf_dst->format;
   4.145  
   4.146      /* Lock the destination if necessary */
   4.147 -    if (SDL_MUSTLOCK(dst)) {
   4.148 -        if (SDL_LockSurface(dst) < 0) {
   4.149 +    if (SDL_MUSTLOCK(surf_dst)) {
   4.150 +        if (SDL_LockSurface(surf_dst) < 0) {
   4.151              return -1;
   4.152          }
   4.153      }
   4.154  
   4.155      x = dstrect->x;
   4.156      y = dstrect->y;
   4.157 -    dstbuf = (Uint8 *) dst->pixels + y * dst->pitch + x * df->BytesPerPixel;
   4.158 -    srcbuf = (Uint8 *) src->map->data + sizeof(RLEDestFormat);
   4.159 +    dstbuf = (Uint8 *) surf_dst->pixels + y * surf_dst->pitch + x * df->BytesPerPixel;
   4.160 +    srcbuf = (Uint8 *) surf_src->map->data + sizeof(RLEDestFormat);
   4.161  
   4.162      {
   4.163          /* skip lines at the top if necessary */
   4.164 @@ -789,8 +789,8 @@
   4.165      }
   4.166  
   4.167      /* if left or right edge clipping needed, call clip blit */
   4.168 -    if (srcrect->x || srcrect->w != src->w) {
   4.169 -        RLEAlphaClipBlit(w, srcbuf, dst, dstbuf, srcrect);
   4.170 +    if (srcrect->x || srcrect->w != surf_src->w) {
   4.171 +        RLEAlphaClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect);
   4.172      } else {
   4.173  
   4.174          /*
   4.175 @@ -839,7 +839,7 @@
   4.176              ofs += run;                  \
   4.177              }                            \
   4.178          } while(ofs < w);                    \
   4.179 -        dstbuf += dst->pitch;                    \
   4.180 +        dstbuf += surf_dst->pitch;                    \
   4.181          } while(--linecount);                    \
   4.182      } while(0)
   4.183  
   4.184 @@ -859,8 +859,8 @@
   4.185  
   4.186    done:
   4.187      /* Unlock the destination if necessary */
   4.188 -    if (SDL_MUSTLOCK(dst)) {
   4.189 -        SDL_UnlockSurface(dst);
   4.190 +    if (SDL_MUSTLOCK(surf_dst)) {
   4.191 +        SDL_UnlockSurface(surf_dst);
   4.192      }
   4.193      return 0;
   4.194  }
     5.1 --- a/src/video/SDL_blit.h	Wed Jun 25 00:20:21 2014 -0700
     5.2 +++ b/src/video/SDL_blit.h	Wed Jun 25 00:43:10 2014 -0700
     5.3 @@ -402,18 +402,18 @@
     5.4  {                                                                       \
     5.5      switch (bpp) {                                                      \
     5.6          case 1: {                                                       \
     5.7 -            Uint8 Pixel;                                                \
     5.8 +            Uint8 _pixel;                                               \
     5.9                                                                          \
    5.10 -            PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a);                    \
    5.11 -            *((Uint8 *)(buf)) = Pixel;                                  \
    5.12 +            PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a);                   \
    5.13 +            *((Uint8 *)(buf)) = _pixel;                                 \
    5.14          }                                                               \
    5.15          break;                                                          \
    5.16                                                                          \
    5.17          case 2: {                                                       \
    5.18 -            Uint16 Pixel;                                               \
    5.19 +            Uint16 _pixel;                                              \
    5.20                                                                          \
    5.21 -            PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a);                    \
    5.22 -            *((Uint16 *)(buf)) = Pixel;                                 \
    5.23 +            PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a);                   \
    5.24 +            *((Uint16 *)(buf)) = _pixel;                                \
    5.25          }                                                               \
    5.26          break;                                                          \
    5.27                                                                          \
    5.28 @@ -431,10 +431,10 @@
    5.29          break;                                                          \
    5.30                                                                          \
    5.31          case 4: {                                                       \
    5.32 -            Uint32 Pixel;                                               \
    5.33 +            Uint32 _pixel;                                              \
    5.34                                                                          \
    5.35 -            PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a);                    \
    5.36 -            *((Uint32 *)(buf)) = Pixel;                                 \
    5.37 +            PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a);                   \
    5.38 +            *((Uint32 *)(buf)) = _pixel;                                \
    5.39          }                                                               \
    5.40          break;                                                          \
    5.41      }                                                                   \
     6.1 --- a/src/video/SDL_video.c	Wed Jun 25 00:20:21 2014 -0700
     6.2 +++ b/src/video/SDL_video.c	Wed Jun 25 00:43:10 2014 -0700
     6.3 @@ -232,16 +232,13 @@
     6.4  }
     6.5  
     6.6  static int
     6.7 -SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
     6.8 +SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
     6.9  {
    6.10      SDL_WindowTextureData *data;
    6.11 -    SDL_RendererInfo info;
    6.12 -    Uint32 i;
    6.13  
    6.14      data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
    6.15      if (!data) {
    6.16          SDL_Renderer *renderer = NULL;
    6.17 -        SDL_RendererInfo info;
    6.18          int i;
    6.19          const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
    6.20  
    6.21 @@ -249,6 +246,7 @@
    6.22          if (hint && *hint != '0' && *hint != '1' &&
    6.23              SDL_strcasecmp(hint, "software") != 0) {
    6.24              for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
    6.25 +                SDL_RendererInfo info;
    6.26                  SDL_GetRenderDriverInfo(i, &info);
    6.27                  if (SDL_strcasecmp(info.name, hint) == 0) {
    6.28                      renderer = SDL_CreateRenderer(window, i, 0);
    6.29 @@ -259,6 +257,7 @@
    6.30          
    6.31          if (!renderer) {
    6.32              for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
    6.33 +                SDL_RendererInfo info;
    6.34                  SDL_GetRenderDriverInfo(i, &info);
    6.35                  if (SDL_strcmp(info.name, "software") != 0) {
    6.36                      renderer = SDL_CreateRenderer(window, i, 0);
    6.37 @@ -291,17 +290,23 @@
    6.38      SDL_free(data->pixels);
    6.39      data->pixels = NULL;
    6.40  
    6.41 -    if (SDL_GetRendererInfo(data->renderer, &info) < 0) {
    6.42 -        return -1;
    6.43 -    }
    6.44 -
    6.45 -    /* Find the first format without an alpha channel */
    6.46 -    *format = info.texture_formats[0];
    6.47 -    for (i = 0; i < info.num_texture_formats; ++i) {
    6.48 -        if (!SDL_ISPIXELFORMAT_FOURCC(info.texture_formats[i]) &&
    6.49 -            !SDL_ISPIXELFORMAT_ALPHA(info.texture_formats[i])) {
    6.50 -            *format = info.texture_formats[i];
    6.51 -            break;
    6.52 +    {
    6.53 +        SDL_RendererInfo info;
    6.54 +        Uint32 i;
    6.55 +
    6.56 +        if (SDL_GetRendererInfo(data->renderer, &info) < 0) {
    6.57 +            return -1;
    6.58 +        }
    6.59 +
    6.60 +        /* Find the first format without an alpha channel */
    6.61 +        *format = info.texture_formats[0];
    6.62 +
    6.63 +        for (i = 0; i < info.num_texture_formats; ++i) {
    6.64 +            if (!SDL_ISPIXELFORMAT_FOURCC(info.texture_formats[i]) &&
    6.65 +                    !SDL_ISPIXELFORMAT_ALPHA(info.texture_formats[i])) {
    6.66 +                *format = info.texture_formats[i];
    6.67 +                break;
    6.68 +            }
    6.69          }
    6.70      }
    6.71  
    6.72 @@ -330,7 +335,7 @@
    6.73  }
    6.74  
    6.75  static int
    6.76 -SDL_UpdateWindowTexture(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects)
    6.77 +SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, const SDL_Rect * rects, int numrects)
    6.78  {
    6.79      SDL_WindowTextureData *data;
    6.80      SDL_Rect rect;
    6.81 @@ -360,7 +365,7 @@
    6.82  }
    6.83  
    6.84  static void
    6.85 -SDL_DestroyWindowTexture(_THIS, SDL_Window * window)
    6.86 +SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window * window)
    6.87  {
    6.88      SDL_WindowTextureData *data;
    6.89  
     7.1 --- a/src/video/x11/SDL_x11modes.c	Wed Jun 25 00:20:21 2014 -0700
     7.2 +++ b/src/video/x11/SDL_x11modes.c	Wed Jun 25 00:43:10 2014 -0700
     7.3 @@ -674,7 +674,6 @@
     7.4      int screen_w;
     7.5      int screen_h;
     7.6      SDL_DisplayMode mode;
     7.7 -    SDL_DisplayModeData *modedata;
     7.8  
     7.9      /* Unfortunately X11 requires the window to be created with the correct
    7.10       * visual and depth ahead of time, but the SDL API allows you to create
    7.11 @@ -692,6 +691,7 @@
    7.12      if (data->use_xinerama) {
    7.13          if (data->use_vidmode && !data->xinerama_info.x_org && !data->xinerama_info.y_org &&
    7.14             (screen_w > data->xinerama_info.width || screen_h > data->xinerama_info.height)) {
    7.15 +            SDL_DisplayModeData *modedata;
    7.16              /* Add the full (both screens combined) xinerama mode only on the display that starts at 0,0
    7.17               * if we're using vidmode.
    7.18               */
    7.19 @@ -707,6 +707,7 @@
    7.20          }
    7.21          else if (!data->use_xrandr)
    7.22          {
    7.23 +            SDL_DisplayModeData *modedata;
    7.24              /* Add the current mode of each monitor otherwise if we can't get them from xrandr */
    7.25              mode.w = data->xinerama_info.width;
    7.26              mode.h = data->xinerama_info.height;
    7.27 @@ -759,6 +760,7 @@
    7.28      if (data->use_vidmode &&
    7.29          X11_XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) {
    7.30          int i;
    7.31 +        SDL_DisplayModeData *modedata;
    7.32  
    7.33  #ifdef X11MODES_DEBUG
    7.34          printf("VidMode modes: (unsorted)\n");
    7.35 @@ -787,6 +789,7 @@
    7.36  #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
    7.37  
    7.38      if (!data->use_xrandr && !data->use_vidmode) {
    7.39 +        SDL_DisplayModeData *modedata;
    7.40          /* Add the desktop mode */
    7.41          mode = sdl_display->desktop_mode;
    7.42          modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData));
     8.1 --- a/src/video/x11/edid-parse.c	Wed Jun 25 00:20:21 2014 -0700
     8.2 +++ b/src/video/x11/edid-parse.c	Wed Jun 25 00:43:10 2014 -0700
     8.3 @@ -548,7 +548,6 @@
     8.4  void
     8.5  dump_monitor_info (MonitorInfo *info)
     8.6  {
     8.7 -    char *s;
     8.8      int i;
     8.9      
    8.10      printf ("Checksum: %d (%s)\n",
    8.11 @@ -601,6 +600,7 @@
    8.12      }
    8.13      else
    8.14      {
    8.15 +       const char *s;
    8.16  	printf ("Video Signal Level: %f\n", info->analog.video_signal_level);
    8.17  	printf ("Sync Signal Level: %f\n", info->analog.sync_signal_level);
    8.18  	printf ("Total Signal Level: %f\n", info->analog.total_signal_level);