Skip to content

Commit

Permalink
A few minor changes to placate static analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jun 14, 2019
1 parent 4eb3c0c commit 90e2dc9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/audio/SDL_wave.c
Expand Up @@ -1240,7 +1240,8 @@ LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return SDL_SetError("WAVE file too big");
}

src = (Uint8 *)SDL_realloc(chunk->data, expanded_len);
/* 1 to avoid allocating zero bytes, to keep static analysis happy. */
src = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
if (src == NULL) {
return SDL_OutOfMemory();
}
Expand Down Expand Up @@ -1371,7 +1372,8 @@ PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
return SDL_SetError("WAVE file too big");
}

ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len);
/* 1 to avoid allocating zero bytes, to keep static analysis happy. */
ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
if (ptr == NULL) {
return SDL_OutOfMemory();
}
Expand Down
6 changes: 5 additions & 1 deletion src/video/cocoa/SDL_cocoamouse.m
Expand Up @@ -424,7 +424,11 @@ + (NSCursor *)invisibleCursor
Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
{
SDL_Mouse *mouse = SDL_GetMouse();
SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
if (!mouse) {
return;
}

SDL_MouseID mouseID = mouse->mouseID;
if ([event subtype] == NSEventSubtypeTouch) { /* this is a synthetic from the OS */
if (mouse->touch_mouse_events) {
mouseID = SDL_TOUCH_MOUSEID; /* Hint is set */
Expand Down
18 changes: 15 additions & 3 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -894,7 +894,11 @@ - (BOOL)processHitTest:(NSEvent *)theEvent
- (void)mouseDown:(NSEvent *)theEvent
{
const SDL_Mouse *mouse = SDL_GetMouse();
SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
if (!mouse) {
return;
}

SDL_MouseID mouseID = mouse->mouseID;
int button;
int clicks;

Expand Down Expand Up @@ -959,7 +963,11 @@ - (void)otherMouseDown:(NSEvent *)theEvent
- (void)mouseUp:(NSEvent *)theEvent
{
const SDL_Mouse *mouse = SDL_GetMouse();
SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
if (!mouse) {
return;
}

SDL_MouseID mouseID = mouse->mouseID;
int button;
int clicks;

Expand Down Expand Up @@ -1014,7 +1022,11 @@ - (void)otherMouseUp:(NSEvent *)theEvent
- (void)mouseMoved:(NSEvent *)theEvent
{
SDL_Mouse *mouse = SDL_GetMouse();
SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
if (!mouse) {
return;
}

SDL_MouseID mouseID = mouse->mouseID;
SDL_Window *window = _data->window;
NSPoint point;
int x, y;
Expand Down

0 comments on commit 90e2dc9

Please sign in to comment.