Commit 8a355116d1a846274753ed3cf5506ac45bd28657

Ozkan Sezer 2021-12-21T20:01:02

silence -Wwrite-strings in visualtest

diff --git a/visualtest/include/SDL_visualtest_action_configparser.h b/visualtest/include/SDL_visualtest_action_configparser.h
index 490c8a3..40481f3 100644
--- a/visualtest/include/SDL_visualtest_action_configparser.h
+++ b/visualtest/include/SDL_visualtest_action_configparser.h
@@ -137,7 +137,7 @@ int SDLVisualTest_InsertIntoActionQueue(SDLVisualTest_ActionQueue* queue,
  *
  * \return 1 on success, 0 on failure.
  */
-int SDLVisualTest_ParseActionConfig(char* file, SDLVisualTest_ActionQueue* queue);
+int SDLVisualTest_ParseActionConfig(const char* file, SDLVisualTest_ActionQueue* queue);
 
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
diff --git a/visualtest/src/action_configparser.c b/visualtest/src/action_configparser.c
index 4580343..f3b1afd 100644
--- a/visualtest/src/action_configparser.c
+++ b/visualtest/src/action_configparser.c
@@ -259,7 +259,7 @@ SDLVisualTest_InsertIntoActionQueue(SDLVisualTest_ActionQueue* queue,
 }
 
 int
-SDLVisualTest_ParseActionConfig(char* file, SDLVisualTest_ActionQueue* queue)
+SDLVisualTest_ParseActionConfig(const char* file, SDLVisualTest_ActionQueue* queue)
 {
     char line[MAX_ACTION_LINE_LENGTH];
     SDLVisualTest_RWHelperBuffer buffer;
diff --git a/visualtest/src/harness_argparser.c b/visualtest/src/harness_argparser.c
index b7f9d0d..8bc5706 100644
--- a/visualtest/src/harness_argparser.c
+++ b/visualtest/src/harness_argparser.c
@@ -19,7 +19,7 @@
 
 /* String compare s1 and s2 ignoring leading hyphens */
 static int
-StrCaseCmpIgnoreHyphen(char* s1, char* s2)
+StrCaseCmpIgnoreHyphen(const char* s1, const char* s2)
 {
     /* treat NULL pointer as empty strings */
     if(!s1)
@@ -199,7 +199,7 @@ ParseArg(char** argv, int index, SDLVisualTest_HarnessState* state)
 
 /* TODO: Trailing/leading spaces and spaces between equals sign not supported. */
 static int
-ParseConfig(char* file, SDLVisualTest_HarnessState* state)
+ParseConfig(const char* file, SDLVisualTest_HarnessState* state)
 {
     SDL_RWops* rw;
     SDLVisualTest_RWHelperBuffer buffer;
diff --git a/visualtest/src/linux/linux_process.c b/visualtest/src/linux/linux_process.c
index d81a32e..b93f340 100644
--- a/visualtest/src/linux/linux_process.c
+++ b/visualtest/src/linux/linux_process.c
@@ -20,11 +20,11 @@
 #include <errno.h>
 
 static void
-LogLastError(char* str)
+LogLastError(const char* str)
 {
-    char* error = (char*)strerror(errno);
+    const char* error = strerror(errno);
     if(!str || !error)
-    	return;
+        return;
     SDLTest_LogError("%s: %s", str, error);
 }
 
diff --git a/visualtest/src/testharness.c b/visualtest/src/testharness.c
index e93b095..db3ca55 100644
--- a/visualtest/src/testharness.c
+++ b/visualtest/src/testharness.c
@@ -49,8 +49,8 @@ static SDLVisualTest_ActionNode* current; /* the current action being performed 
 static SDL_TimerID action_timer, kill_timer;
 
 /* returns a char* to be passed as the format argument of a printf-style function. */
-static char*
-usage()
+static const char*
+usage(void)
 {
     return "Usage: \n%s --sutapp xyz"
            " [--sutargs abc | --parameter-config xyz.parameters"
@@ -462,7 +462,7 @@ main(int argc, char* argv[])
 
     if(state.sut_config.num_options > 0)
     {
-        char* variator_name = state.variator_type == SDL_VARIATOR_RANDOM ?
+        const char* variator_name = (state.variator_type == SDL_VARIATOR_RANDOM) ?
                               "RANDOM" : "EXHAUSTIVE";
         if(state.num_variations > 0)
             SDLTest_Log("Testing SUT with variator: %s for %d variations",
diff --git a/visualtest/src/windows/windows_process.c b/visualtest/src/windows/windows_process.c
index 346d605..e7e265c 100644
--- a/visualtest/src/windows/windows_process.c
+++ b/visualtest/src/windows/windows_process.c
@@ -15,7 +15,7 @@
 #if defined(__WIN32__)
 
 void
-LogLastError(char* str)
+LogLastError(const char* str)
 {
     LPVOID buffer;
     DWORD dw = GetLastError();
diff --git a/visualtest/src/windows/windows_screenshot.c b/visualtest/src/windows/windows_screenshot.c
index c8fd1e4..6d9189d 100644
--- a/visualtest/src/windows/windows_screenshot.c
+++ b/visualtest/src/windows/windows_screenshot.c
@@ -16,7 +16,7 @@
 #if defined(__WIN32__)
 #include <windows.h>
 
-void LogLastError(char* str);
+void LogLastError(const char* str);
 
 static int img_num;
 static SDL_ProcessInfo screenshot_pinfo;