Fix some clang analyzer warnings.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Tue, 23 Jul 2013 17:40:13 -0700
changeset 75081f64c6874619
parent 7507 885b4aab4190
child 7509 cf7c2e3493b2
Fix some clang analyzer warnings.

This fixes some analyzer warnings and a couple of minor memory leaks.
src/events/SDL_gesture.c
src/render/SDL_render.c
src/video/SDL_surface.c
src/video/SDL_video.c
src/video/cocoa/SDL_cocoaevents.m
src/video/cocoa/SDL_cocoashape.m
     1.1 --- a/src/events/SDL_gesture.c	Tue Jul 23 17:38:59 2013 -0700
     1.2 +++ b/src/events/SDL_gesture.c	Tue Jul 23 17:40:13 2013 -0700
     1.3 @@ -392,7 +392,7 @@
     1.4  static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_GestureTouch* touch)
     1.5  {
     1.6  
     1.7 -    SDL_FloatPoint points[DOLLARNPOINTS];
     1.8 +    SDL_FloatPoint points[DOLLARNPOINTS] = {};
     1.9      int i;
    1.10      float bestDiff = 10000;
    1.11  
     2.1 --- a/src/render/SDL_render.c	Tue Jul 23 17:38:59 2013 -0700
     2.2 +++ b/src/render/SDL_render.c	Tue Jul 23 17:40:13 2013 -0700
     2.3 @@ -1467,7 +1467,7 @@
     2.4  int
     2.5  SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect)
     2.6  {
     2.7 -    SDL_Rect full_rect;
     2.8 +    SDL_Rect full_rect = {};
     2.9  
    2.10      CHECK_RENDERER_MAGIC(renderer, -1);
    2.11  
     3.1 --- a/src/video/SDL_surface.c	Tue Jul 23 17:38:59 2013 -0700
     3.2 +++ b/src/video/SDL_surface.c	Tue Jul 23 17:40:13 2013 -0700
     3.3 @@ -619,6 +619,8 @@
     3.4      /* If the destination rectangle is NULL, use the entire dest surface */
     3.5      if (dstrect == NULL) {
     3.6          fulldst.x = fulldst.y = 0;
     3.7 +        fulldst.w = dst->w;
     3.8 +        fulldst.h = dst->h;
     3.9          dstrect = &fulldst;
    3.10      }
    3.11  
     4.1 --- a/src/video/SDL_video.c	Tue Jul 23 17:38:59 2013 -0700
     4.2 +++ b/src/video/SDL_video.c	Tue Jul 23 17:40:13 2013 -0700
     4.3 @@ -3062,8 +3062,11 @@
     4.4      }
     4.5  
     4.6      SDL_VERSION(&info.version);
     4.7 -    SDL_GetWindowWMInfo(window, &info);
     4.8 -    return (info.subsystem == drivertype);
     4.9 +    if (!SDL_GetWindowWMInfo(window, &info)) {
    4.10 +        return SDL_TRUE;
    4.11 +    } else {
    4.12 +        return (info.subsystem == drivertype);
    4.13 +    }
    4.14  }
    4.15  
    4.16  int
     5.1 --- a/src/video/cocoa/SDL_cocoaevents.m	Tue Jul 23 17:38:59 2013 -0700
     5.2 +++ b/src/video/cocoa/SDL_cocoaevents.m	Tue Jul 23 17:40:13 2013 -0700
     5.3 @@ -138,6 +138,10 @@
     5.4      NSMenu *windowMenu;
     5.5      NSMenuItem *menuItem;
     5.6  
     5.7 +    if (!NSApp) {
     5.8 +        return;
     5.9 +    }
    5.10 +    
    5.11      /* Create the main menu bar */
    5.12      [NSApp setMainMenu:[[NSMenu alloc] init]];
    5.13  
    5.14 @@ -228,7 +232,7 @@
    5.15          }
    5.16          [NSApp finishLaunching];
    5.17      }
    5.18 -    if ([NSApp delegate] == nil) {
    5.19 +    if (NSApp && ![NSApp delegate]) {
    5.20          [NSApp setDelegate:[[SDLAppDelegate alloc] init]];
    5.21      }
    5.22      [pool release];
     6.1 --- a/src/video/cocoa/SDL_cocoashape.m	Tue Jul 23 17:38:59 2013 -0700
     6.2 +++ b/src/video/cocoa/SDL_cocoashape.m	Tue Jul 23 17:40:13 2013 -0700
     6.3 @@ -96,6 +96,7 @@
     6.4      closure.window = shaper->window;
     6.5      SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
     6.6      [closure.path addClip];
     6.7 +    [pool release];
     6.8  
     6.9      return 0;
    6.10  }