summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-09-18 20:07:12 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-10-02 08:20:10 -0400
commit5b0506e9de356f915138711b62f3e414a8c1b2bb (patch)
tree7d42f57c5133d14efe35b05fa42b54bcfa962350
parent420fb1163c526cdbfba4b131b8c33824f401cd15 (diff)
downloadrockbox-5b0506e9de.tar.gz
rockbox-5b0506e9de.zip
gui: Constify list title text
Use const char* pointers for list titles. Only one debug menu actually modifies the title, and in that case it's legal to cast away const because the title points to a known mutable buffer on the stack. Change-Id: Idb8ab307b9a6ec23a93d8420c5e19fafd9f59c30
-rw-r--r--apps/debug_menu.c3
-rw-r--r--apps/gui/bitmap/list.c2
-rw-r--r--apps/gui/list.c2
-rw-r--r--apps/gui/list.h8
-rw-r--r--apps/gui/statusbar-skinned.c4
-rw-r--r--apps/gui/statusbar-skinned.h2
-rw-r--r--apps/plugin.h2
-rw-r--r--apps/plugins/lib/printcell_helper.c2
8 files changed, 13 insertions, 12 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index f510597ad2..9c911eea4d 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1247,7 +1247,8 @@ static int disk_callback(int btn, struct gui_synclist *lists)
int *cardnum = (int*)lists->data;
unsigned char card_name[6];
unsigned char pbuf[32];
- char *title = lists->title;
+ /* Casting away const is safe; the buffer is defined as non-const. */
+ char *title = (char *)lists->title;
static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
static const unsigned char * const kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" };
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 53874a8dfa..b2987e9853 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -103,7 +103,7 @@ static void _default_listdraw_fn(struct list_putlineinfo_t *list_info)
bool show_cursor = list_info->show_cursor;
bool have_icons = list_info->have_icons;
struct line_desc *linedes = list_info->linedes;
- char *dsp_text = list_info->dsp_text;
+ const char *dsp_text = list_info->dsp_text;
if (is_title)
{
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 29c80574c2..df5df22ca1 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -490,7 +490,7 @@ void gui_list_screen_scroll_out_of_view(bool enable)
* both the title and icon. Use NOICON if there is no icon.
*/
void gui_synclist_set_title(struct gui_synclist * gui_list,
- char * title, enum themable_icons icon)
+ const char * title, enum themable_icons icon)
{
gui_list->title = title;
gui_list->title_icon = icon;
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 4dc83a1b27..2df33b7541 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -96,7 +96,7 @@ struct list_putlineinfo_t {
struct viewport *vp;
struct line_desc *linedes;
struct gui_synclist * list;
- char *dsp_text;
+ const char *dsp_text;
bool is_selected;
bool is_title;
@@ -185,7 +185,7 @@ struct gui_synclist
/* The data that will be passed to the callback function YOU implement */
void * data;
/* The optional title, set to NULL for none */
- char * title;
+ const char * title;
/* Optional title icon */
enum themable_icons title_icon;
@@ -233,7 +233,7 @@ extern void gui_synclist_select_item(struct gui_synclist * lists,
extern void gui_synclist_add_item(struct gui_synclist * lists);
extern void gui_synclist_del_item(struct gui_synclist * lists);
extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll);
-extern void gui_synclist_set_title(struct gui_synclist * lists, char * title,
+extern void gui_synclist_set_title(struct gui_synclist * lists, const char * title,
enum themable_icons icon);
extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
bool hide);
@@ -301,7 +301,7 @@ extern bool list_do_action(int context, int timeout,
**/
struct simplelist_info {
- char *title; /* title to show on the list */
+ const char *title; /* title to show on the list */
int count; /* number of items in the list, each item is selection_size high */
int selection_size; /* list selection size, usually 1 */
bool hide_selection;
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c
index fd695bf6b6..cda3ec29c9 100644
--- a/apps/gui/statusbar-skinned.c
+++ b/apps/gui/statusbar-skinned.c
@@ -49,11 +49,11 @@
static int update_delay = DEFAULT_UPDATE_DELAY;
static bool sbs_has_title[NB_SCREENS];
-static char* sbs_title[NB_SCREENS];
+static const char* sbs_title[NB_SCREENS];
static enum themable_icons sbs_icon[NB_SCREENS];
static bool sbs_loaded[NB_SCREENS] = { false };
-bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen)
+bool sb_set_title_text(const char* title, enum themable_icons icon, enum screen_type screen)
{
sbs_title[screen] = title;
/* Icon_NOICON == -1 which the skin engine wants at position 1, so + 2 */
diff --git a/apps/gui/statusbar-skinned.h b/apps/gui/statusbar-skinned.h
index 3ed36f1a84..7f4d93e67e 100644
--- a/apps/gui/statusbar-skinned.h
+++ b/apps/gui/statusbar-skinned.h
@@ -39,7 +39,7 @@ struct viewport *sb_skin_get_info_vp(enum screen_type screen);
void sb_skin_update(enum screen_type screen, bool force);
void sb_skin_set_update_delay(int delay);
-bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen);
+bool sb_set_title_text(const char* title, enum themable_icons icon, enum screen_type screen);
void sb_skin_has_title(enum screen_type screen);
const char* sb_get_title(enum screen_type screen);
enum themable_icons sb_get_icon(enum screen_type screen);
diff --git a/apps/plugin.h b/apps/plugin.h
index a487f64168..e35909f409 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -387,7 +387,7 @@ struct plugin_api {
void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll);
bool (*gui_synclist_do_button)(struct gui_synclist * lists,
int *action, enum list_wrap wrap);
- void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title,
+ void (*gui_synclist_set_title)(struct gui_synclist *lists, const char* title,
enum themable_icons icon);
enum yesno_res (*gui_syncyesno_run)(const struct text_message * main_message,
const struct text_message * yes_message,
diff --git a/apps/plugins/lib/printcell_helper.c b/apps/plugins/lib/printcell_helper.c
index 328f74e318..f34636585e 100644
--- a/apps/plugins/lib/printcell_helper.c
+++ b/apps/plugins/lib/printcell_helper.c
@@ -234,7 +234,7 @@ static void printcell_listdraw_fn(struct list_putlineinfo_t *list_info)
bool show_cursor = list_info->show_cursor;
bool have_icons = list_info->have_icons;
struct line_desc *linedes = list_info->linedes;
- char *dsp_text = list_info->dsp_text;
+ const char *dsp_text = list_info->dsp_text;
struct viewport *vp = list_info->vp;
int line = list_info->line;