SDL-1.2: tests: silenced several -Wwrite-strings warnings.

From a7037311cf8228d2d960c4b7d32f9bb7251ccd4f Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 17 Nov 2021 11:35:02 +0300
Subject: [PATCH] tests:  silenced several -Wwrite-strings warnings.

---
 test/loopwave.c    | 7 +++----
 test/testalpha.c   | 2 +-
 test/testcdrom.c   | 2 +-
 test/testiconv.c   | 7 +++----
 test/testoverlay.c | 4 ++--
 test/testpalette.c | 2 +-
 test/testsprite.c  | 2 +-
 test/testwin.c     | 2 +-
 test/testwm.c      | 7 +++++--
 test/threadwin.c   | 2 +-
 10 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/test/loopwave.c b/test/loopwave.c
index e1df747a7..426837377 100644
--- a/test/loopwave.c
+++ b/test/loopwave.c
@@ -63,17 +63,16 @@ void poked(int sig)
 int main(int argc, char *argv[])
 {
 	char name[32];
+	const char *file;
 
 	/* Load the SDL library */
 	if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) {
 		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
 		return(1);
 	}
-	if ( argv[1] == NULL ) {
-		argv[1] = "sample.wav";
-	}
+	file = (argc < 2)? "sample.wav" : argv[1];
 	/* Load the wave file into memory */
-	if ( SDL_LoadWAV(argv[1],
+	if ( SDL_LoadWAV(file,
 			&wave.spec, &wave.sound, &wave.soundlen) == NULL ) {
 		fprintf(stderr, "Couldn't load %s: %s\n",
 						argv[1], SDL_GetError());
diff --git a/test/testalpha.c b/test/testalpha.c
index 7e04fbe08..2ba899d03 100644
--- a/test/testalpha.c
+++ b/test/testalpha.c
@@ -178,7 +178,7 @@ static SDL_Rect    position;
 static int         x_vel, y_vel;
 static int	   alpha_vel;
 
-int LoadSprite(SDL_Surface *screen, char *file)
+int LoadSprite(SDL_Surface *screen, const char *file)
 {
 	SDL_Surface *converted;
 
diff --git a/test/testcdrom.c b/test/testcdrom.c
index 2fc6daeb9..f1c4b2a34 100644
--- a/test/testcdrom.c
+++ b/test/testcdrom.c
@@ -51,7 +51,7 @@ static void ListTracks(SDL_CD *cdrom)
 {
 	int i;
 	int m, s, f;
-	char* trtype;
+	const char *trtype;
 
 	SDL_CDStatus(cdrom);
 	printf("Drive tracks: %d\n", cdrom->numtracks);
diff --git a/test/testiconv.c b/test/testiconv.c
index 5f1cff471..bc429a770 100644
--- a/test/testiconv.c
+++ b/test/testiconv.c
@@ -29,6 +29,7 @@ int main(int argc, char *argv[])
 		"UCS4",
 		"UCS-4",
 	};
+	const char *fname;
 	char buffer[BUFSIZ];
 	char *ucs4;
 	char *test[2];
@@ -36,10 +37,8 @@ int main(int argc, char *argv[])
 	FILE *file;
 	int errors = 0;
 
-	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 ) {
 		fprintf(stderr, "Unable to open %s\n", argv[1]);
 		return (1);
diff --git a/test/testoverlay.c b/test/testoverlay.c
index da53f9ea0..0afae05dc 100644
--- a/test/testoverlay.c
+++ b/test/testoverlay.c
@@ -325,7 +325,7 @@ int main(int argc, char **argv)
 	int delay;
 	int desired_bpp;
 	Uint32 video_flags, overlay_format;
-	char *bmpfile;
+	const char *bmpfile;
 #ifdef BENCHMARK_SDL
 	Uint32 then, now;
 #endif
@@ -480,7 +480,7 @@ int main(int argc, char **argv)
 	SDL_WM_SetCaption("SDL test overlay", "testoverlay");
 
 	/* Load picture */
-	bmpfile=(argv[1]?argv[1]:"sample.bmp");
+	bmpfile = argv[1] ? argv[1]:"sample.bmp";
 	pic = SDL_LoadBMP(bmpfile);
 	if ( pic == NULL ) {
 		fprintf(stderr, "Couldn't load %s: %s\n", bmpfile,
diff --git a/test/testpalette.c b/test/testpalette.c
index 2ad49164a..efa07327c 100644
--- a/test/testpalette.c
+++ b/test/testpalette.c
@@ -61,7 +61,7 @@ static void quit(int rc)
 	exit(rc);
 }
 
-static void sdlerr(char *when)
+static void sdlerr(const char *when)
 {
     fprintf(stderr, "SDL error: %s: %s\n", when, SDL_GetError());
     quit(1);
diff --git a/test/testsprite.c b/test/testsprite.c
index 6d9e0a859..da6537bce 100644
--- a/test/testsprite.c
+++ b/test/testsprite.c
@@ -28,7 +28,7 @@ static void quit(int rc)
 	exit(rc);
 }
 
-int LoadSprite(char *file)
+int LoadSprite(const char *file)
 {
 	SDL_Surface *temp;
 
diff --git a/test/testwin.c b/test/testwin.c
index 261ea9942..2fcbd1084 100644
--- a/test/testwin.c
+++ b/test/testwin.c
@@ -18,7 +18,7 @@ static void quit(int rc)
 	exit(rc);
 }
 
-void DrawPict(SDL_Surface *screen, char *bmpfile,
+void DrawPict(SDL_Surface *screen, const char *bmpfile,
 					int speedy, int flip, int nofade)
 {
 	SDL_Surface *picture;
diff --git a/test/testwm.c b/test/testwm.c
index 9c3c0506b..d971589ec 100644
--- a/test/testwm.c
+++ b/test/testwm.c
@@ -60,7 +60,7 @@ int SetVideoMode(int w, int h)
 	return(0);
 }
 
-SDL_Surface *LoadIconSurface(char *file, Uint8 **maskp)
+SDL_Surface *LoadIconSurface(const char *file, Uint8 **maskp)
 {
 	SDL_Surface *icon;
 	Uint8       *pixels;
@@ -330,6 +330,9 @@ int SDLCALL FilterEvents(const SDL_Event *event)
 	}
 }
 
+
+static char testtitle[] = "Testing  1.. 2.. 3...";
+
 int main(int argc, char *argv[])
 {
 	SDL_Event event;
@@ -396,7 +399,7 @@ int main(int argc, char *argv[])
 
 	/* Set the title bar */
 	if ( argv[1] == NULL )
-		title = "Testing  1.. 2.. 3...";
+		title = testtitle;
 	else
 		title = argv[1];
 	SDL_WM_SetCaption(title, "testwm");
diff --git a/test/threadwin.c b/test/threadwin.c
index c704b30d1..761fdbc8f 100644
--- a/test/threadwin.c
+++ b/test/threadwin.c
@@ -21,7 +21,7 @@ static void quit(int rc)
 	exit(rc);
 }
 
-SDL_Surface *LoadIconSurface(char *file, Uint8 **maskp)
+SDL_Surface *LoadIconSurface(const char *file, Uint8 **maskp)
 {
 	SDL_Surface *icon;
 	Uint8       *pixels;