tests: several -Wwrite-strings fixes.

This commit is contained in:
Ozkan Sezer 2021-11-20 01:02:02 +03:00
parent 665865eda2
commit 990fb668f7
17 changed files with 84 additions and 84 deletions

View File

@ -76,9 +76,9 @@ typedef struct SDLTest_TestCaseReference {
/* !< Func2Stress */ /* !< Func2Stress */
SDLTest_TestCaseFp testCase; SDLTest_TestCaseFp testCase;
/* !< Short name (or function name) "Func2Stress" */ /* !< Short name (or function name) "Func2Stress" */
char *name; const char *name;
/* !< Long name or full description "This test pushes func2() to the limit." */ /* !< Long name or full description "This test pushes func2() to the limit." */
char *description; const char *description;
/* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */
int enabled; int enabled;
} SDLTest_TestCaseReference; } SDLTest_TestCaseReference;
@ -88,7 +88,7 @@ typedef struct SDLTest_TestCaseReference {
*/ */
typedef struct SDLTest_TestSuiteReference { typedef struct SDLTest_TestSuiteReference {
/* !< "PlatformSuite" */ /* !< "PlatformSuite" */
char *name; const char *name;
/* !< The function that is run before each test. NULL skips. */ /* !< The function that is run before each test. NULL skips. */
SDLTest_TestCaseSetUpFp testSetUp; SDLTest_TestCaseSetUpFp testSetUp;
/* !< The test cases that are run as part of the suite. Last item should be NULL. */ /* !< The test cases that are run as part of the suite. Last item should be NULL. */

View File

@ -98,7 +98,7 @@ SDLTest_GenerateRunSeed(const int length)
* *
*/ */
static Uint64 static Uint64
SDLTest_GenerateExecKey(const char *runSeed, char *suiteName, char *testName, int iteration) SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName, const char *testName, int iteration)
{ {
SDLTest_Md5Context md5Context; SDLTest_Md5Context md5Context;
Uint64 *keys; Uint64 *keys;

View File

@ -137,9 +137,10 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
} }
static void static void
PrintText(char *eventtype, char *text) PrintText(const char *eventtype, const char *text)
{ {
char *spot, expanded[1024]; const char *spot;
char expanded[1024];
expanded[0] = '\0'; expanded[0] = '\0';
for ( spot = text; *spot; ++spot ) for ( spot = text; *spot; ++spot )

View File

@ -138,9 +138,10 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
} }
static void static void
PrintText(char *eventtype, char *text) PrintText(const char *eventtype, const char *text)
{ {
char *spot, expanded[1024]; const char *spot;
char expanded[1024];
expanded[0] = '\0'; expanded[0] = '\0';
for ( spot = text; *spot; ++spot ) for ( spot = text; *spot; ++spot )

View File

@ -19,13 +19,13 @@
*/ */
static static
char * const char *
tf(SDL_bool tf) tf(SDL_bool _tf)
{ {
static char *t = "TRUE"; static const char *t = "TRUE";
static char *f = "FALSE"; static const char *f = "FALSE";
if (tf) if (_tf)
{ {
return t; return t;
} }

View File

@ -498,7 +498,7 @@ const int _numAudioFormats = 18;
SDL_AudioFormat _audioFormats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB, SDL_AudioFormat _audioFormats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB,
AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32, AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32,
AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 }; AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 };
char *_audioFormatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB", const char *_audioFormatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB",
"AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32", "AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32",
"AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" }; "AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" };
const int _numAudioChannels = 4; const int _numAudioChannels = 4;
@ -697,7 +697,7 @@ int audio_openCloseAndGetAudioStatus()
SDL_AudioStatus result; SDL_AudioStatus result;
int i; int i;
int count; int count;
char *device; const char *device;
SDL_AudioDeviceID id; SDL_AudioDeviceID id;
SDL_AudioSpec desired, obtained; SDL_AudioSpec desired, obtained;
@ -707,7 +707,7 @@ int audio_openCloseAndGetAudioStatus()
if (count > 0) { if (count > 0) {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
/* Get device name */ /* Get device name */
device = (char *)SDL_GetAudioDeviceName(i, 0); device = SDL_GetAudioDeviceName(i, 0);
SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i); SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL"); SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
if (device == NULL) return TEST_ABORTED; if (device == NULL) return TEST_ABORTED;
@ -721,7 +721,7 @@ int audio_openCloseAndGetAudioStatus()
desired.userdata=NULL; desired.userdata=NULL;
/* Open device */ /* Open device */
id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); id = SDL_OpenAudioDevice(device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id); SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id);
if (id > 1) { if (id > 1) {
@ -755,7 +755,7 @@ int audio_lockUnlockOpenAudioDevice()
{ {
int i; int i;
int count; int count;
char *device; const char *device;
SDL_AudioDeviceID id; SDL_AudioDeviceID id;
SDL_AudioSpec desired, obtained; SDL_AudioSpec desired, obtained;
@ -765,7 +765,7 @@ int audio_lockUnlockOpenAudioDevice()
if (count > 0) { if (count > 0) {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
/* Get device name */ /* Get device name */
device = (char *)SDL_GetAudioDeviceName(i, 0); device = SDL_GetAudioDeviceName(i, 0);
SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i); SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL"); SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
if (device == NULL) return TEST_ABORTED; if (device == NULL) return TEST_ABORTED;
@ -779,7 +779,7 @@ int audio_lockUnlockOpenAudioDevice()
desired.userdata=NULL; desired.userdata=NULL;
/* Open device */ /* Open device */
id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); id = SDL_OpenAudioDevice(device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id); SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id);
if (id > 1) { if (id > 1) {
@ -917,7 +917,7 @@ int audio_openCloseAudioDeviceConnected()
int result = -1; int result = -1;
int i; int i;
int count; int count;
char *device; const char *device;
SDL_AudioDeviceID id; SDL_AudioDeviceID id;
SDL_AudioSpec desired, obtained; SDL_AudioSpec desired, obtained;
@ -927,7 +927,7 @@ int audio_openCloseAudioDeviceConnected()
if (count > 0) { if (count > 0) {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
/* Get device name */ /* Get device name */
device = (char *)SDL_GetAudioDeviceName(i, 0); device = SDL_GetAudioDeviceName(i, 0);
SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i); SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL"); SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
if (device == NULL) return TEST_ABORTED; if (device == NULL) return TEST_ABORTED;
@ -941,7 +941,7 @@ int audio_openCloseAudioDeviceConnected()
desired.userdata=NULL; desired.userdata=NULL;
/* Open device */ /* Open device */
id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); id = SDL_OpenAudioDevice(device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >1, got: %i", id); SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >1, got: %i", id);
if (id > 1) { if (id > 1) {

View File

@ -9,7 +9,7 @@
const int _numHintsEnum = 25; const int _numHintsEnum = 25;
char* _HintsEnum[] = const char* _HintsEnum[] =
{ {
SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_HINT_ACCELEROMETER_AS_JOYSTICK,
SDL_HINT_FRAMEBUFFER_ACCELERATION, SDL_HINT_FRAMEBUFFER_ACCELERATION,
@ -37,7 +37,7 @@ char* _HintsEnum[] =
SDL_HINT_VIDEO_X11_XVIDMODE, SDL_HINT_VIDEO_X11_XVIDMODE,
SDL_HINT_XINPUT_ENABLED, SDL_HINT_XINPUT_ENABLED,
}; };
char* _HintsVerbose[] = const char* _HintsVerbose[] =
{ {
"SDL_ACCELEROMETER_AS_JOYSTICK", "SDL_ACCELEROMETER_AS_JOYSTICK",
"SDL_FRAMEBUFFER_ACCELERATION", "SDL_FRAMEBUFFER_ACCELERATION",
@ -75,14 +75,14 @@ char* _HintsVerbose[] =
int int
hints_getHint(void *arg) hints_getHint(void *arg)
{ {
char *result1; const char *result1;
char *result2; const char *result2;
int i; int i;
for (i=0; i<_numHintsEnum; i++) { for (i=0; i<_numHintsEnum; i++) {
result1 = (char *)SDL_GetHint((char*)_HintsEnum[i]); result1 = SDL_GetHint(_HintsEnum[i]);
SDLTest_AssertPass("Call to SDL_GetHint(%s) - using define definition", (char*)_HintsEnum[i]); SDLTest_AssertPass("Call to SDL_GetHint(%s) - using define definition", (char*)_HintsEnum[i]);
result2 = (char *)SDL_GetHint((char *)_HintsVerbose[i]); result2 = SDL_GetHint(_HintsVerbose[i]);
SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]); SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]);
SDLTest_AssertCheck( SDLTest_AssertCheck(
(result1 == NULL && result2 == NULL) || (SDL_strcmp(result1, result2) == 0), (result1 == NULL && result2 == NULL) || (SDL_strcmp(result1, result2) == 0),
@ -100,9 +100,9 @@ hints_getHint(void *arg)
int int
hints_setHint(void *arg) hints_setHint(void *arg)
{ {
char *originalValue; const char *originalValue;
char *value; const char *value;
char *testValue; const char *testValue;
SDL_bool result; SDL_bool result;
int i, j; int i, j;
@ -111,22 +111,22 @@ hints_setHint(void *arg)
for (i=0; i<_numHintsEnum; i++) { for (i=0; i<_numHintsEnum; i++) {
/* Capture current value */ /* Capture current value */
originalValue = (char *)SDL_GetHint((char*)_HintsEnum[i]); originalValue = SDL_GetHint(_HintsEnum[i]);
SDLTest_AssertPass("Call to SDL_GetHint(%s)", (char*)_HintsEnum[i]); SDLTest_AssertPass("Call to SDL_GetHint(%s)", _HintsEnum[i]);
/* Copy the original value, since it will be freed when we set it again */ /* Copy the original value, since it will be freed when we set it again */
originalValue = originalValue ? SDL_strdup(originalValue) : NULL; originalValue = originalValue ? SDL_strdup(originalValue) : NULL;
/* Set value (twice) */ /* Set value (twice) */
for (j=1; j<=2; j++) { for (j=1; j<=2; j++) {
result = SDL_SetHint((char*)_HintsEnum[i], value); result = SDL_SetHint(_HintsEnum[i], value);
SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", (char*)_HintsEnum[i], value, j); SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", _HintsEnum[i], value, j);
SDLTest_AssertCheck( SDLTest_AssertCheck(
result == SDL_TRUE || result == SDL_FALSE, result == SDL_TRUE || result == SDL_FALSE,
"Verify valid result was returned, got: %i", "Verify valid result was returned, got: %i",
(int)result); (int)result);
testValue = (char *)SDL_GetHint((char*)_HintsEnum[i]); testValue = SDL_GetHint(_HintsEnum[i]);
SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]); SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", _HintsVerbose[i]);
SDLTest_AssertCheck( SDLTest_AssertCheck(
(SDL_strcmp(value, testValue) == 0), (SDL_strcmp(value, testValue) == 0),
"Verify returned value equals set value; got: testValue='%s' value='%s", "Verify returned value equals set value; got: testValue='%s' value='%s",
@ -135,16 +135,16 @@ hints_setHint(void *arg)
} }
/* Reset original value */ /* Reset original value */
result = SDL_SetHint((char*)_HintsEnum[i], originalValue); result = SDL_SetHint(_HintsEnum[i], originalValue);
SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", (char*)_HintsEnum[i]); SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", _HintsEnum[i]);
SDLTest_AssertCheck( SDLTest_AssertCheck(
result == SDL_TRUE || result == SDL_FALSE, result == SDL_TRUE || result == SDL_FALSE,
"Verify valid result was returned, got: %i", "Verify valid result was returned, got: %i",
(int)result); (int)result);
SDL_free(originalValue); SDL_free((void *)originalValue);
} }
SDL_free(value); SDL_free((void *)value);
return TEST_COMPLETED; return TEST_COMPLETED;
} }

View File

@ -168,8 +168,8 @@ keyboard_getKeyFromScancode(void *arg)
int int
keyboard_getKeyName(void *arg) keyboard_getKeyName(void *arg)
{ {
char *result; const char *result;
char *expected; const char *expected;
/* Case where key has a 1 character name */ /* Case where key has a 1 character name */
expected = "3"; expected = "3";
@ -225,8 +225,8 @@ int
keyboard_getScancodeNameNegative(void *arg) keyboard_getScancodeNameNegative(void *arg)
{ {
SDL_Scancode scancode; SDL_Scancode scancode;
char *result; const char *result;
char *expected = ""; const char *expected = "";
/* Clear error message */ /* Clear error message */
SDL_ClearError(); SDL_ClearError();
@ -252,8 +252,8 @@ int
keyboard_getKeyNameNegative(void *arg) keyboard_getKeyNameNegative(void *arg)
{ {
SDL_Keycode keycode; SDL_Keycode keycode;
char *result; const char *result;
char *expected = ""; const char *expected = "";
/* Unknown keycode */ /* Unknown keycode */
keycode = SDLK_UNKNOWN; keycode = SDLK_UNKNOWN;
@ -612,7 +612,7 @@ _checkInvalidNameError()
int int
keyboard_getScancodeFromNameNegative(void *arg) keyboard_getScancodeFromNameNegative(void *arg)
{ {
char *name; const char *name;
SDL_Scancode scancode; SDL_Scancode scancode;
/* Clear error message */ /* Clear error message */
@ -625,9 +625,9 @@ keyboard_getScancodeFromNameNegative(void *arg)
if (name == NULL) { if (name == NULL) {
return TEST_ABORTED; return TEST_ABORTED;
} }
scancode = SDL_GetScancodeFromName((const char *)name); scancode = SDL_GetScancodeFromName(name);
SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name); SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name);
SDL_free(name); SDL_free((void *)name);
SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode);
_checkInvalidNameError(); _checkInvalidNameError();

View File

@ -45,7 +45,7 @@ Uint32 _RGBPixelFormats[] =
SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_ARGB2101010 SDL_PIXELFORMAT_ARGB2101010
}; };
char* _RGBPixelFormatsVerbose[] = const char* _RGBPixelFormatsVerbose[] =
{ {
"SDL_PIXELFORMAT_INDEX1LSB", "SDL_PIXELFORMAT_INDEX1LSB",
"SDL_PIXELFORMAT_INDEX1MSB", "SDL_PIXELFORMAT_INDEX1MSB",
@ -92,7 +92,7 @@ Uint32 _nonRGBPixelFormats[] =
SDL_PIXELFORMAT_NV12, SDL_PIXELFORMAT_NV12,
SDL_PIXELFORMAT_NV21 SDL_PIXELFORMAT_NV21
}; };
char* _nonRGBPixelFormatsVerbose[] = const char* _nonRGBPixelFormatsVerbose[] =
{ {
"SDL_PIXELFORMAT_YV12", "SDL_PIXELFORMAT_YV12",
"SDL_PIXELFORMAT_IYUV", "SDL_PIXELFORMAT_IYUV",
@ -110,7 +110,7 @@ Uint32 _invalidPixelFormats[] =
0xfffffffe, 0xfffffffe,
0xffffffff 0xffffffff
}; };
char* _invalidPixelFormatsVerbose[] = const char* _invalidPixelFormatsVerbose[] =
{ {
"SDL_PIXELFORMAT_UNKNOWN", "SDL_PIXELFORMAT_UNKNOWN",
"SDL_PIXELFORMAT_UNKNOWN" "SDL_PIXELFORMAT_UNKNOWN"
@ -237,14 +237,14 @@ pixels_getPixelFormatName(void *arg)
const char *error; const char *error;
int i; int i;
Uint32 format; Uint32 format;
char* result; const char *result;
/* Blank/undefined format */ /* Blank/undefined format */
format = 0; format = 0;
SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format); SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format);
/* Get name of format */ /* Get name of format */
result = (char *)SDL_GetPixelFormatName(format); result = SDL_GetPixelFormatName(format);
SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) { if (result != NULL) {
@ -259,7 +259,7 @@ pixels_getPixelFormatName(void *arg)
SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format); SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format);
/* Get name of format */ /* Get name of format */
result = (char *)SDL_GetPixelFormatName(format); result = SDL_GetPixelFormatName(format);
SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) { if (result != NULL) {
@ -275,7 +275,7 @@ pixels_getPixelFormatName(void *arg)
SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format); SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format);
/* Get name of format */ /* Get name of format */
result = (char *)SDL_GetPixelFormatName(format); result = SDL_GetPixelFormatName(format);
SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) { if (result != NULL) {
@ -292,7 +292,7 @@ pixels_getPixelFormatName(void *arg)
SDLTest_AssertPass("Call to SDL_ClearError()"); SDLTest_AssertPass("Call to SDL_ClearError()");
for (i = 0; i < _numInvalidPixelFormats; i++) { for (i = 0; i < _numInvalidPixelFormats; i++) {
format = _invalidPixelFormats[i]; format = _invalidPixelFormats[i];
result = (char *)SDL_GetPixelFormatName(format); result = SDL_GetPixelFormatName(format);
SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%u)", format); SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%u)", format);
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) { if (result != NULL) {

View File

@ -42,6 +42,8 @@ main(int argc, char *argv[])
"UCS4", "UCS4",
"UCS-4", "UCS-4",
}; };
const char * fname;
char buffer[BUFSIZ]; char buffer[BUFSIZ];
char *ucs4; char *ucs4;
char *test[2]; char *test[2];
@ -52,12 +54,10 @@ main(int argc, char *argv[])
/* Enable standard application logging */ /* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
if (!argv[1]) { fname = (argc < 2) ? "utf8.txt" : argv[1];
argv[1] = "utf8.txt"; file = fopen(fname, "rb");
}
file = fopen(argv[1], "rb");
if (!file) { if (!file) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", argv[1]); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", fname);
return (1); return (1);
} }

View File

@ -180,13 +180,11 @@ main(int argc, char **argv)
if (devcount < 1) { if (devcount < 1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n"); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n");
} else { } else {
if (argv[1] == NULL) { const char *file = (argc < 2) ? "sample.wav" : argv[1];
argv[1] = "sample.wav";
}
/* Load the wave file into memory */ /* Load the wave file into memory */
if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) { if (SDL_LoadWAV(file, &spec, &sound, &soundlen) == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file,
SDL_GetError()); SDL_GetError());
} else { } else {
test_multi_audio(devcount); test_multi_audio(devcount);

View File

@ -53,7 +53,7 @@ quit(int rc)
} }
SDL_Texture * SDL_Texture *
LoadSprite(SDL_Renderer *renderer, char *file) LoadSprite(SDL_Renderer *renderer, const char *file)
{ {
SDL_Surface *temp; SDL_Surface *temp;
SDL_Texture *sprite; SDL_Texture *sprite;

View File

@ -19,7 +19,7 @@ report_power(void)
{ {
int seconds, percent; int seconds, percent;
const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent); const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent);
char *statestr = NULL; const char *statestr = NULL;
SDL_Log("SDL-reported power info...\n"); SDL_Log("SDL-reported power info...\n");
switch (state) { switch (state) {

View File

@ -46,7 +46,7 @@ quit(int rc)
} }
SDL_Texture * SDL_Texture *
LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
{ {
SDL_Surface *temp; SDL_Surface *temp;
SDL_Texture *texture; SDL_Texture *texture;

View File

@ -47,7 +47,7 @@ quit(int rc)
} }
SDL_Texture * SDL_Texture *
LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent)
{ {
SDL_Surface *temp; SDL_Surface *temp;
SDL_Texture *texture; SDL_Texture *texture;

View File

@ -43,7 +43,7 @@ quit(int rc)
} }
int int
LoadSprite(char *file) LoadSprite(const char *file)
{ {
SDL_Surface *temp; SDL_Surface *temp;

View File

@ -43,7 +43,7 @@ quit(int rc)
} }
int int
LoadSprite(char *file, SDL_Renderer *renderer) LoadSprite(const char *file, SDL_Renderer *renderer)
{ {
SDL_Surface *temp; SDL_Surface *temp;