Commit 990fb668f71fb51dc1c698083bb0fd006b77189f

Ozkan Sezer 2021-11-20T01:02:02

tests: several -Wwrite-strings fixes.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
diff --git a/include/SDL_test_harness.h b/include/SDL_test_harness.h
index 106464c..3353fb7 100644
--- a/include/SDL_test_harness.h
+++ b/include/SDL_test_harness.h
@@ -76,9 +76,9 @@ typedef struct SDLTest_TestCaseReference {
     /* !< Func2Stress */
     SDLTest_TestCaseFp testCase;
     /* !< Short name (or function name) "Func2Stress" */
-    char *name;
+    const char *name;
     /* !< 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) */
     int enabled;
 } SDLTest_TestCaseReference;
@@ -88,7 +88,7 @@ typedef struct SDLTest_TestCaseReference {
  */
 typedef struct SDLTest_TestSuiteReference {
     /* !< "PlatformSuite" */
-    char *name;
+    const char *name;
     /* !< The function that is run before each test. NULL skips. */
     SDLTest_TestCaseSetUpFp testSetUp;
     /* !< The test cases that are run as part of the suite. Last item should be NULL. */
diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c
index 7a1d261..978bea4 100644
--- a/src/test/SDL_test_harness.c
+++ b/src/test/SDL_test_harness.c
@@ -98,7 +98,7 @@ SDLTest_GenerateRunSeed(const int length)
 *
 */
 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;
     Uint64 *keys;
diff --git a/test/checkkeys.c b/test/checkkeys.c
index f2ddc7f..8188db8 100644
--- a/test/checkkeys.c
+++ b/test/checkkeys.c
@@ -137,9 +137,10 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
 }
 
 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';
     for ( spot = text; *spot; ++spot )
diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c
index f9de1d8..e636b71 100644
--- a/test/checkkeysthreads.c
+++ b/test/checkkeysthreads.c
@@ -138,9 +138,10 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
 }
 
 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';
     for ( spot = text; *spot; ++spot )
diff --git a/test/testatomic.c b/test/testatomic.c
index ba04967..cc5e249 100644
--- a/test/testatomic.c
+++ b/test/testatomic.c
@@ -19,13 +19,13 @@
 */
 
 static
-char *
-tf(SDL_bool tf)
+const char *
+tf(SDL_bool _tf)
 {
-    static char *t = "TRUE";
-    static char *f = "FALSE";
+    static const char *t = "TRUE";
+    static const char *f = "FALSE";
 
-    if (tf)
+    if (_tf)
     {
        return t;
     }
diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c
index be0f15e..96c174f 100644
--- a/test/testautomation_audio.c
+++ b/test/testautomation_audio.c
@@ -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,
                 AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32,
                                 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_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" };
 const int _numAudioChannels = 4;
@@ -697,7 +697,7 @@ int audio_openCloseAndGetAudioStatus()
    SDL_AudioStatus result;
    int i;
    int count;
-   char *device;
+   const char *device;
    SDL_AudioDeviceID id;
    SDL_AudioSpec desired, obtained;
 
@@ -707,7 +707,7 @@ int audio_openCloseAndGetAudioStatus()
    if (count > 0) {
      for (i = 0; i < count; i++) {
        /* Get device name */
-       device = (char *)SDL_GetAudioDeviceName(i, 0);
+       device = SDL_GetAudioDeviceName(i, 0);
        SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
        SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
        if (device == NULL) return TEST_ABORTED;
@@ -721,7 +721,7 @@ int audio_openCloseAndGetAudioStatus()
        desired.userdata=NULL;
 
        /* 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_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id);
        if (id > 1) {
@@ -755,7 +755,7 @@ int audio_lockUnlockOpenAudioDevice()
 {
    int i;
    int count;
-   char *device;
+   const char *device;
    SDL_AudioDeviceID id;
    SDL_AudioSpec desired, obtained;
 
@@ -765,7 +765,7 @@ int audio_lockUnlockOpenAudioDevice()
    if (count > 0) {
      for (i = 0; i < count; i++) {
        /* Get device name */
-       device = (char *)SDL_GetAudioDeviceName(i, 0);
+       device = SDL_GetAudioDeviceName(i, 0);
        SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
        SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
        if (device == NULL) return TEST_ABORTED;
@@ -779,7 +779,7 @@ int audio_lockUnlockOpenAudioDevice()
        desired.userdata=NULL;
 
        /* 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_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id);
        if (id > 1) {
@@ -917,7 +917,7 @@ int audio_openCloseAudioDeviceConnected()
    int result = -1;
    int i;
    int count;
-   char *device;
+   const char *device;
    SDL_AudioDeviceID id;
    SDL_AudioSpec desired, obtained;
 
@@ -927,7 +927,7 @@ int audio_openCloseAudioDeviceConnected()
    if (count > 0) {
      for (i = 0; i < count; i++) {
        /* Get device name */
-       device = (char *)SDL_GetAudioDeviceName(i, 0);
+       device = SDL_GetAudioDeviceName(i, 0);
        SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
        SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
        if (device == NULL) return TEST_ABORTED;
@@ -941,7 +941,7 @@ int audio_openCloseAudioDeviceConnected()
        desired.userdata=NULL;
 
        /* 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_AssertCheck(id > 1, "Validate device ID; expected: >1, got: %i", id);
        if (id > 1) {
diff --git a/test/testautomation_hints.c b/test/testautomation_hints.c
index 2c49110..0d1b7b6 100644
--- a/test/testautomation_hints.c
+++ b/test/testautomation_hints.c
@@ -9,7 +9,7 @@
 
 
 const int _numHintsEnum = 25;
-char* _HintsEnum[] =
+const char* _HintsEnum[] =
   {
     SDL_HINT_ACCELEROMETER_AS_JOYSTICK,
     SDL_HINT_FRAMEBUFFER_ACCELERATION,
@@ -37,7 +37,7 @@ char* _HintsEnum[] =
     SDL_HINT_VIDEO_X11_XVIDMODE,
     SDL_HINT_XINPUT_ENABLED,
   };
-char* _HintsVerbose[] =
+const char* _HintsVerbose[] =
   {
     "SDL_ACCELEROMETER_AS_JOYSTICK",
     "SDL_FRAMEBUFFER_ACCELERATION",
@@ -75,14 +75,14 @@ char* _HintsVerbose[] =
 int
 hints_getHint(void *arg)
 {
-  char *result1;
-  char *result2;
+  const char *result1;
+  const char *result2;
   int 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]);
-    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_AssertCheck(
       (result1 == NULL && result2 == NULL) || (SDL_strcmp(result1, result2) == 0),
@@ -90,7 +90,7 @@ hints_getHint(void *arg)
       (result1 == NULL) ? "null" : result1,
       (result2 == NULL) ? "null" : result2);
   }
-  
+
   return TEST_COMPLETED;
 }
 
@@ -100,52 +100,52 @@ hints_getHint(void *arg)
 int
 hints_setHint(void *arg)
 {
-  char *originalValue;
-  char *value;
-  char *testValue;
+  const char *originalValue;
+  const char *value;
+  const char *testValue;
   SDL_bool result;
   int i, j;
 
-  /* Create random values to set */                    
+  /* Create random values to set */
   value = SDLTest_RandomAsciiStringOfSize(10);
-    
+
   for (i=0; i<_numHintsEnum; i++) {
     /* Capture current value */
-    originalValue = (char *)SDL_GetHint((char*)_HintsEnum[i]);
-    SDLTest_AssertPass("Call to SDL_GetHint(%s)", (char*)_HintsEnum[i]);
+    originalValue = SDL_GetHint(_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 */
     originalValue = originalValue ? SDL_strdup(originalValue) : NULL;
-    
+
     /* Set value (twice) */
     for (j=1; j<=2; j++) {
-      result = SDL_SetHint((char*)_HintsEnum[i], value);
-      SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", (char*)_HintsEnum[i], value, j);
+      result = SDL_SetHint(_HintsEnum[i], value);
+      SDLTest_AssertPass("Call to SDL_SetHint(%s, %s) (iteration %i)", _HintsEnum[i], value, j);
       SDLTest_AssertCheck(
         result == SDL_TRUE || result == SDL_FALSE, 
         "Verify valid result was returned, got: %i",
         (int)result);
-      testValue = (char *)SDL_GetHint((char*)_HintsEnum[i]);
-      SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", (char*)_HintsVerbose[i]);
+      testValue = SDL_GetHint(_HintsEnum[i]);
+      SDLTest_AssertPass("Call to SDL_GetHint(%s) - using string definition", _HintsVerbose[i]);
       SDLTest_AssertCheck(
         (SDL_strcmp(value, testValue) == 0),
         "Verify returned value equals set value; got: testValue='%s' value='%s",
         (testValue == NULL) ? "null" : testValue,
         value);
     }
-      
+
     /* Reset original value */
-    result = SDL_SetHint((char*)_HintsEnum[i], originalValue);
-    SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", (char*)_HintsEnum[i]);
+    result = SDL_SetHint(_HintsEnum[i], originalValue);
+    SDLTest_AssertPass("Call to SDL_SetHint(%s, originalValue)", _HintsEnum[i]);
     SDLTest_AssertCheck(
       result == SDL_TRUE || result == SDL_FALSE, 
       "Verify valid result was returned, got: %i",
       (int)result);
-    SDL_free(originalValue);
+    SDL_free((void *)originalValue);
   }
-  
-  SDL_free(value);
-  
+
+  SDL_free((void *)value);
+
   return TEST_COMPLETED;
 }
 
diff --git a/test/testautomation_keyboard.c b/test/testautomation_keyboard.c
index f415da4..84a7635 100644
--- a/test/testautomation_keyboard.c
+++ b/test/testautomation_keyboard.c
@@ -168,8 +168,8 @@ keyboard_getKeyFromScancode(void *arg)
 int
 keyboard_getKeyName(void *arg)
 {
-   char *result;
-   char *expected;
+   const char *result;
+   const char *expected;
 
    /* Case where key has a 1 character name */
    expected = "3";
@@ -225,8 +225,8 @@ int
 keyboard_getScancodeNameNegative(void *arg)
 {
    SDL_Scancode scancode;
-   char *result;
-   char *expected = "";
+   const char *result;
+   const char *expected = "";
 
    /* Clear error message */
    SDL_ClearError();
@@ -252,8 +252,8 @@ int
 keyboard_getKeyNameNegative(void *arg)
 {
    SDL_Keycode keycode;
-   char *result;
-   char *expected = "";
+   const char *result;
+   const char *expected = "";
 
    /* Unknown keycode */
    keycode = SDLK_UNKNOWN;
@@ -612,7 +612,7 @@ _checkInvalidNameError()
 int
 keyboard_getScancodeFromNameNegative(void *arg)
 {
-   char *name;
+   const char *name;
    SDL_Scancode scancode;
 
    /* Clear error message */
@@ -625,9 +625,9 @@ keyboard_getScancodeFromNameNegative(void *arg)
    if (name == NULL) {
       return TEST_ABORTED;
    }
-   scancode = SDL_GetScancodeFromName((const char *)name);
+   scancode = SDL_GetScancodeFromName(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);
    _checkInvalidNameError();
 
diff --git a/test/testautomation_pixels.c b/test/testautomation_pixels.c
index 2ff2d87..0f6870c 100644
--- a/test/testautomation_pixels.c
+++ b/test/testautomation_pixels.c
@@ -45,7 +45,7 @@ Uint32 _RGBPixelFormats[] =
     SDL_PIXELFORMAT_BGRA8888,
     SDL_PIXELFORMAT_ARGB2101010
   };
-char* _RGBPixelFormatsVerbose[] =
+const char* _RGBPixelFormatsVerbose[] =
   {
     "SDL_PIXELFORMAT_INDEX1LSB",
     "SDL_PIXELFORMAT_INDEX1MSB",
@@ -92,7 +92,7 @@ Uint32 _nonRGBPixelFormats[] =
     SDL_PIXELFORMAT_NV12,
     SDL_PIXELFORMAT_NV21
   };
-char* _nonRGBPixelFormatsVerbose[] =
+const char* _nonRGBPixelFormatsVerbose[] =
   {
     "SDL_PIXELFORMAT_YV12",
     "SDL_PIXELFORMAT_IYUV",
@@ -110,7 +110,7 @@ Uint32 _invalidPixelFormats[] =
     0xfffffffe,
     0xffffffff
   };
-char* _invalidPixelFormatsVerbose[] =
+const char* _invalidPixelFormatsVerbose[] =
   {
     "SDL_PIXELFORMAT_UNKNOWN",
     "SDL_PIXELFORMAT_UNKNOWN"
@@ -237,14 +237,14 @@ pixels_getPixelFormatName(void *arg)
   const char *error;
   int i;
   Uint32 format;
-  char* result;
+  const char *result;
 
   /* Blank/undefined format */
   format = 0;
   SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format);
 
   /* Get name of format */
-  result = (char *)SDL_GetPixelFormatName(format);
+  result = SDL_GetPixelFormatName(format);
   SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
   SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
   if (result != NULL) {
@@ -259,7 +259,7 @@ pixels_getPixelFormatName(void *arg)
     SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format);
 
     /* Get name of format */
-    result = (char *)SDL_GetPixelFormatName(format);
+    result = SDL_GetPixelFormatName(format);
     SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
     SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
     if (result != NULL) {
@@ -275,7 +275,7 @@ pixels_getPixelFormatName(void *arg)
     SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format);
 
     /* Get name of format */
-    result = (char *)SDL_GetPixelFormatName(format);
+    result = SDL_GetPixelFormatName(format);
     SDLTest_AssertPass("Call to SDL_GetPixelFormatName()");
     SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
     if (result != NULL) {
@@ -292,7 +292,7 @@ pixels_getPixelFormatName(void *arg)
   SDLTest_AssertPass("Call to SDL_ClearError()");
   for (i = 0; i < _numInvalidPixelFormats; i++) {
     format = _invalidPixelFormats[i];
-    result = (char *)SDL_GetPixelFormatName(format);
+    result = SDL_GetPixelFormatName(format);
     SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%u)", format);
     SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
     if (result != NULL) {
diff --git a/test/testiconv.c b/test/testiconv.c
index 29c54e6..c05fa41 100644
--- a/test/testiconv.c
+++ b/test/testiconv.c
@@ -42,6 +42,8 @@ main(int argc, char *argv[])
         "UCS4",
         "UCS-4",
     };
+
+    const char * fname;
     char buffer[BUFSIZ];
     char *ucs4;
     char *test[2];
@@ -52,12 +54,10 @@ main(int argc, char *argv[])
     /* Enable standard application logging */
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
-    if (!argv[1]) {
-        argv[1] = "utf8.txt";
-    }
-    file = fopen(argv[1], "rb");
+    fname = (argc < 2) ? "utf8.txt" : argv[1];
+    file = fopen(fname, "rb");
     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);
     }
 
diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c
index b2b5232..130e4d1 100644
--- a/test/testmultiaudio.c
+++ b/test/testmultiaudio.c
@@ -180,13 +180,11 @@ main(int argc, char **argv)
     if (devcount < 1) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n");
     } else {
-        if (argv[1] == NULL) {
-            argv[1] = "sample.wav";
-        }
+        const char *file = (argc < 2) ? "sample.wav" : argv[1];
 
         /* Load the wave file into memory */
-        if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1],
+        if (SDL_LoadWAV(file, &spec, &sound, &soundlen) == NULL) {
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file,
                     SDL_GetError());
         } else {
             test_multi_audio(devcount);
diff --git a/test/testnative.c b/test/testnative.c
index 21aee04..ced04ab 100644
--- a/test/testnative.c
+++ b/test/testnative.c
@@ -53,7 +53,7 @@ quit(int rc)
 }
 
 SDL_Texture *
-LoadSprite(SDL_Renderer *renderer, char *file)
+LoadSprite(SDL_Renderer *renderer, const char *file)
 {
     SDL_Surface *temp;
     SDL_Texture *sprite;
diff --git a/test/testpower.c b/test/testpower.c
index 2e36966..7b41f43 100644
--- a/test/testpower.c
+++ b/test/testpower.c
@@ -19,7 +19,7 @@ report_power(void)
 {
     int seconds, percent;
     const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent);
-    char *statestr = NULL;
+    const char *statestr = NULL;
 
     SDL_Log("SDL-reported power info...\n");
     switch (state) {
@@ -55,7 +55,7 @@ report_power(void)
         SDL_Log("Time left: unknown\n");
     } else {
         SDL_Log("Time left: %d minutes, %d seconds\n", (int) (seconds / 60),
-               (int) (seconds % 60));
+                (int) (seconds % 60));
     }
 }
 
diff --git a/test/testrendertarget.c b/test/testrendertarget.c
index 5366d50..021e727 100644
--- a/test/testrendertarget.c
+++ b/test/testrendertarget.c
@@ -46,7 +46,7 @@ quit(int rc)
 }
 
 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_Texture *texture;
diff --git a/test/testscale.c b/test/testscale.c
index 5ce882d..966b169 100644
--- a/test/testscale.c
+++ b/test/testscale.c
@@ -47,7 +47,7 @@ quit(int rc)
 }
 
 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_Texture *texture;
diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c
index 6d10249..23c8a59 100644
--- a/test/testspriteminimal.c
+++ b/test/testspriteminimal.c
@@ -43,7 +43,7 @@ quit(int rc)
 }
 
 int
-LoadSprite(char *file)
+LoadSprite(const char *file)
 {
     SDL_Surface *temp;
 
diff --git a/test/testviewport.c b/test/testviewport.c
index 0c8f255..775892b 100644
--- a/test/testviewport.c
+++ b/test/testviewport.c
@@ -43,7 +43,7 @@ quit(int rc)
 }
 
 int
-LoadSprite(char *file, SDL_Renderer *renderer)
+LoadSprite(const char *file, SDL_Renderer *renderer)
 {
     SDL_Surface *temp;