A few minor changes to placate static analysis.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 14 Jun 2019 18:23:51 -0400
changeset 1286263a0d3c13f44
parent 12861 7409d02471b3
child 12863 bddd4ba329cc
A few minor changes to placate static analysis.
src/audio/SDL_wave.c
src/video/cocoa/SDL_cocoamouse.m
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/audio/SDL_wave.c	Fri Jun 14 13:56:52 2019 -0700
     1.2 +++ b/src/audio/SDL_wave.c	Fri Jun 14 18:23:51 2019 -0400
     1.3 @@ -1240,7 +1240,8 @@
     1.4          return SDL_SetError("WAVE file too big");
     1.5      }
     1.6  
     1.7 -    src = (Uint8 *)SDL_realloc(chunk->data, expanded_len);
     1.8 +    /* 1 to avoid allocating zero bytes, to keep static analysis happy. */
     1.9 +    src = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
    1.10      if (src == NULL) {
    1.11          return SDL_OutOfMemory();
    1.12      }
    1.13 @@ -1371,7 +1372,8 @@
    1.14          return SDL_SetError("WAVE file too big");
    1.15      }
    1.16  
    1.17 -    ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len);
    1.18 +    /* 1 to avoid allocating zero bytes, to keep static analysis happy. */
    1.19 +    ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
    1.20      if (ptr == NULL) {
    1.21          return SDL_OutOfMemory();
    1.22      }
     2.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Fri Jun 14 13:56:52 2019 -0700
     2.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Fri Jun 14 18:23:51 2019 -0400
     2.3 @@ -424,7 +424,11 @@
     2.4  Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
     2.5  {
     2.6      SDL_Mouse *mouse = SDL_GetMouse();
     2.7 -    SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
     2.8 +    if (!mouse) {
     2.9 +        return;
    2.10 +    }
    2.11 +
    2.12 +    SDL_MouseID mouseID = mouse->mouseID;
    2.13      if ([event subtype] == NSEventSubtypeTouch) {  /* this is a synthetic from the OS */
    2.14          if (mouse->touch_mouse_events) {
    2.15              mouseID = SDL_TOUCH_MOUSEID;   /* Hint is set */
     3.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Fri Jun 14 13:56:52 2019 -0700
     3.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Jun 14 18:23:51 2019 -0400
     3.3 @@ -894,7 +894,11 @@
     3.4  - (void)mouseDown:(NSEvent *)theEvent
     3.5  {
     3.6      const SDL_Mouse *mouse = SDL_GetMouse();
     3.7 -    SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
     3.8 +    if (!mouse) {
     3.9 +        return;
    3.10 +    }
    3.11 +
    3.12 +    SDL_MouseID mouseID = mouse->mouseID;
    3.13      int button;
    3.14      int clicks;
    3.15  
    3.16 @@ -959,7 +963,11 @@
    3.17  - (void)mouseUp:(NSEvent *)theEvent
    3.18  {
    3.19      const SDL_Mouse *mouse = SDL_GetMouse();
    3.20 -    SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
    3.21 +    if (!mouse) {
    3.22 +        return;
    3.23 +    }
    3.24 +
    3.25 +    SDL_MouseID mouseID = mouse->mouseID;
    3.26      int button;
    3.27      int clicks;
    3.28  
    3.29 @@ -1014,7 +1022,11 @@
    3.30  - (void)mouseMoved:(NSEvent *)theEvent
    3.31  {
    3.32      SDL_Mouse *mouse = SDL_GetMouse();
    3.33 -    SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
    3.34 +    if (!mouse) {
    3.35 +        return;
    3.36 +    }
    3.37 +
    3.38 +    SDL_MouseID mouseID = mouse->mouseID;
    3.39      SDL_Window *window = _data->window;
    3.40      NSPoint point;
    3.41      int x, y;