From 7df03158d31945d1491d4db51b85dd85f019c3e9 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 e1df747..4268373 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 7e04fbe..2ba899d 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 2fc6dae..f1c4b2a 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 5f1cff4..bc429a7 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 b06d0fe..01ab8ed 100644
--- a/test/testoverlay.c
+++ b/test/testoverlay.c
@@ -324,7 +324,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
@@ -477,7 +477,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 2ad4916..efa0732 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 b777dbb..f83de9a 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 261ea99..2fcbd10 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 aef4e60..0486156 100644
--- a/test/testwm.c
+++ b/test/testwm.c
@@ -66,7 +66,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;
@@ -348,6 +348,9 @@ int SDLCALL FilterEvents(const SDL_Event *event)
}
}
+
+static char testtitle[] = "Testing 1.. 2.. 3...";
+
int main(int argc, char *argv[])
{
SDL_Event event;
@@ -414,7 +417,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 c704b30..761fdbc 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;