mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-19 03:08:27 +00:00
Fixed some issues found with static analysis
This commit is contained in:
parent
218e45247f
commit
b854e1fe0b
6 changed files with 41 additions and 14 deletions
|
@ -840,7 +840,7 @@ static void SDLTest_PrintWindowFlag(char *text, size_t maxlen, SDL_WindowFlags f
|
||||||
SDL_snprintfcat(text, maxlen, "TRANSPARENT");
|
SDL_snprintfcat(text, maxlen, "TRANSPARENT");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SDL_snprintfcat(text, maxlen, "0x%8.8x", flag);
|
SDL_snprintfcat(text, maxlen, "0x%16.16" SDL_PRIx64, flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,8 @@ static SDL_Mutex *SDL_CreateMutex_cs(void)
|
||||||
#ifdef SDL_PLATFORM_WINRT
|
#ifdef SDL_PLATFORM_WINRT
|
||||||
InitializeCriticalSectionEx(&mutex->cs, 2000, 0);
|
InitializeCriticalSectionEx(&mutex->cs, 2000, 0);
|
||||||
#else
|
#else
|
||||||
InitializeCriticalSectionAndSpinCount(&mutex->cs, 2000);
|
// This function always succeeds
|
||||||
|
(void)InitializeCriticalSectionAndSpinCount(&mutex->cs, 2000);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return (SDL_Mutex *)mutex;
|
return (SDL_Mutex *)mutex;
|
||||||
|
|
|
@ -928,10 +928,16 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
|
||||||
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX1) {
|
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX1) {
|
||||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
case 0:
|
case 0:
|
||||||
|
if (which < SDL_arraysize(bitmap_blit_1b)) {
|
||||||
return bitmap_blit_1b[which];
|
return bitmap_blit_1b[which];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SDL_COPY_COLORKEY:
|
case SDL_COPY_COLORKEY:
|
||||||
|
if (which < SDL_arraysize(colorkey_blit_1b)) {
|
||||||
return colorkey_blit_1b[which];
|
return colorkey_blit_1b[which];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
||||||
return which >= 2 ? Blit1btoNAlpha : (SDL_BlitFunc)NULL;
|
return which >= 2 ? Blit1btoNAlpha : (SDL_BlitFunc)NULL;
|
||||||
|
@ -945,10 +951,16 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
|
||||||
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX2) {
|
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX2) {
|
||||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
case 0:
|
case 0:
|
||||||
|
if (which < SDL_arraysize(bitmap_blit_2b)) {
|
||||||
return bitmap_blit_2b[which];
|
return bitmap_blit_2b[which];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SDL_COPY_COLORKEY:
|
case SDL_COPY_COLORKEY:
|
||||||
|
if (which < SDL_arraysize(colorkey_blit_2b)) {
|
||||||
return colorkey_blit_2b[which];
|
return colorkey_blit_2b[which];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
||||||
return which >= 2 ? Blit2btoNAlpha : (SDL_BlitFunc)NULL;
|
return which >= 2 ? Blit2btoNAlpha : (SDL_BlitFunc)NULL;
|
||||||
|
@ -962,10 +974,16 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
|
||||||
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX4) {
|
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX4) {
|
||||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
case 0:
|
case 0:
|
||||||
|
if (which < SDL_arraysize(bitmap_blit_4b)) {
|
||||||
return bitmap_blit_4b[which];
|
return bitmap_blit_4b[which];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SDL_COPY_COLORKEY:
|
case SDL_COPY_COLORKEY:
|
||||||
|
if (which < SDL_arraysize(colorkey_blit_4b)) {
|
||||||
return colorkey_blit_4b[which];
|
return colorkey_blit_4b[which];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
|
||||||
return which >= 2 ? Blit4btoNAlpha : (SDL_BlitFunc)NULL;
|
return which >= 2 ? Blit4btoNAlpha : (SDL_BlitFunc)NULL;
|
||||||
|
|
|
@ -526,10 +526,16 @@ SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface *surface)
|
||||||
|
|
||||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
case 0:
|
case 0:
|
||||||
|
if (which < SDL_arraysize(one_blit)) {
|
||||||
return one_blit[which];
|
return one_blit[which];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SDL_COPY_COLORKEY:
|
case SDL_COPY_COLORKEY:
|
||||||
|
if (which < SDL_arraysize(one_blitkey)) {
|
||||||
return one_blitkey[which];
|
return one_blitkey[which];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SDL_COPY_COLORKEY | SDL_COPY_BLEND: /* this is not super-robust but handles a specific case we found sdl12-compat. */
|
case SDL_COPY_COLORKEY | SDL_COPY_BLEND: /* this is not super-robust but handles a specific case we found sdl12-compat. */
|
||||||
return (surface->internal->map.info.a == 255) ? one_blitkey[which] :
|
return (surface->internal->map.info.a == 255) ? one_blitkey[which] :
|
||||||
|
|
|
@ -561,10 +561,12 @@ int main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
if (windowstates) {
|
||||||
for (i = 0; i < state->num_windows; ++i) {
|
for (i = 0; i < state->num_windows; ++i) {
|
||||||
SDLTest_TextWindowDestroy(windowstates[i].textwindow);
|
SDLTest_TextWindowDestroy(windowstates[i].textwindow);
|
||||||
}
|
}
|
||||||
SDL_free(windowstates);
|
SDL_free(windowstates);
|
||||||
|
}
|
||||||
SDLTest_CleanupTextDrawing();
|
SDLTest_CleanupTextDrawing();
|
||||||
SDLTest_CommonQuit(state);
|
SDLTest_CommonQuit(state);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -378,7 +378,7 @@ static int stdlib_swprintf(void *arg)
|
||||||
const wchar_t *expected;
|
const wchar_t *expected;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
result = SDL_swprintf(text, sizeof(text), L"%s", "foo");
|
result = SDL_swprintf(text, SDL_arraysize(text), L"%s", "foo");
|
||||||
expected = L"foo";
|
expected = L"foo";
|
||||||
SDLTest_AssertPass("Call to SDL_swprintf(\"%%s\", \"foo\")");
|
SDLTest_AssertPass("Call to SDL_swprintf(\"%%s\", \"foo\")");
|
||||||
SDLTest_AssertCheck(SDL_wcscmp(text, expected) == 0, "Check text, expected: %S, got: %S", expected, text);
|
SDLTest_AssertCheck(SDL_wcscmp(text, expected) == 0, "Check text, expected: %S, got: %S", expected, text);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue