From 3166cfd54ce85bdfed3c61dd5c405b4b328bff1b Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 18:53:23 +0200 Subject: [PATCH 01/19] misc: Fix const correctness issue in M_BaseName --- src/m_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_misc.c b/src/m_misc.c index 27a31099..1f8117be 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -291,7 +291,7 @@ char *M_DirName(const char *path) // allocated. const char *M_BaseName(const char *path) { - char *p; + const char *p; p = strrchr(path, DIR_SEPARATOR); if (p == NULL) From efc804dc55aabdb068dce51f05fbd04ec4aacdbe Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 18:56:35 +0200 Subject: [PATCH 02/19] setup: Make AddCmdLineParameter format parameter const --- src/setup/execute.c | 2 +- src/setup/execute.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setup/execute.c b/src/setup/execute.c index 7a3faa21..f2377f61 100644 --- a/src/setup/execute.c +++ b/src/setup/execute.c @@ -130,7 +130,7 @@ execute_context_t *NewExecuteContext(void) return result; } -void AddCmdLineParameter(execute_context_t *context, char *s, ...) +void AddCmdLineParameter(execute_context_t *context, const char *s, ...) { va_list args; diff --git a/src/setup/execute.h b/src/setup/execute.h index f3e90e3c..21530f14 100644 --- a/src/setup/execute.h +++ b/src/setup/execute.h @@ -28,7 +28,7 @@ typedef struct execute_context_s execute_context_t; #define IWAD_CHEX (1 << 5) /* chex.wad */ execute_context_t *NewExecuteContext(void); -void AddCmdLineParameter(execute_context_t *context, char *s, ...) PRINTF_ATTR(2, 3); +void AddCmdLineParameter(execute_context_t *context, const char *s, ...) PRINTF_ATTR(2, 3); void PassThroughArguments(execute_context_t *context); int ExecuteDoom(execute_context_t *context); int FindInstalledIWADs(void); From 3171e5189ec9e1102cf0779ad5a3f7a231489d57 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 18:57:40 +0200 Subject: [PATCH 03/19] setup: Fix const correctness issue in TempFile --- src/setup/execute.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/execute.c b/src/setup/execute.c index f2377f61..e3a939c6 100644 --- a/src/setup/execute.c +++ b/src/setup/execute.c @@ -56,7 +56,7 @@ struct execute_context_s static char *TempFile(char *s) { - char *tempdir; + const char *tempdir; #ifdef _WIN32 // Check the TEMP environment variable to find the location. From 04535a58e80e78c32015a3af212c01c34e3e60bc Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:00:00 +0200 Subject: [PATCH 04/19] setup: Make TempFile parameter const --- src/setup/execute.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/execute.c b/src/setup/execute.c index e3a939c6..9293d5b0 100644 --- a/src/setup/execute.c +++ b/src/setup/execute.c @@ -54,7 +54,7 @@ struct execute_context_s // Returns the path to a temporary file of the given name, stored // inside the system temporary directory. -static char *TempFile(char *s) +static char *TempFile(const char *s) { const char *tempdir; From ed72f3fc752d255bc54c982c7709980fe8e8fa94 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:01:12 +0200 Subject: [PATCH 05/19] setup: Make AddJoystickControl label parameter const --- src/setup/joystick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/joystick.c b/src/setup/joystick.c index b8600ef5..83d0462f 100644 --- a/src/setup/joystick.c +++ b/src/setup/joystick.c @@ -972,7 +972,7 @@ static void CalibrateJoystick(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) // GUI // -static void AddJoystickControl(TXT_UNCAST_ARG(table), char *label, int *var) +static void AddJoystickControl(TXT_UNCAST_ARG(table), const char *label, int *var) { TXT_CAST_ARG(txt_table_t, table); txt_joystick_input_t *joy_input; From e0b005e61ac8fec632969c174d07f2c9652c0b4e Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:02:29 +0200 Subject: [PATCH 06/19] setup: Make AddKeyControl name parameter const --- src/setup/keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/keyboard.c b/src/setup/keyboard.c index b88fe92d..5fb2378d 100644 --- a/src/setup/keyboard.c +++ b/src/setup/keyboard.c @@ -146,7 +146,7 @@ static void KeySetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable)) // Add a label and keyboard input to the specified table. -static void AddKeyControl(TXT_UNCAST_ARG(table), char *name, int *var) +static void AddKeyControl(TXT_UNCAST_ARG(table), const char *name, int *var) { TXT_CAST_ARG(txt_table_t, table); txt_key_input_t *key_input; From f766714b811f7957754443db4766257bd01422ea Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:04:12 +0200 Subject: [PATCH 07/19] setup: Make AddSectionLabel title parameter const --- src/setup/keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/keyboard.c b/src/setup/keyboard.c index 5fb2378d..80a06278 100644 --- a/src/setup/keyboard.c +++ b/src/setup/keyboard.c @@ -158,7 +158,7 @@ static void AddKeyControl(TXT_UNCAST_ARG(table), const char *name, int *var) TXT_SignalConnect(key_input, "set", KeySetCallback, var); } -static void AddSectionLabel(TXT_UNCAST_ARG(table), char *title, +static void AddSectionLabel(TXT_UNCAST_ARG(table), const char *title, boolean add_space) { TXT_CAST_ARG(txt_table_t, table); From ea34b7bcf061858218a86a09696ce21deff757f4 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:05:40 +0200 Subject: [PATCH 08/19] setup: Make GetExecutableName return value const --- src/setup/mode.c | 2 +- src/setup/mode.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setup/mode.c b/src/setup/mode.c index 15841530..ae7b21bc 100644 --- a/src/setup/mode.c +++ b/src/setup/mode.c @@ -367,7 +367,7 @@ void SetupMission(GameSelectCallback callback) } } -char *GetExecutableName(void) +const char *GetExecutableName(void) { return executable; } diff --git a/src/setup/mode.h b/src/setup/mode.h index 0ae8a2cb..838bbd02 100644 --- a/src/setup/mode.h +++ b/src/setup/mode.h @@ -23,7 +23,7 @@ extern GameMission_t gamemission; void SetupMission(GameSelectCallback callback); void InitBindings(void); -char *GetExecutableName(void); +const char *GetExecutableName(void); char *GetGameTitle(void); const iwad_t **GetIwads(void); From 6e18c2ecdcf43654a202e774f1def3266292be93 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:06:36 +0200 Subject: [PATCH 09/19] setup: Make GetGameTitle return value const --- src/setup/mode.c | 2 +- src/setup/mode.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setup/mode.c b/src/setup/mode.c index ae7b21bc..8af31038 100644 --- a/src/setup/mode.c +++ b/src/setup/mode.c @@ -372,7 +372,7 @@ const char *GetExecutableName(void) return executable; } -char *GetGameTitle(void) +const char *GetGameTitle(void) { return game_title; } diff --git a/src/setup/mode.h b/src/setup/mode.h index 838bbd02..2687a488 100644 --- a/src/setup/mode.h +++ b/src/setup/mode.h @@ -24,7 +24,7 @@ extern GameMission_t gamemission; void SetupMission(GameSelectCallback callback); void InitBindings(void); const char *GetExecutableName(void); -char *GetGameTitle(void); +const char *GetGameTitle(void); const iwad_t **GetIwads(void); #endif /* #ifndef SETUP_MODE_H */ From 80816d072506256d38cf2c2cf796adc86c489dff Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:07:54 +0200 Subject: [PATCH 10/19] setup: Make AddMouseControl label parameter const --- src/setup/mouse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/mouse.c b/src/setup/mouse.c index 1c27d5a0..e25cd990 100644 --- a/src/setup/mouse.c +++ b/src/setup/mouse.c @@ -67,7 +67,7 @@ static void MouseSetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable)) } } -static void AddMouseControl(TXT_UNCAST_ARG(table), char *label, int *var) +static void AddMouseControl(TXT_UNCAST_ARG(table), const char *label, int *var) { TXT_CAST_ARG(txt_table_t, table); txt_mouse_input_t *mouse_input; From 94f59664ca51c0763beffe7f19f6094995bb9748 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:09:42 +0200 Subject: [PATCH 11/19] setup: Make StartGameMenu window_title parameter const --- src/setup/multiplayer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index 809d70b2..f247b5ea 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -705,7 +705,7 @@ static txt_dropdown_list_t *GameTypeDropdown(void) // and the single player warp menu. The parameters specify // the window title and whether to display multiplayer options. -static void StartGameMenu(char *window_title, int multiplayer) +static void StartGameMenu(const char *window_title, int multiplayer) { txt_window_t *window; txt_widget_t *iwad_selector; From fa22df1349a83102763a98470742db57b45ddc63 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:11:14 +0200 Subject: [PATCH 12/19] setup: Make ServerQueryWindow title parameter const --- src/setup/multiplayer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index f247b5ea..61d34d35 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -984,7 +984,7 @@ static void QueryWindowClosed(TXT_UNCAST_ARG(window), void *unused) TXT_SetPeriodicCallback(NULL, NULL, 0); } -static void ServerQueryWindow(char *title) +static void ServerQueryWindow(const char *title) { txt_table_t *results_table; From 0ec616b898ffa715d0ca27cfad6ffd4510bbb885 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:12:59 +0200 Subject: [PATCH 13/19] setup: Make CalibrationLabel return value const --- src/setup/txt_joyaxis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/txt_joyaxis.c b/src/setup/txt_joyaxis.c index 498e5294..a863704d 100644 --- a/src/setup/txt_joyaxis.c +++ b/src/setup/txt_joyaxis.c @@ -32,7 +32,7 @@ #define JOYSTICK_AXIS_WIDTH 20 -static char *CalibrationLabel(txt_joystick_axis_t *joystick_axis) +static const char *CalibrationLabel(txt_joystick_axis_t *joystick_axis) { switch (joystick_axis->config_stage) { From 5a7cb09524ad939936d8788dc5dfe9944bdcee03 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:15:41 +0200 Subject: [PATCH 14/19] setup: Make joystick_config_t name member const --- src/setup/joystick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/joystick.c b/src/setup/joystick.c index 83d0462f..ed9d1a84 100644 --- a/src/setup/joystick.c +++ b/src/setup/joystick.c @@ -33,7 +33,7 @@ typedef struct { - char *name; // Config file name + const char *name; // Config file name int value; } joystick_config_t; From 0ad55d18f3275b0bf32ffad90198e300f7c005b9 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:16:27 +0200 Subject: [PATCH 15/19] setup: Make known_joystick_t name member const --- src/setup/joystick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/joystick.c b/src/setup/joystick.c index ed9d1a84..07388735 100644 --- a/src/setup/joystick.c +++ b/src/setup/joystick.c @@ -39,7 +39,7 @@ typedef struct typedef struct { - char *name; + const char *name; int axes, buttons, hats; const joystick_config_t *configs; } known_joystick_t; From cf2166483908b35d607e2431549cc31410283a8d Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:18:51 +0200 Subject: [PATCH 16/19] setup: Fix const correctness issue in GetLaunchButton --- src/setup/mainmenu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/mainmenu.c b/src/setup/mainmenu.c index 62206b39..03116f62 100644 --- a/src/setup/mainmenu.c +++ b/src/setup/mainmenu.c @@ -181,7 +181,7 @@ static void LaunchDoom(void *unused1, void *unused2) static txt_button_t *GetLaunchButton(void) { - char *label; + const char *label; switch (gamemission) { From 9209085d85377bc4b362f8dbd8b76b05b83c3134 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:19:29 +0200 Subject: [PATCH 17/19] setup: Make game_title variable const --- src/setup/mode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/mode.c b/src/setup/mode.c index 8af31038..2cd23d82 100644 --- a/src/setup/mode.c +++ b/src/setup/mode.c @@ -106,7 +106,7 @@ static int screenblocks = 9; static int detailLevel = 0; static char *savedir = NULL; static char *executable = NULL; -static char *game_title = "Doom"; +static const char *game_title = "Doom"; static char *back_flat = "F_PAVE01"; static int comport = 0; static char *nickname = NULL; From 8f82960fbef90ff0fbe6606d43d862dd8735843b Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:22:40 +0200 Subject: [PATCH 18/19] setup: Fix const correctness issue in SetChatMacroDefaults --- src/setup/multiplayer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index 61d34d35..3faaaca1 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -1067,7 +1067,7 @@ void JoinMultiGame(TXT_UNCAST_ARG(widget), void *user_data) void SetChatMacroDefaults(void) { int i; - char *defaults[] = + const char *const defaults[] = { HUSTR_CHATMACRO0, HUSTR_CHATMACRO1, From c5d8067d38e0c356677eb996cc09dd45a580b52d Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 22 Jan 2019 19:26:59 +0200 Subject: [PATCH 19/19] setup: Make mission_config_t string members const --- src/setup/mode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/setup/mode.c b/src/setup/mode.c index 2cd23d82..dbe667df 100644 --- a/src/setup/mode.c +++ b/src/setup/mode.c @@ -44,13 +44,13 @@ static const iwad_t **iwads; typedef struct { - char *label; + const char *label; GameMission_t mission; int mask; - char *name; - char *config_file; - char *extra_config_file; - char *executable; + const char *name; + const char *config_file; + const char *extra_config_file; + const char *executable; } mission_config_t; // Default mission to fall back on, if no IWADs are found at all: