mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-17 17:08:22 +00:00
committed by
Sam Lantinga
parent
e29c0661cc
commit
d0bbfdbfb8
@@ -161,7 +161,7 @@ PrintText(const char *eventtype, const char *text)
|
||||
expanded[0] = '\0';
|
||||
for (spot = text; *spot; ++spot) {
|
||||
size_t length = SDL_strlen(expanded);
|
||||
SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot);
|
||||
(void)SDL_snprintf(expanded + length, sizeof expanded - length, "\\x%.2x", (unsigned char)*spot);
|
||||
}
|
||||
SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,6 @@ PrintKey(SDL_Keysym *sym, SDL_bool pressed, SDL_bool repeat)
|
||||
print_string(&spot, &left, " (repeat)");
|
||||
}
|
||||
SDL_Log("%s\n", message);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -158,7 +157,7 @@ PrintText(const char *eventtype, const char *text)
|
||||
expanded[0] = '\0';
|
||||
for (spot = text; *spot; ++spot) {
|
||||
size_t length = SDL_strlen(expanded);
|
||||
SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot);
|
||||
(void)SDL_snprintf(expanded + length, sizeof expanded - length, "\\x%.2x", (unsigned char)*spot);
|
||||
}
|
||||
SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text);
|
||||
}
|
||||
@@ -169,12 +168,11 @@ void loop()
|
||||
/* Check for events */
|
||||
/*SDL_WaitEvent(&event); emscripten does not like waiting*/
|
||||
|
||||
fprintf(stderr, "starting loop\n");
|
||||
fflush(stderr);
|
||||
(void)fprintf(stderr, "starting loop\n");
|
||||
(void)fflush(stderr);
|
||||
// while (SDL_PollEvent(&event)) {
|
||||
while (!done && SDL_WaitEvent(&event)) {
|
||||
fprintf(stderr, "got event type: %" SDL_PRIu32 "\n", event.type);
|
||||
fflush(stderr);
|
||||
SDL_Log("Got event type: %" SDL_PRIu32 "\n", event.type);
|
||||
switch (event.type) {
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
@@ -188,8 +186,8 @@ void loop()
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
/* Left button quits the app, other buttons toggles text input */
|
||||
fprintf(stderr, "mouse button down button: %d (LEFT=%d)\n", event.button.button, SDL_BUTTON_LEFT);
|
||||
fflush(stderr);
|
||||
(void)fprintf(stderr, "mouse button down button: %d (LEFT=%d)\n", event.button.button, SDL_BUTTON_LEFT);
|
||||
(void)fflush(stderr);
|
||||
if (event.button.button == SDL_BUTTON_LEFT) {
|
||||
done = 1;
|
||||
} else {
|
||||
@@ -208,11 +206,11 @@ void loop()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "waiting new event\n");
|
||||
fflush(stderr);
|
||||
(void)fprintf(stderr, "waiting new event\n");
|
||||
(void)fflush(stderr);
|
||||
}
|
||||
fprintf(stderr, "exiting event loop\n");
|
||||
fflush(stderr);
|
||||
(void)fprintf(stderr, "exiting event loop\n");
|
||||
(void)fflush(stderr);
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (done) {
|
||||
emscripten_cancel_main_loop();
|
||||
@@ -227,8 +225,8 @@ static int SDLCALL ping_thread(void *ptr)
|
||||
SDL_Event sdlevent;
|
||||
SDL_memset(&sdlevent, 0, sizeof(SDL_Event));
|
||||
for (cnt = 0; cnt < 10; ++cnt) {
|
||||
fprintf(stderr, "sending event (%d/%d) from thread.\n", cnt + 1, 10);
|
||||
fflush(stderr);
|
||||
(void)fprintf(stderr, "sending event (%d/%d) from thread.\n", cnt + 1, 10);
|
||||
(void)fflush(stderr);
|
||||
sdlevent.type = SDL_KEYDOWN;
|
||||
sdlevent.key.keysym.sym = SDLK_1;
|
||||
SDL_PushEvent(&sdlevent);
|
||||
@@ -282,7 +280,7 @@ int main(int argc, char *argv[])
|
||||
/* Watch keystrokes */
|
||||
done = 0;
|
||||
|
||||
thread = SDL_CreateThread(ping_thread, "PingThread", (void *)NULL);
|
||||
thread = SDL_CreateThread(ping_thread, "PingThread", NULL);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(loop, 0, 1);
|
||||
|
||||
@@ -393,7 +393,6 @@ WatchJoystick(SDL_Joystick *joystick)
|
||||
|
||||
/* Skip any spurious events at start */
|
||||
while (SDL_PollEvent(&event) > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Loop, getting joystick events! */
|
||||
@@ -594,7 +593,7 @@ WatchJoystick(SDL_Joystick *joystick)
|
||||
char crc_string[5];
|
||||
|
||||
SDL_strlcat(mapping, "crc:", SDL_arraysize(mapping));
|
||||
SDL_snprintf(crc_string, sizeof(crc_string), "%.4x", crc);
|
||||
(void)SDL_snprintf(crc_string, sizeof crc_string, "%.4x", crc);
|
||||
SDL_strlcat(mapping, crc_string, SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
}
|
||||
@@ -667,17 +666,17 @@ WatchJoystick(SDL_Joystick *joystick)
|
||||
pszElement[0] = '\0';
|
||||
switch (pBinding->bindType) {
|
||||
case SDL_CONTROLLER_BINDTYPE_BUTTON:
|
||||
SDL_snprintf(pszElement, sizeof(pszElement), "b%d", pBinding->value.button);
|
||||
(void)SDL_snprintf(pszElement, sizeof pszElement, "b%d", pBinding->value.button);
|
||||
break;
|
||||
case SDL_CONTROLLER_BINDTYPE_AXIS:
|
||||
if (pBinding->value.axis.axis_min == 0 && pBinding->value.axis.axis_max == SDL_JOYSTICK_AXIS_MIN) {
|
||||
/* The negative half axis */
|
||||
SDL_snprintf(pszElement, sizeof(pszElement), "-a%d", pBinding->value.axis.axis);
|
||||
(void)SDL_snprintf(pszElement, sizeof pszElement, "-a%d", pBinding->value.axis.axis);
|
||||
} else if (pBinding->value.axis.axis_min == 0 && pBinding->value.axis.axis_max == SDL_JOYSTICK_AXIS_MAX) {
|
||||
/* The positive half axis */
|
||||
SDL_snprintf(pszElement, sizeof(pszElement), "+a%d", pBinding->value.axis.axis);
|
||||
(void)SDL_snprintf(pszElement, sizeof pszElement, "+a%d", pBinding->value.axis.axis);
|
||||
} else {
|
||||
SDL_snprintf(pszElement, sizeof(pszElement), "a%d", pBinding->value.axis.axis);
|
||||
(void)SDL_snprintf(pszElement, sizeof pszElement, "a%d", pBinding->value.axis.axis);
|
||||
if (pBinding->value.axis.axis_min > pBinding->value.axis.axis_max) {
|
||||
/* Invert the axis */
|
||||
SDL_strlcat(pszElement, "~", SDL_arraysize(pszElement));
|
||||
@@ -685,7 +684,7 @@ WatchJoystick(SDL_Joystick *joystick)
|
||||
}
|
||||
break;
|
||||
case SDL_CONTROLLER_BINDTYPE_HAT:
|
||||
SDL_snprintf(pszElement, sizeof(pszElement), "h%d.%d", pBinding->value.hat.hat, pBinding->value.hat.hat_mask);
|
||||
(void)SDL_snprintf(pszElement, sizeof pszElement, "h%d.%d", pBinding->value.hat.hat, pBinding->value.hat.hat_mask);
|
||||
break;
|
||||
default:
|
||||
SDL_assert(!"Unknown bind type");
|
||||
|
||||
@@ -100,13 +100,13 @@ int main(int argc, char *argv[])
|
||||
#if HAVE_SIGNAL_H
|
||||
/* Set the signals */
|
||||
#ifdef SIGHUP
|
||||
signal(SIGHUP, poked);
|
||||
(void)signal(SIGHUP, poked);
|
||||
#endif
|
||||
signal(SIGINT, poked);
|
||||
(void)signal(SIGINT, poked);
|
||||
#ifdef SIGQUIT
|
||||
signal(SIGQUIT, poked);
|
||||
(void)signal(SIGQUIT, poked);
|
||||
#endif
|
||||
signal(SIGTERM, poked);
|
||||
(void)signal(SIGTERM, poked);
|
||||
#endif /* HAVE_SIGNAL_H */
|
||||
|
||||
/* Initialize fillerup() variables */
|
||||
|
||||
@@ -617,7 +617,7 @@ static void RunFIFOTest(SDL_bool lock_free)
|
||||
SDL_zeroa(readerData);
|
||||
for (i = 0; i < NUM_READERS; ++i) {
|
||||
char name[64];
|
||||
SDL_snprintf(name, sizeof(name), "FIFOReader%d", i);
|
||||
(void)SDL_snprintf(name, sizeof name, "FIFOReader%d", i);
|
||||
readerData[i].queue = &queue;
|
||||
readerData[i].lock_free = lock_free;
|
||||
readerData[i].thread = SDL_CreateThread(FIFO_Reader, name, &readerData[i]);
|
||||
@@ -628,7 +628,7 @@ static void RunFIFOTest(SDL_bool lock_free)
|
||||
SDL_zeroa(writerData);
|
||||
for (i = 0; i < NUM_WRITERS; ++i) {
|
||||
char name[64];
|
||||
SDL_snprintf(name, sizeof(name), "FIFOWriter%d", i);
|
||||
(void)SDL_snprintf(name, sizeof name, "FIFOWriter%d", i);
|
||||
writerData[i].queue = &queue;
|
||||
writerData[i].index = i;
|
||||
writerData[i].lock_free = lock_free;
|
||||
@@ -677,17 +677,17 @@ static void RunFIFOTest(SDL_bool lock_free)
|
||||
}
|
||||
grand_total += total;
|
||||
SDL_Log("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits);
|
||||
SDL_snprintf(textBuffer, sizeof(textBuffer), " { ");
|
||||
(void)SDL_snprintf(textBuffer, sizeof textBuffer, " { ");
|
||||
for (j = 0; j < NUM_WRITERS; ++j) {
|
||||
if (j > 0) {
|
||||
len = SDL_strlen(textBuffer);
|
||||
SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, ", ");
|
||||
(void)SDL_snprintf(textBuffer + len, sizeof textBuffer - len, ", ");
|
||||
}
|
||||
len = SDL_strlen(textBuffer);
|
||||
SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, "%d", readerData[i].counters[j]);
|
||||
(void)SDL_snprintf(textBuffer + len, sizeof textBuffer - len, "%d", readerData[i].counters[j]);
|
||||
}
|
||||
len = SDL_strlen(textBuffer);
|
||||
SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n");
|
||||
(void)SDL_snprintf(textBuffer + len, sizeof textBuffer - len, " }\n");
|
||||
SDL_Log("%s", textBuffer);
|
||||
}
|
||||
SDL_Log("Readers read %d total events\n", grand_total);
|
||||
|
||||
@@ -96,9 +96,9 @@ iteration()
|
||||
int index = e.adevice.which;
|
||||
int iscapture = e.adevice.iscapture;
|
||||
const char *name = SDL_GetAudioDeviceName(index, iscapture);
|
||||
if (name != NULL)
|
||||
if (name != NULL) {
|
||||
SDL_Log("New %s audio device at index %u: %s\n", devtypestr(iscapture), (unsigned int)index, name);
|
||||
else {
|
||||
} else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Got new %s device at index %u, but failed to get the name: %s\n",
|
||||
devtypestr(iscapture), (unsigned int)index, SDL_GetError());
|
||||
continue;
|
||||
@@ -166,13 +166,13 @@ int main(int argc, char *argv[])
|
||||
#if HAVE_SIGNAL_H
|
||||
/* Set the signals */
|
||||
#ifdef SIGHUP
|
||||
signal(SIGHUP, poked);
|
||||
(void)signal(SIGHUP, poked);
|
||||
#endif
|
||||
signal(SIGINT, poked);
|
||||
(void)signal(SIGINT, poked);
|
||||
#ifdef SIGQUIT
|
||||
signal(SIGQUIT, poked);
|
||||
(void)signal(SIGQUIT, poked);
|
||||
#endif
|
||||
signal(SIGTERM, poked);
|
||||
(void)signal(SIGTERM, poked);
|
||||
#endif /* HAVE_SIGNAL_H */
|
||||
|
||||
/* Show the list of available drivers */
|
||||
|
||||
@@ -21,18 +21,19 @@ print_devices(int iscapture)
|
||||
|
||||
SDL_Log("Found %d %s device%s:\n", n, typestr, n != 1 ? "s" : "");
|
||||
|
||||
if (n == -1)
|
||||
if (n == -1) {
|
||||
SDL_Log(" Driver can't detect specific %s devices.\n\n", typestr);
|
||||
else if (n == 0)
|
||||
} else if (n == 0) {
|
||||
SDL_Log(" No %s devices found.\n\n", typestr);
|
||||
else {
|
||||
} else {
|
||||
int i;
|
||||
for (i = 0; i < n; i++) {
|
||||
const char *name = SDL_GetAudioDeviceName(i, iscapture);
|
||||
if (name != NULL)
|
||||
if (name != NULL) {
|
||||
SDL_Log(" %d: %s\n", i, name);
|
||||
else
|
||||
} else {
|
||||
SDL_Log(" %d Error: %s\n", i, SDL_GetError());
|
||||
}
|
||||
|
||||
if (SDL_GetAudioDeviceSpec(i, iscapture, &spec) == 0) {
|
||||
SDL_Log(" Sample Rate: %d\n", spec.freq);
|
||||
|
||||
@@ -62,7 +62,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
} else if (SDL_strcasecmp(argv[i], "--execKey") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
SDL_sscanf(argv[i + 1], "%" SDL_PRIu64, &userExecKey);
|
||||
(void)SDL_sscanf(argv[i + 1], "%" SDL_PRIu64, &userExecKey);
|
||||
consumed = 2;
|
||||
}
|
||||
} else if (SDL_strcasecmp(argv[i], "--seed") == 0) {
|
||||
|
||||
@@ -32,7 +32,7 @@ void _audioSetUp(void *arg)
|
||||
void _audioTearDown(void *arg)
|
||||
{
|
||||
/* Remove a possibly created file from SDL disk writer audio driver; ignore errors */
|
||||
remove("sdlaudio.raw");
|
||||
(void)remove("sdlaudio.raw");
|
||||
|
||||
SDLTest_AssertPass("Cleanup of test files completed");
|
||||
}
|
||||
@@ -94,8 +94,8 @@ int audio_initQuitAudio()
|
||||
for (i = 0; i < iMax; i++) {
|
||||
audioDriver = SDL_GetAudioDriver(i);
|
||||
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
|
||||
SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
|
||||
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
|
||||
SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
|
||||
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
|
||||
|
||||
/* Call Init */
|
||||
result = SDL_AudioInit(audioDriver);
|
||||
@@ -151,8 +151,8 @@ int audio_initOpenCloseQuitAudio()
|
||||
for (i = 0; i < iMax; i++) {
|
||||
audioDriver = SDL_GetAudioDriver(i);
|
||||
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
|
||||
SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
|
||||
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
|
||||
SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
|
||||
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
|
||||
|
||||
/* Change specs */
|
||||
for (j = 0; j < 2; j++) {
|
||||
@@ -240,8 +240,8 @@ int audio_pauseUnpauseAudio()
|
||||
for (i = 0; i < iMax; i++) {
|
||||
audioDriver = SDL_GetAudioDriver(i);
|
||||
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
|
||||
SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
|
||||
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
|
||||
SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
|
||||
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
|
||||
|
||||
/* Change specs */
|
||||
for (j = 0; j < 2; j++) {
|
||||
|
||||
@@ -169,11 +169,11 @@ int clipboard_testClipboardTextFunctions(void *arg)
|
||||
/* Empty clipboard */
|
||||
charResult = SDL_GetClipboardText();
|
||||
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
|
||||
SDLTest_AssertCheck(
|
||||
SDLTest_Assert(
|
||||
charResult != NULL,
|
||||
"Verify SDL_GetClipboardText did not return NULL");
|
||||
SDLTest_AssertCheck(
|
||||
charResult[0] == '\0',
|
||||
charResult[0] == '\0', /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
|
||||
"Verify SDL_GetClipboardText returned string with length 0, got length %i",
|
||||
(int)SDL_strlen(charResult));
|
||||
intResult = SDL_SetClipboardText((const char *)text);
|
||||
@@ -247,11 +247,11 @@ int clipboard_testPrimarySelectionTextFunctions(void *arg)
|
||||
/* Empty primary selection */
|
||||
charResult = SDL_GetPrimarySelectionText();
|
||||
SDLTest_AssertPass("Call to SDL_GetPrimarySelectionText succeeded");
|
||||
SDLTest_AssertCheck(
|
||||
SDLTest_Assert(
|
||||
charResult != NULL,
|
||||
"Verify SDL_GetPrimarySelectionText did not return NULL");
|
||||
SDLTest_AssertCheck(
|
||||
charResult[0] == '\0',
|
||||
charResult[0] == '\0', /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
|
||||
"Verify SDL_GetPrimarySelectionText returned string with length 0, got length %i",
|
||||
(int)SDL_strlen(charResult));
|
||||
intResult = SDL_SetPrimarySelectionText((const char *)text);
|
||||
|
||||
@@ -616,14 +616,14 @@ int keyboard_getScancodeFromNameNegative(void *arg)
|
||||
|
||||
/* Zero length string input */
|
||||
name = "";
|
||||
scancode = SDL_GetScancodeFromName((const char *)name);
|
||||
scancode = SDL_GetScancodeFromName(name);
|
||||
SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
|
||||
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
|
||||
_checkInvalidNameError();
|
||||
|
||||
/* NULL input */
|
||||
name = NULL;
|
||||
scancode = SDL_GetScancodeFromName((const char *)name);
|
||||
scancode = SDL_GetScancodeFromName(name);
|
||||
SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)");
|
||||
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
|
||||
_checkInvalidNameError();
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
/* Range tests parameters */
|
||||
#define RANGE_TEST_ITERATIONS 10000000
|
||||
#define RANGE_TEST_STEP SDL_MAX_UINT32 / RANGE_TEST_ITERATIONS
|
||||
#define RANGE_TEST_STEP ((Uint32)(SDL_MAX_UINT32 / RANGE_TEST_ITERATIONS))
|
||||
|
||||
/* Margin of error for imprecise tests */
|
||||
#define EPSILON 1.0E-10
|
||||
|
||||
@@ -34,16 +34,16 @@ int platform_testTypes(void *arg)
|
||||
int ret;
|
||||
|
||||
ret = _compareSizeOfType(sizeof(Uint8), 1);
|
||||
SDLTest_AssertCheck(ret == 0, "sizeof(Uint8) = %lu, expected 1", (unsigned long)sizeof(Uint8));
|
||||
SDLTest_AssertCheck(ret == 0, "sizeof(Uint8) = %u, expected 1", (unsigned int)sizeof(Uint8));
|
||||
|
||||
ret = _compareSizeOfType(sizeof(Uint16), 2);
|
||||
SDLTest_AssertCheck(ret == 0, "sizeof(Uint16) = %lu, expected 2", (unsigned long)sizeof(Uint16));
|
||||
SDLTest_AssertCheck(ret == 0, "sizeof(Uint16) = %u, expected 2", (unsigned int)sizeof(Uint16));
|
||||
|
||||
ret = _compareSizeOfType(sizeof(Uint32), 4);
|
||||
SDLTest_AssertCheck(ret == 0, "sizeof(Uint32) = %lu, expected 4", (unsigned long)sizeof(Uint32));
|
||||
SDLTest_AssertCheck(ret == 0, "sizeof(Uint32) = %u, expected 4", (unsigned int)sizeof(Uint32));
|
||||
|
||||
ret = _compareSizeOfType(sizeof(Uint64), 8);
|
||||
SDLTest_AssertCheck(ret == 0, "sizeof(Uint64) = %lu, expected 8", (unsigned long)sizeof(Uint64));
|
||||
SDLTest_AssertCheck(ret == 0, "sizeof(Uint64) = %u, expected 8", (unsigned int)sizeof(Uint64));
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ int rect_testIntersectRectEmpty(void *arg)
|
||||
rectB = refRectB;
|
||||
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
|
||||
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
|
||||
empty = (SDL_bool)SDL_RectEmpty(&result);
|
||||
empty = SDL_RectEmpty(&result);
|
||||
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
|
||||
|
||||
/* Rect B empty */
|
||||
@@ -668,7 +668,7 @@ int rect_testIntersectRectEmpty(void *arg)
|
||||
rectB = refRectB;
|
||||
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
|
||||
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
|
||||
empty = (SDL_bool)SDL_RectEmpty(&result);
|
||||
empty = SDL_RectEmpty(&result);
|
||||
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
|
||||
|
||||
/* Rect A and B empty */
|
||||
@@ -687,7 +687,7 @@ int rect_testIntersectRectEmpty(void *arg)
|
||||
rectB = refRectB;
|
||||
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
|
||||
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
|
||||
empty = (SDL_bool)SDL_RectEmpty(&result);
|
||||
empty = SDL_RectEmpty(&result);
|
||||
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
@@ -1533,7 +1533,7 @@ int rect_testRectEmpty(void *arg)
|
||||
refRect.h = SDLTest_RandomIntegerInRange(256, 1024);
|
||||
expectedResult = SDL_FALSE;
|
||||
rect = refRect;
|
||||
result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect);
|
||||
result = SDL_RectEmpty(&rect);
|
||||
_validateRectEmptyResults(result, expectedResult, &rect, &refRect);
|
||||
|
||||
/* Empty case */
|
||||
@@ -1546,7 +1546,7 @@ int rect_testRectEmpty(void *arg)
|
||||
refRect.h = h;
|
||||
expectedResult = SDL_TRUE;
|
||||
rect = refRect;
|
||||
result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect);
|
||||
result = SDL_RectEmpty(&rect);
|
||||
_validateRectEmptyResults(result, expectedResult, &rect, &refRect);
|
||||
}
|
||||
}
|
||||
@@ -1566,7 +1566,7 @@ int rect_testRectEmptyParam(void *arg)
|
||||
SDL_bool result;
|
||||
|
||||
/* invalid parameter combinations */
|
||||
result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)NULL);
|
||||
result = SDL_RectEmpty(NULL);
|
||||
SDLTest_AssertCheck(result == SDL_TRUE, "Check that function returns TRUE when 1st parameter is NULL");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
@@ -1596,7 +1596,7 @@ int rect_testRectEquals(void *arg)
|
||||
expectedResult = SDL_TRUE;
|
||||
rectA = refRectA;
|
||||
rectB = refRectB;
|
||||
result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)&rectB);
|
||||
result = SDL_RectEquals(&rectA, &rectB);
|
||||
_validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
@@ -1625,11 +1625,11 @@ int rect_testRectEqualsParam(void *arg)
|
||||
rectB.h = SDLTest_RandomIntegerInRange(1, 1024);
|
||||
|
||||
/* invalid parameter combinations */
|
||||
result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)&rectB);
|
||||
result = SDL_RectEquals(NULL, &rectB);
|
||||
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
|
||||
result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)NULL);
|
||||
result = SDL_RectEquals(&rectA, NULL);
|
||||
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
|
||||
result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)NULL);
|
||||
result = SDL_RectEquals(NULL, NULL);
|
||||
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
@@ -1659,7 +1659,7 @@ int rect_testFRectEquals(void *arg)
|
||||
expectedResult = SDL_TRUE;
|
||||
rectA = refRectA;
|
||||
rectB = refRectB;
|
||||
result = (SDL_bool)SDL_FRectEquals((const SDL_FRect *)&rectA, (const SDL_FRect *)&rectB);
|
||||
result = SDL_FRectEquals(&rectA, &rectB);
|
||||
_validateFRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
@@ -1688,11 +1688,11 @@ int rect_testFRectEqualsParam(void *arg)
|
||||
rectB.h = SDLTest_RandomFloat();
|
||||
|
||||
/* invalid parameter combinations */
|
||||
result = (SDL_bool)SDL_FRectEquals((const SDL_FRect *)NULL, (const SDL_FRect *)&rectB);
|
||||
result = SDL_FRectEquals(NULL, &rectB);
|
||||
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL");
|
||||
result = (SDL_bool)SDL_FRectEquals((const SDL_FRect *)&rectA, (const SDL_FRect *)NULL);
|
||||
result = SDL_FRectEquals(&rectA, NULL);
|
||||
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL");
|
||||
result = (SDL_bool)SDL_FRectEquals((const SDL_FRect *)NULL, (const SDL_FRect *)NULL);
|
||||
result = SDL_FRectEquals(NULL, NULL);
|
||||
SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
|
||||
@@ -39,9 +39,9 @@ void RWopsSetUp(void *arg)
|
||||
int result;
|
||||
|
||||
/* Clean up from previous runs (if any); ignore errors */
|
||||
remove(RWopsReadTestFilename);
|
||||
remove(RWopsWriteTestFilename);
|
||||
remove(RWopsAlphabetFilename);
|
||||
(void)remove(RWopsReadTestFilename);
|
||||
(void)remove(RWopsWriteTestFilename);
|
||||
(void)remove(RWopsAlphabetFilename);
|
||||
|
||||
/* Create a test file */
|
||||
handle = fopen(RWopsReadTestFilename, "w");
|
||||
@@ -81,7 +81,7 @@ void RWopsTearDown(void *arg)
|
||||
/* Remove the created files to clean up; ignore errors for write filename */
|
||||
result = remove(RWopsReadTestFilename);
|
||||
SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsReadTestFilename, result);
|
||||
remove(RWopsWriteTestFilename);
|
||||
(void)remove(RWopsWriteTestFilename);
|
||||
result = remove(RWopsAlphabetFilename);
|
||||
SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsAlphabetFilename, result);
|
||||
|
||||
@@ -198,7 +198,7 @@ int rwops_testParamNegative(void)
|
||||
SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", NULL) succeeded");
|
||||
SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", NULL) returns NULL");
|
||||
|
||||
rwops = SDL_RWFromMem((void *)NULL, 10);
|
||||
rwops = SDL_RWFromMem(NULL, 10);
|
||||
SDLTest_AssertPass("Call to SDL_RWFromMem(NULL, 10) succeeded");
|
||||
SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromMem(NULL, 10) returns NULL");
|
||||
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
|
||||
/* Test case functions */
|
||||
|
||||
/* Forward declarations for internal harness functions */
|
||||
extern char *SDLTest_GenerateRunSeed(const int length);
|
||||
|
||||
/**
|
||||
* @brief Calls to SDLTest_GenerateRunSeed()
|
||||
*/
|
||||
@@ -37,7 +34,7 @@ int sdltest_generateRunSeed(void *arg)
|
||||
int j;
|
||||
|
||||
for (i = 1; i <= 10; i += 3) {
|
||||
result = SDLTest_GenerateRunSeed((const int)i);
|
||||
result = SDLTest_GenerateRunSeed((int)i);
|
||||
SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()");
|
||||
SDLTest_AssertCheck(result != NULL, "Verify returned value is not NULL");
|
||||
if (result != NULL) {
|
||||
@@ -49,7 +46,7 @@ int sdltest_generateRunSeed(void *arg)
|
||||
|
||||
/* Negative cases */
|
||||
for (j = -2; j <= 0; j++) {
|
||||
result = SDLTest_GenerateRunSeed((const int)j);
|
||||
result = SDLTest_GenerateRunSeed(j);
|
||||
SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()");
|
||||
SDLTest_AssertCheck(result == NULL, "Verify returned value is not NULL");
|
||||
}
|
||||
@@ -136,7 +133,7 @@ int sdltest_randomNumber(void *arg)
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomFloat");
|
||||
SDLTest_AssertCheck(dresult >= (double)(-FLT_MAX) && dresult <= (double)FLT_MAX, "Verify result value, expected: [%e,%e], got: %e", (double)(-FLT_MAX), (double)FLT_MAX, dresult);
|
||||
|
||||
dresult = (double)SDLTest_RandomUnitDouble();
|
||||
dresult = SDLTest_RandomUnitDouble();
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUnitDouble");
|
||||
SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult);
|
||||
|
||||
@@ -487,63 +484,63 @@ int sdltest_randomBoundaryNumberUint64(void *arg)
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 10, SDL_TRUE);
|
||||
uresult = SDLTest_RandomUint64BoundaryValue(10, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10,
|
||||
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %" SDL_PRIs64, uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE);
|
||||
uresult = SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11,
|
||||
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %" SDL_PRIs64, uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE);
|
||||
uresult = SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 12,
|
||||
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %" SDL_PRIs64, uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE);
|
||||
uresult = SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13,
|
||||
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %" SDL_PRIs64, uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE);
|
||||
uresult = SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
|
||||
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE);
|
||||
uresult = SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20,
|
||||
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE);
|
||||
uresult = SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0 || uresult == 21,
|
||||
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %" SDL_PRIs64, uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE);
|
||||
uresult = SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 100,
|
||||
"Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %" SDL_PRIs64, uresult);
|
||||
|
||||
/* RandomUintXBoundaryValue(1, 0xffffffffffffffff, SDL_FALSE) returns 0 (no error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
|
||||
uresult = SDLTest_RandomUint64BoundaryValue(1, 0xffffffffffffffffULL, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0,
|
||||
@@ -553,17 +550,17 @@ int sdltest_randomBoundaryNumberUint64(void *arg)
|
||||
SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 0xfffffffffffffffe, SDL_FALSE) returns 0xffffffffffffffff (no error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xfffffffffffffffeULL, SDL_FALSE);
|
||||
uresult = SDLTest_RandomUint64BoundaryValue(0, 0xfffffffffffffffeULL, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == (Uint64)0xffffffffffffffffULL,
|
||||
uresult == 0xffffffffffffffffULL,
|
||||
"Validate result value for parameters (0,0xfffffffffffffffe,SDL_FALSE); expected: 0xffffffffffffffff, got: %" SDL_PRIs64, uresult);
|
||||
lastError = (char *)SDL_GetError();
|
||||
SDLTest_AssertPass("SDL_GetError()");
|
||||
SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
|
||||
|
||||
/* RandomUintXBoundaryValue(0, 0xffffffffffffffff, SDL_FALSE) returns 0 (sets error) */
|
||||
uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, (Uint64)0xffffffffffffffffULL, SDL_FALSE);
|
||||
uresult = SDLTest_RandomUint64BoundaryValue(0, 0xffffffffffffffffULL, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
uresult == 0,
|
||||
@@ -930,63 +927,63 @@ int sdltest_randomBoundaryNumberSint64(void *arg)
|
||||
SDLTest_AssertPass("SDL_ClearError()");
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 10, SDL_TRUE) returns 10 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 10, SDL_TRUE);
|
||||
sresult = SDLTest_RandomSint64BoundaryValue(10, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10,
|
||||
"Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %" SDL_PRIs64, sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE);
|
||||
sresult = SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11,
|
||||
"Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %" SDL_PRIs64, sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE);
|
||||
sresult = SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 12,
|
||||
"Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %" SDL_PRIs64, sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 13, SDL_TRUE);
|
||||
sresult = SDLTest_RandomSint64BoundaryValue(10, 13, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13,
|
||||
"Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %" SDL_PRIs64, sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 20, SDL_TRUE);
|
||||
sresult = SDLTest_RandomSint64BoundaryValue(10, 20, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
|
||||
"Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(20, 10, SDL_TRUE);
|
||||
sresult = SDLTest_RandomSint64BoundaryValue(20, 10, SDL_TRUE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20,
|
||||
"Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %" SDL_PRIs64, sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(1, 20, SDL_FALSE);
|
||||
sresult = SDLTest_RandomSint64BoundaryValue(1, 20, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 0 || sresult == 21,
|
||||
"Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %" SDL_PRIs64, sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, 99, SDL_FALSE);
|
||||
sresult = SDLTest_RandomSint64BoundaryValue(INT64_MIN, 99, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == 100,
|
||||
"Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %" SDL_PRIs64, sresult);
|
||||
|
||||
/* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN + 1, INT64_MAX, SDL_FALSE);
|
||||
sresult = SDLTest_RandomSint64BoundaryValue(INT64_MIN + 1, INT64_MAX, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == INT64_MIN,
|
||||
@@ -996,7 +993,7 @@ int sdltest_randomBoundaryNumberSint64(void *arg)
|
||||
SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
|
||||
|
||||
/* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX - 1, SDL_FALSE) returns LLONG_MAX (no error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX - 1, SDL_FALSE);
|
||||
sresult = SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX - 1, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == INT64_MAX,
|
||||
@@ -1006,7 +1003,7 @@ int sdltest_randomBoundaryNumberSint64(void *arg)
|
||||
SDLTest_AssertCheck(lastError == NULL || lastError[0] == '\0', "Validate no error message was set");
|
||||
|
||||
/* RandomSintXBoundaryValue(LLONG_MIN, LLONG_MAX, SDL_FALSE) returns 0 (sets error) */
|
||||
sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX, SDL_FALSE);
|
||||
sresult = SDLTest_RandomSint64BoundaryValue(INT64_MIN, INT64_MAX, SDL_FALSE);
|
||||
SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue");
|
||||
SDLTest_AssertCheck(
|
||||
sresult == INT64_MIN,
|
||||
|
||||
@@ -383,7 +383,7 @@ int stdlib_sscanf(void *arg)
|
||||
SIZED_TEST_CASE(long long, long_long, "%lld")
|
||||
|
||||
size_output = 123;
|
||||
expected_size_output = (size_t)~0;
|
||||
expected_size_output = ~((size_t)0);
|
||||
expected_result = 1;
|
||||
result = SDL_snprintf(text, sizeof(text), "%zu", expected_size_output);
|
||||
result = SDL_sscanf(text, "%zu", &size_output);
|
||||
|
||||
@@ -450,13 +450,15 @@ int video_getClosestDisplayModeCurrentResolution(void *arg)
|
||||
/* Make call */
|
||||
dResult = SDL_GetClosestDisplayMode(i, &target, &closest);
|
||||
SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=current/variation%d)", variation);
|
||||
SDLTest_AssertCheck(dResult != NULL, "Verify returned value is not NULL");
|
||||
SDLTest_Assert(dResult != NULL, "Verify returned value is not NULL");
|
||||
|
||||
/* Check that one gets the current resolution back again */
|
||||
SDLTest_AssertCheck(closest.w == current.w, "Verify returned width matches current width; expected: %d, got: %d", current.w, closest.w);
|
||||
SDLTest_AssertCheck(closest.h == current.h, "Verify returned height matches current height; expected: %d, got: %d", current.h, closest.h);
|
||||
/* NOLINTBEGIN(clang-analyzer-core.NullDereference): Checked earlier for NULL */
|
||||
SDLTest_AssertCheck(closest.w == dResult->w, "Verify return value matches assigned value; expected: %d, got: %d", closest.w, dResult->w);
|
||||
SDLTest_AssertCheck(closest.h == dResult->h, "Verify return value matches assigned value; expected: %d, got: %d", closest.h, dResult->h);
|
||||
/* NOLINTEND(clang-analyzer-core.NullDereference) */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1685,7 +1687,7 @@ int video_getSetWindowData(void *arg)
|
||||
returnValue = TEST_ABORTED;
|
||||
goto cleanup;
|
||||
}
|
||||
userdata2 = (char *)SDL_strdup(referenceUserdata2);
|
||||
userdata2 = SDL_strdup(referenceUserdata2);
|
||||
if (userdata2 == NULL) {
|
||||
returnValue = TEST_ABORTED;
|
||||
goto cleanup;
|
||||
|
||||
@@ -102,7 +102,8 @@ init_system_cursor(const char *image[])
|
||||
int i, row, col;
|
||||
Uint8 data[4 * 32];
|
||||
Uint8 mask[4 * 32];
|
||||
int hot_x, hot_y;
|
||||
int hot_x = 0;
|
||||
int hot_y = 0;
|
||||
|
||||
i = -1;
|
||||
for (row = 0; row < 32; ++row) {
|
||||
@@ -127,7 +128,7 @@ init_system_cursor(const char *image[])
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_sscanf(image[4 + row], "%d,%d", &hot_x, &hot_y);
|
||||
(void)SDL_sscanf(image[4 + row], "%d,%d", &hot_x, &hot_y);
|
||||
return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " MODE %d: failed to query (%s)\n", m, SDL_GetError());
|
||||
} else {
|
||||
char prefix[64];
|
||||
SDL_snprintf(prefix, sizeof(prefix), " MODE %d", m);
|
||||
(void)SDL_snprintf(prefix, sizeof prefix, " MODE %d", m);
|
||||
print_mode(prefix, &mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
|
||||
if (7 != rwops->read(rwops, test_buf, 1, 7)) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (SDL_memcmp(test_buf, "1234567", 7)) {
|
||||
if (SDL_memcmp(test_buf, "1234567", 7) != 0) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (0 != rwops->read(rwops, test_buf, 1, 1)) {
|
||||
@@ -186,7 +186,7 @@ int main(int argc, char *argv[])
|
||||
if (2 != rwops->read(rwops, test_buf, 10, 3)) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (SDL_memcmp(test_buf, "12345678901234567890", 20)) {
|
||||
if (SDL_memcmp(test_buf, "12345678901234567890", 20) != 0) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (0 != rwops->write(rwops, test_buf, 1, 1)) {
|
||||
@@ -225,7 +225,7 @@ int main(int argc, char *argv[])
|
||||
if (7 != rwops->read(rwops, test_buf, 1, 7)) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (SDL_memcmp(test_buf, "1234567", 7)) {
|
||||
if (SDL_memcmp(test_buf, "1234567", 7) != 0) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (0 != rwops->read(rwops, test_buf, 1, 1)) {
|
||||
@@ -240,7 +240,7 @@ int main(int argc, char *argv[])
|
||||
if (2 != rwops->read(rwops, test_buf, 10, 3)) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (SDL_memcmp(test_buf, "12345678901234567890", 20)) {
|
||||
if (SDL_memcmp(test_buf, "12345678901234567890", 20) != 0) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
rwops->close(rwops);
|
||||
@@ -276,7 +276,7 @@ int main(int argc, char *argv[])
|
||||
if (7 != rwops->read(rwops, test_buf, 1, 7)) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (SDL_memcmp(test_buf, "1234567", 7)) {
|
||||
if (SDL_memcmp(test_buf, "1234567", 7) != 0) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (0 != rwops->read(rwops, test_buf, 1, 1)) {
|
||||
@@ -291,7 +291,7 @@ int main(int argc, char *argv[])
|
||||
if (2 != rwops->read(rwops, test_buf, 10, 3)) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (SDL_memcmp(test_buf, "12345678901234567890", 20)) {
|
||||
if (SDL_memcmp(test_buf, "12345678901234567890", 20) != 0) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
rwops->close(rwops);
|
||||
@@ -328,7 +328,7 @@ int main(int argc, char *argv[])
|
||||
if (7 != rwops->read(rwops, test_buf, 1, 7)) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (SDL_memcmp(test_buf, "1234567", 7)) {
|
||||
if (SDL_memcmp(test_buf, "1234567", 7) != 0) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (0 != rwops->read(rwops, test_buf, 1, 1)) {
|
||||
@@ -348,7 +348,7 @@ int main(int argc, char *argv[])
|
||||
if (3 != rwops->read(rwops, test_buf, 10, 3)) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30)) {
|
||||
if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30) != 0) {
|
||||
RWOP_ERR_QUIT(rwops);
|
||||
}
|
||||
rwops->close(rwops);
|
||||
|
||||
@@ -744,7 +744,7 @@ void loop(void *arg)
|
||||
Uint8 r, g, b;
|
||||
|
||||
if (x < 0) {
|
||||
r = (Uint8)(((int)(~x) * 255) / 32767);
|
||||
r = (Uint8)(((~x) * 255) / 32767);
|
||||
b = 0;
|
||||
} else {
|
||||
r = 0;
|
||||
|
||||
@@ -189,7 +189,7 @@ perspective_matrix(float fovy, float aspect, float znear, float zfar, float *r)
|
||||
* major. In-place multiplication is supported.
|
||||
*/
|
||||
static void
|
||||
multiply_matrix(float *lhs, float *rhs, float *r)
|
||||
multiply_matrix(const float *lhs, const float *rhs, float *r)
|
||||
{
|
||||
int i, j, k;
|
||||
float tmp[16];
|
||||
|
||||
@@ -86,10 +86,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
test[0] = SDL_iconv_string("UTF-8", "UCS-4", ucs4, len);
|
||||
SDL_free(ucs4);
|
||||
fputs(test[0], stdout);
|
||||
(void)fputs(test[0], stdout);
|
||||
SDL_free(test[0]);
|
||||
}
|
||||
fclose(file);
|
||||
(void)fclose(file);
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Total errors: %d\n", errors);
|
||||
return errors ? errors + 1 : 0;
|
||||
|
||||
@@ -159,15 +159,15 @@ static int unifont_init(const char *fontname)
|
||||
}
|
||||
|
||||
/* Looking for the colon that separates the codepoint and glyph data at position 2, 4, 6 and 8. */
|
||||
if (hexBuffer[2] == ':')
|
||||
if (hexBuffer[2] == ':') {
|
||||
codepointHexSize = 2;
|
||||
else if (hexBuffer[4] == ':')
|
||||
} else if (hexBuffer[4] == ':') {
|
||||
codepointHexSize = 4;
|
||||
else if (hexBuffer[6] == ':')
|
||||
} else if (hexBuffer[6] == ':') {
|
||||
codepointHexSize = 6;
|
||||
else if (hexBuffer[8] == ':')
|
||||
} else if (hexBuffer[8] == ':') {
|
||||
codepointHexSize = 8;
|
||||
else {
|
||||
} else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Could not find codepoint and glyph data separator symbol in hex file on line %d.\n", lineNumber);
|
||||
return -1;
|
||||
}
|
||||
@@ -190,9 +190,9 @@ static int unifont_init(const char *fontname)
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n");
|
||||
return -1;
|
||||
}
|
||||
if (hexBuffer[32] == '\n')
|
||||
if (hexBuffer[32] == '\n') {
|
||||
glyphWidth = 8;
|
||||
else {
|
||||
} else {
|
||||
glyphWidth = 16;
|
||||
bytesRead = SDL_RWread(hexFile, hexBuffer + 33, 1, 32);
|
||||
if (bytesRead < 32) {
|
||||
@@ -207,9 +207,9 @@ static int unifont_init(const char *fontname)
|
||||
}
|
||||
|
||||
if (codepoint <= UNIFONT_MAX_CODEPOINT) {
|
||||
if (unifontGlyph[codepoint].width > 0)
|
||||
if (unifontGlyph[codepoint].width > 0) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "unifont: Ignoring duplicate codepoint 0x%08" SDL_PRIx32 " in hex file on line %d.\n", codepoint, lineNumber);
|
||||
else {
|
||||
} else {
|
||||
unifontGlyph[codepoint].width = glyphWidth;
|
||||
/* Pack the hex data into a more compact form. */
|
||||
for (i = 0; i < glyphWidth * 2; i++) {
|
||||
@@ -227,7 +227,8 @@ static int unifont_init(const char *fontname)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void unifont_make_rgba(Uint8 *src, Uint8 *dst, Uint8 width)
|
||||
static void
|
||||
unifont_make_rgba(const Uint8 *src, Uint8 *dst, Uint8 width)
|
||||
{
|
||||
int i, j;
|
||||
Uint8 *row = dst;
|
||||
@@ -279,7 +280,7 @@ static int unifont_load_texture(Uint32 textureID)
|
||||
Uint32 codepoint = UNIFONT_GLYPHS_IN_TEXTURE * textureID + i;
|
||||
if (unifontGlyph[codepoint].width > 0) {
|
||||
const Uint32 cInTex = codepoint % UNIFONT_GLYPHS_IN_TEXTURE;
|
||||
const size_t offset = (cInTex / UNIFONT_GLYPHS_IN_ROW) * UNIFONT_TEXTURE_PITCH * 16 + (cInTex % UNIFONT_GLYPHS_IN_ROW) * 16 * 4;
|
||||
const size_t offset = ((size_t)cInTex / UNIFONT_GLYPHS_IN_ROW) * UNIFONT_TEXTURE_PITCH * 16 + (cInTex % UNIFONT_GLYPHS_IN_ROW) * 16 * 4;
|
||||
unifont_make_rgba(unifontGlyph[codepoint].data, textureRGBA + offset, unifontGlyph[codepoint].width);
|
||||
}
|
||||
}
|
||||
@@ -362,16 +363,16 @@ static void unifont_cleanup()
|
||||
size_t utf8_length(unsigned char c)
|
||||
{
|
||||
c = (unsigned char)(0xff & c);
|
||||
if (c < 0x80)
|
||||
if (c < 0x80) {
|
||||
return 1;
|
||||
else if ((c >> 5) == 0x6)
|
||||
} else if ((c >> 5) == 0x6) {
|
||||
return 2;
|
||||
else if ((c >> 4) == 0xe)
|
||||
} else if ((c >> 4) == 0xe) {
|
||||
return 3;
|
||||
else if ((c >> 3) == 0x1e)
|
||||
} else if ((c >> 3) == 0x1e) {
|
||||
return 4;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *utf8_next(char *p)
|
||||
@@ -409,9 +410,9 @@ Uint32 utf8_decode(char *p, size_t len)
|
||||
}
|
||||
|
||||
for (; i < len; ++i) {
|
||||
if (i == 0)
|
||||
if (i == 0) {
|
||||
codepoint = (0xff >> len) & *p;
|
||||
else {
|
||||
} else {
|
||||
codepoint <<= 6;
|
||||
codepoint |= 0x3f & *p;
|
||||
}
|
||||
@@ -641,9 +642,9 @@ int main(int argc, char *argv[])
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (argc > 0)
|
||||
if (argc > 0) {
|
||||
fontname = argv[0];
|
||||
else {
|
||||
} else {
|
||||
usage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ DrawRectLineIntersections(SDL_Renderer *renderer)
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 0, 255, 55, 255);
|
||||
|
||||
for (i = 0; i < num_rects; i++)
|
||||
for (i = 0; i < num_rects; i++) {
|
||||
for (j = 0; j < num_lines; j++) {
|
||||
int x1, y1, x2, y2;
|
||||
SDL_Rect r;
|
||||
@@ -188,6 +188,7 @@ DrawRectLineIntersections(SDL_Renderer *renderer)
|
||||
SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -197,13 +198,14 @@ DrawRectRectIntersections(SDL_Renderer *renderer)
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 255, 200, 0, 255);
|
||||
|
||||
for (i = 0; i < num_rects; i++)
|
||||
for (i = 0; i < num_rects; i++) {
|
||||
for (j = i + 1; j < num_rects; j++) {
|
||||
SDL_Rect r;
|
||||
if (SDL_IntersectRect(&rects[i], &rects[j], &r)) {
|
||||
SDL_RenderFillRect(renderer, &r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
@@ -230,18 +232,20 @@ void loop()
|
||||
case SDL_KEYDOWN:
|
||||
switch (event.key.keysym.sym) {
|
||||
case 'l':
|
||||
if (event.key.keysym.mod & KMOD_SHIFT)
|
||||
if (event.key.keysym.mod & KMOD_SHIFT) {
|
||||
num_lines = 0;
|
||||
else
|
||||
} else {
|
||||
add_line(rand() % 640, rand() % 480, rand() % 640,
|
||||
rand() % 480);
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
if (event.key.keysym.mod & KMOD_SHIFT)
|
||||
if (event.key.keysym.mod & KMOD_SHIFT) {
|
||||
num_rects = 0;
|
||||
else
|
||||
} else {
|
||||
add_rect(rand() % 640, rand() % 480, rand() % 640,
|
||||
rand() % 480);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -67,11 +67,9 @@ int main(int argc, char *argv[])
|
||||
SDL_Log("Found %s in %s at %p\n", symname, libname, fn);
|
||||
if (hello) {
|
||||
SDL_Log("Calling function...\n");
|
||||
fflush(stdout);
|
||||
fn(" HELLO, WORLD!\n");
|
||||
SDL_Log("...apparently, we survived. :)\n");
|
||||
SDL_Log("Unloading library...\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
SDL_UnloadObject(lib);
|
||||
|
||||
@@ -42,7 +42,7 @@ void printid(void)
|
||||
|
||||
void terminate(int sig)
|
||||
{
|
||||
signal(SIGINT, terminate);
|
||||
(void)signal(SIGINT, terminate);
|
||||
SDL_AtomicSet(&doterminate, 1);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ int SDLCALL
|
||||
Run(void *data)
|
||||
{
|
||||
if (SDL_ThreadID() == mainthread) {
|
||||
signal(SIGTERM, closemutex);
|
||||
(void)signal(SIGTERM, closemutex);
|
||||
}
|
||||
while (!SDL_AtomicGet(&doterminate)) {
|
||||
SDL_Log("Process %lu ready to work\n", SDL_ThreadID());
|
||||
@@ -83,7 +83,7 @@ Run(void *data)
|
||||
}
|
||||
if (SDL_ThreadID() == mainthread && SDL_AtomicGet(&doterminate)) {
|
||||
SDL_Log("Process %lu: raising SIGTERM\n", SDL_ThreadID());
|
||||
raise(SIGTERM);
|
||||
(void)raise(SIGTERM);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -101,26 +101,28 @@ int main(int argc, char *argv[])
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
atexit(SDL_Quit_Wrapper);
|
||||
(void)atexit(SDL_Quit_Wrapper);
|
||||
|
||||
SDL_AtomicSet(&doterminate, 0);
|
||||
|
||||
if ((mutex = SDL_CreateMutex()) == NULL) {
|
||||
mutex = SDL_CreateMutex();
|
||||
if (mutex == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
mainthread = SDL_ThreadID();
|
||||
SDL_Log("Main thread: %lu\n", mainthread);
|
||||
atexit(printid);
|
||||
(void)atexit(printid);
|
||||
for (i = 0; i < maxproc; ++i) {
|
||||
char name[64];
|
||||
SDL_snprintf(name, sizeof(name), "Worker%d", i);
|
||||
if ((threads[i] = SDL_CreateThread(Run, name, NULL)) == NULL) {
|
||||
(void)SDL_snprintf(name, sizeof name, "Worker%d", i);
|
||||
threads[i] = SDL_CreateThread(Run, name, NULL);
|
||||
if (threads[i] == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n");
|
||||
}
|
||||
}
|
||||
signal(SIGINT, terminate);
|
||||
(void)signal(SIGINT, terminate);
|
||||
Run(NULL);
|
||||
|
||||
return 0; /* Never reached */
|
||||
|
||||
@@ -90,7 +90,6 @@ test_multi_audio(int devcount)
|
||||
for (i = 0; i < devcount; i++) {
|
||||
const char *devname = SDL_GetAudioDeviceName(i, 0);
|
||||
SDL_Log("playing on device #%d: ('%s')...", i, devname);
|
||||
fflush(stdout);
|
||||
|
||||
SDL_memset(&cbd[0], '\0', sizeof(callback_data));
|
||||
spec.userdata = &cbd[0];
|
||||
|
||||
@@ -47,7 +47,7 @@ static void
|
||||
quit(int rc)
|
||||
{
|
||||
SDL_VideoQuit();
|
||||
if (native_window) {
|
||||
if (native_window != NULL && factory != NULL) {
|
||||
factory->DestroyNativeWindow(native_window);
|
||||
}
|
||||
exit(rc);
|
||||
|
||||
@@ -319,6 +319,7 @@ int main(int argc, char **argv)
|
||||
filename = GetResourceFilename(NULL, "moose.dat");
|
||||
if (filename == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
|
||||
SDL_free(RawMooseData);
|
||||
return -1;
|
||||
}
|
||||
handle = SDL_RWFromFile(filename, "rb");
|
||||
|
||||
@@ -54,8 +54,7 @@ report_power(void)
|
||||
if (seconds == -1) {
|
||||
SDL_Log("Time left: unknown\n");
|
||||
} else {
|
||||
SDL_Log("Time left: %d minutes, %d seconds\n", (int)(seconds / 60),
|
||||
(int)(seconds % 60));
|
||||
SDL_Log("Time left: %d minutes, %d seconds\n", seconds / 60, seconds % 60);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,10 +51,11 @@ int main(int argc, char *argv[])
|
||||
if (argc > 1) {
|
||||
int success;
|
||||
Uint64 seed = 0;
|
||||
if (argv[1][0] == '0' && argv[1][1] == 'x')
|
||||
if (argv[1][0] == '0' && argv[1][1] == 'x') {
|
||||
success = SDL_sscanf(argv[1] + 2, "%" SDL_PRIx64, &seed);
|
||||
else
|
||||
} else {
|
||||
success = SDL_sscanf(argv[1], "%" SDL_PRIu64, &seed);
|
||||
}
|
||||
if (!success) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid seed. Use a decimal or hexadecimal number.\n");
|
||||
return 1;
|
||||
|
||||
@@ -56,7 +56,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
cvt.len = len;
|
||||
cvt.buf = (Uint8 *)SDL_malloc(len * cvt.len_mult);
|
||||
cvt.buf = (Uint8 *)SDL_malloc((size_t)len * cvt.len_mult);
|
||||
if (cvt.buf == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n");
|
||||
SDL_FreeWAV(data);
|
||||
|
||||
@@ -76,7 +76,7 @@ TestRealWorld(int init_sem)
|
||||
/* Create all the threads */
|
||||
for (i = 0; i < NUM_THREADS; ++i) {
|
||||
char name[64];
|
||||
SDL_snprintf(name, sizeof(name), "Thread%u", (unsigned int)i);
|
||||
(void)SDL_snprintf(name, sizeof name, "Thread%u", (unsigned int)i);
|
||||
thread_states[i].number = i;
|
||||
thread_states[i].thread = SDL_CreateThread(ThreadFuncRealWorld, name, (void *)&thread_states[i]);
|
||||
}
|
||||
@@ -198,7 +198,7 @@ TestOverheadContended(SDL_bool try_wait)
|
||||
/* Create multiple threads to starve the semaphore and cause contention */
|
||||
for (i = 0; i < NUM_THREADS; ++i) {
|
||||
char name[64];
|
||||
SDL_snprintf(name, sizeof(name), "Thread%u", (unsigned int)i);
|
||||
(void)SDL_snprintf(name, sizeof name, "Thread%u", (unsigned int)i);
|
||||
thread_states[i].flag = try_wait;
|
||||
thread_states[i].thread = SDL_CreateThread(ThreadFuncOverheadContended, name, (void *)&thread_states[i]);
|
||||
}
|
||||
@@ -229,17 +229,17 @@ TestOverheadContended(SDL_bool try_wait)
|
||||
duration, try_wait ? "where contended" : "timed out", content_count,
|
||||
loop_count, ((float)content_count * 100) / loop_count);
|
||||
/* Print how many semaphores where consumed per thread */
|
||||
SDL_snprintf(textBuffer, sizeof(textBuffer), "{ ");
|
||||
(void)SDL_snprintf(textBuffer, sizeof textBuffer, "{ ");
|
||||
for (i = 0; i < NUM_THREADS; ++i) {
|
||||
if (i > 0) {
|
||||
len = SDL_strlen(textBuffer);
|
||||
SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, ", ");
|
||||
(void)SDL_snprintf(textBuffer + len, sizeof textBuffer - len, ", ");
|
||||
}
|
||||
len = SDL_strlen(textBuffer);
|
||||
SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, "%d", thread_states[i].loop_count - thread_states[i].content_count);
|
||||
(void)SDL_snprintf(textBuffer + len, sizeof textBuffer - len, "%d", thread_states[i].loop_count - thread_states[i].content_count);
|
||||
}
|
||||
len = SDL_strlen(textBuffer);
|
||||
SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n");
|
||||
(void)SDL_snprintf(textBuffer + len, sizeof textBuffer - len, " }\n");
|
||||
SDL_Log("%s\n", textBuffer);
|
||||
|
||||
SDL_DestroySemaphore(sem);
|
||||
@@ -262,8 +262,8 @@ int main(int argc, char **argv)
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
signal(SIGTERM, killed);
|
||||
signal(SIGINT, killed);
|
||||
(void)signal(SIGTERM, killed);
|
||||
(void)signal(SIGINT, killed);
|
||||
|
||||
init_sem = SDL_atoi(argv[1]);
|
||||
if (init_sem > 0) {
|
||||
|
||||
@@ -28,7 +28,7 @@ static const char *GetSensorTypeString(SDL_SensorType type)
|
||||
case SDL_SENSOR_GYRO:
|
||||
return "SDL_SENSOR_GYRO";
|
||||
default:
|
||||
SDL_snprintf(unknown_type, sizeof(unknown_type), "UNKNOWN (%d)", type);
|
||||
(void)SDL_snprintf(unknown_type, sizeof unknown_type, "UNKNOWN (%d)", type);
|
||||
return unknown_type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ static SDL_bool CompileShader(GLhandleARB shader, const char *source)
|
||||
char *info;
|
||||
|
||||
glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
|
||||
info = (char *)SDL_malloc(length + 1);
|
||||
info = (char *)SDL_malloc((size_t)length + 1);
|
||||
if (info == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
|
||||
} else {
|
||||
@@ -162,7 +162,7 @@ static SDL_bool LinkProgram(ShaderData *data)
|
||||
char *info;
|
||||
|
||||
glGetObjectParameterivARB(data->program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
|
||||
info = (char *)SDL_malloc(length + 1);
|
||||
info = (char *)SDL_malloc((size_t)length + 1);
|
||||
if (info == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
|
||||
} else {
|
||||
@@ -208,7 +208,7 @@ static SDL_bool CompileShaderProgram(ShaderData *data)
|
||||
glUseProgramObjectARB(data->program);
|
||||
for (i = 0; i < num_tmus_bound; ++i) {
|
||||
char tex_name[5];
|
||||
SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i);
|
||||
(void)SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i);
|
||||
location = glGetUniformLocationARB(data->program, tex_name);
|
||||
if (location >= 0) {
|
||||
glUniform1iARB(location, i);
|
||||
|
||||
@@ -158,7 +158,7 @@ int main(int argc, char **argv)
|
||||
texture_dimensions.x = 0;
|
||||
texture_dimensions.y = 0;
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Changing to shaped bmp: %s", pictures[current_picture].name);
|
||||
SDL_QueryTexture(pictures[current_picture].texture, (Uint32 *)&pixelFormat, (int *)&access, &texture_dimensions.w, &texture_dimensions.h);
|
||||
SDL_QueryTexture(pictures[current_picture].texture, &pixelFormat, &access, &texture_dimensions.w, &texture_dimensions.h);
|
||||
SDL_SetWindowSize(window, texture_dimensions.w, texture_dimensions.h);
|
||||
SDL_SetWindowShape(window, pictures[current_picture].surface, &pictures[current_picture].mode);
|
||||
while (should_exit == 0) {
|
||||
@@ -177,7 +177,7 @@ int main(int argc, char **argv)
|
||||
current_picture = 0;
|
||||
}
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Changing to shaped bmp: %s", pictures[current_picture].name);
|
||||
SDL_QueryTexture(pictures[current_picture].texture, (Uint32 *)&pixelFormat, (int *)&access, &texture_dimensions.w, &texture_dimensions.h);
|
||||
SDL_QueryTexture(pictures[current_picture].texture, &pixelFormat, &access, &texture_dimensions.w, &texture_dimensions.h);
|
||||
SDL_SetWindowSize(window, texture_dimensions.w, texture_dimensions.h);
|
||||
SDL_SetWindowShape(window, pictures[current_picture].surface, &pictures[current_picture].mode);
|
||||
}
|
||||
|
||||
@@ -126,13 +126,13 @@ int main(int argc, char *argv[])
|
||||
SDL_Log("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls));
|
||||
|
||||
alive = 1;
|
||||
signal(SIGTERM, killed);
|
||||
(void)signal(SIGTERM, killed);
|
||||
thread = SDL_CreateThread(ThreadFunc, "Two", "#2");
|
||||
if (thread == NULL) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
|
||||
quit(1);
|
||||
}
|
||||
raise(SIGTERM);
|
||||
(void)raise(SIGTERM);
|
||||
|
||||
SDL_Quit(); /* Never reached */
|
||||
return 0; /* Never reached */
|
||||
|
||||
@@ -33,7 +33,7 @@ GetNearbyFilename(const char *file)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_snprintf(path, len, "%s%s", base, file);
|
||||
(void)SDL_snprintf(path, len, "%s%s", base, file);
|
||||
SDL_free(base);
|
||||
|
||||
rw = SDL_RWFromFile(path, "rb");
|
||||
|
||||
@@ -897,7 +897,9 @@ static void rerecordCommandBuffer(uint32_t frameIndex, const VkClearColorValue *
|
||||
|
||||
static void destroySwapchainAndSwapchainSpecificStuff(SDL_bool doDestroySwapchain)
|
||||
{
|
||||
vkDeviceWaitIdle(vulkanContext->device);
|
||||
if (vkDeviceWaitIdle != NULL) {
|
||||
vkDeviceWaitIdle(vulkanContext->device);
|
||||
}
|
||||
destroyFences();
|
||||
destroyCommandBuffers();
|
||||
destroyCommandPool();
|
||||
|
||||
@@ -83,12 +83,12 @@ draw_modes_menu(SDL_Window *window, SDL_Renderer *renderer, SDL_Rect viewport)
|
||||
|
||||
y += lineHeight;
|
||||
|
||||
SDL_snprintf(text, sizeof(text), "Click on a mode to set it with SDL_SetWindowDisplayMode");
|
||||
SDL_strlcpy(text, "Click on a mode to set it with SDL_SetWindowDisplayMode", sizeof text);
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
SDLTest_DrawString(renderer, x, y, text);
|
||||
y += lineHeight;
|
||||
|
||||
SDL_snprintf(text, sizeof(text), "Press Ctrl+Enter to toggle SDL_WINDOW_FULLSCREEN");
|
||||
SDL_strlcpy(text, "Press Ctrl+Enter to toggle SDL_WINDOW_FULLSCREEN", sizeof text);
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
SDLTest_DrawString(renderer, x, y, text);
|
||||
y += lineHeight;
|
||||
@@ -107,8 +107,8 @@ draw_modes_menu(SDL_Window *window, SDL_Renderer *renderer, SDL_Rect viewport)
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_snprintf(text, sizeof(text), "%d: %dx%d@%dHz",
|
||||
i, mode.w, mode.h, mode.refresh_rate);
|
||||
(void)SDL_snprintf(text, sizeof text, "%d: %dx%d@%dHz",
|
||||
i, mode.w, mode.h, mode.refresh_rate);
|
||||
|
||||
/* Update column width */
|
||||
text_length = (int)SDL_strlen(text);
|
||||
|
||||
@@ -436,7 +436,7 @@ int main(int argc, char **argv)
|
||||
if (current == 0) {
|
||||
SDLTest_DrawString(renderer, 4, 4, titles[current]);
|
||||
} else {
|
||||
SDL_snprintf(title, sizeof(title), "%s %s %s", titles[current], yuv_name, yuv_mode);
|
||||
(void)SDL_snprintf(title, sizeof title, "%s %s %s", titles[current], yuv_name, yuv_mode);
|
||||
SDLTest_DrawString(renderer, 4, 4, title);
|
||||
}
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
@@ -19,7 +19,7 @@ static float clip3(float x, float y, float z)
|
||||
return (z < x) ? x : ((z > y) ? y : z);
|
||||
}
|
||||
|
||||
static void RGBtoYUV(Uint8 *rgb, int *yuv, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance)
|
||||
static void RGBtoYUV(const Uint8 *rgb, int *yuv, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance)
|
||||
{
|
||||
if (mode == SDL_YUV_CONVERSION_JPEG) {
|
||||
/* Full range YUV */
|
||||
|
||||
@@ -52,7 +52,7 @@ ThreadFunc(void *data)
|
||||
|
||||
for (i = 0; i < NUMTHREADS; i++) {
|
||||
char name[64];
|
||||
SDL_snprintf(name, sizeof(name), "Child%d_%d", tid, i);
|
||||
(void)SDL_snprintf(name, sizeof name, "Child%d_%d", tid, i);
|
||||
flags[i] = 0;
|
||||
sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]);
|
||||
}
|
||||
@@ -87,10 +87,10 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
signal(SIGSEGV, SIG_DFL);
|
||||
(void)signal(SIGSEGV, SIG_DFL);
|
||||
for (i = 0; i < NUMTHREADS; i++) {
|
||||
char name[64];
|
||||
SDL_snprintf(name, sizeof(name), "Parent%d", i);
|
||||
(void)SDL_snprintf(name, sizeof name, "Parent%d", i);
|
||||
SDL_AtomicSet(&time_for_threads_to_die[i], 0);
|
||||
threads[i] = SDL_CreateThread(ThreadFunc, name, (void *)(uintptr_t)i);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user