diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-09-18 20:07:12 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-10-02 08:20:10 -0400 |
commit | 5b0506e9de356f915138711b62f3e414a8c1b2bb (patch) | |
tree | 7d42f57c5133d14efe35b05fa42b54bcfa962350 /apps | |
parent | 420fb1163c526cdbfba4b131b8c33824f401cd15 (diff) | |
download | rockbox-5b0506e9de356f915138711b62f3e414a8c1b2bb.tar.gz rockbox-5b0506e9de356f915138711b62f3e414a8c1b2bb.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
Diffstat (limited to 'apps')
-rw-r--r-- | apps/debug_menu.c | 3 | ||||
-rw-r--r-- | apps/gui/bitmap/list.c | 2 | ||||
-rw-r--r-- | apps/gui/list.c | 2 | ||||
-rw-r--r-- | apps/gui/list.h | 8 | ||||
-rw-r--r-- | apps/gui/statusbar-skinned.c | 4 | ||||
-rw-r--r-- | apps/gui/statusbar-skinned.h | 2 | ||||
-rw-r--r-- | apps/plugin.h | 2 | ||||
-rw-r--r-- | apps/plugins/lib/printcell_helper.c | 2 |
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) | |||
1247 | int *cardnum = (int*)lists->data; | 1247 | int *cardnum = (int*)lists->data; |
1248 | unsigned char card_name[6]; | 1248 | unsigned char card_name[6]; |
1249 | unsigned char pbuf[32]; | 1249 | unsigned char pbuf[32]; |
1250 | char *title = lists->title; | 1250 | /* Casting away const is safe; the buffer is defined as non-const. */ |
1251 | char *title = (char *)lists->title; | ||
1251 | static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 }; | 1252 | static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 }; |
1252 | static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; | 1253 | static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; |
1253 | static const unsigned char * const kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" }; | 1254 | 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) | |||
103 | bool show_cursor = list_info->show_cursor; | 103 | bool show_cursor = list_info->show_cursor; |
104 | bool have_icons = list_info->have_icons; | 104 | bool have_icons = list_info->have_icons; |
105 | struct line_desc *linedes = list_info->linedes; | 105 | struct line_desc *linedes = list_info->linedes; |
106 | char *dsp_text = list_info->dsp_text; | 106 | const char *dsp_text = list_info->dsp_text; |
107 | 107 | ||
108 | if (is_title) | 108 | if (is_title) |
109 | { | 109 | { |
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) | |||
490 | * both the title and icon. Use NOICON if there is no icon. | 490 | * both the title and icon. Use NOICON if there is no icon. |
491 | */ | 491 | */ |
492 | void gui_synclist_set_title(struct gui_synclist * gui_list, | 492 | void gui_synclist_set_title(struct gui_synclist * gui_list, |
493 | char * title, enum themable_icons icon) | 493 | const char * title, enum themable_icons icon) |
494 | { | 494 | { |
495 | gui_list->title = title; | 495 | gui_list->title = title; |
496 | gui_list->title_icon = icon; | 496 | 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 { | |||
96 | struct viewport *vp; | 96 | struct viewport *vp; |
97 | struct line_desc *linedes; | 97 | struct line_desc *linedes; |
98 | struct gui_synclist * list; | 98 | struct gui_synclist * list; |
99 | char *dsp_text; | 99 | const char *dsp_text; |
100 | 100 | ||
101 | bool is_selected; | 101 | bool is_selected; |
102 | bool is_title; | 102 | bool is_title; |
@@ -185,7 +185,7 @@ struct gui_synclist | |||
185 | /* The data that will be passed to the callback function YOU implement */ | 185 | /* The data that will be passed to the callback function YOU implement */ |
186 | void * data; | 186 | void * data; |
187 | /* The optional title, set to NULL for none */ | 187 | /* The optional title, set to NULL for none */ |
188 | char * title; | 188 | const char * title; |
189 | /* Optional title icon */ | 189 | /* Optional title icon */ |
190 | enum themable_icons title_icon; | 190 | enum themable_icons title_icon; |
191 | 191 | ||
@@ -233,7 +233,7 @@ extern void gui_synclist_select_item(struct gui_synclist * lists, | |||
233 | extern void gui_synclist_add_item(struct gui_synclist * lists); | 233 | extern void gui_synclist_add_item(struct gui_synclist * lists); |
234 | extern void gui_synclist_del_item(struct gui_synclist * lists); | 234 | extern void gui_synclist_del_item(struct gui_synclist * lists); |
235 | extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll); | 235 | extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll); |
236 | extern void gui_synclist_set_title(struct gui_synclist * lists, char * title, | 236 | extern void gui_synclist_set_title(struct gui_synclist * lists, const char * title, |
237 | enum themable_icons icon); | 237 | enum themable_icons icon); |
238 | extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists, | 238 | extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists, |
239 | bool hide); | 239 | bool hide); |
@@ -301,7 +301,7 @@ extern bool list_do_action(int context, int timeout, | |||
301 | **/ | 301 | **/ |
302 | 302 | ||
303 | struct simplelist_info { | 303 | struct simplelist_info { |
304 | char *title; /* title to show on the list */ | 304 | const char *title; /* title to show on the list */ |
305 | int count; /* number of items in the list, each item is selection_size high */ | 305 | int count; /* number of items in the list, each item is selection_size high */ |
306 | int selection_size; /* list selection size, usually 1 */ | 306 | int selection_size; /* list selection size, usually 1 */ |
307 | bool hide_selection; | 307 | 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 @@ | |||
49 | static int update_delay = DEFAULT_UPDATE_DELAY; | 49 | static int update_delay = DEFAULT_UPDATE_DELAY; |
50 | 50 | ||
51 | static bool sbs_has_title[NB_SCREENS]; | 51 | static bool sbs_has_title[NB_SCREENS]; |
52 | static char* sbs_title[NB_SCREENS]; | 52 | static const char* sbs_title[NB_SCREENS]; |
53 | static enum themable_icons sbs_icon[NB_SCREENS]; | 53 | static enum themable_icons sbs_icon[NB_SCREENS]; |
54 | static bool sbs_loaded[NB_SCREENS] = { false }; | 54 | static bool sbs_loaded[NB_SCREENS] = { false }; |
55 | 55 | ||
56 | bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen) | 56 | bool sb_set_title_text(const char* title, enum themable_icons icon, enum screen_type screen) |
57 | { | 57 | { |
58 | sbs_title[screen] = title; | 58 | sbs_title[screen] = title; |
59 | /* Icon_NOICON == -1 which the skin engine wants at position 1, so + 2 */ | 59 | /* 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); | |||
39 | void sb_skin_update(enum screen_type screen, bool force); | 39 | void sb_skin_update(enum screen_type screen, bool force); |
40 | 40 | ||
41 | void sb_skin_set_update_delay(int delay); | 41 | void sb_skin_set_update_delay(int delay); |
42 | bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen); | 42 | bool sb_set_title_text(const char* title, enum themable_icons icon, enum screen_type screen); |
43 | void sb_skin_has_title(enum screen_type screen); | 43 | void sb_skin_has_title(enum screen_type screen); |
44 | const char* sb_get_title(enum screen_type screen); | 44 | const char* sb_get_title(enum screen_type screen); |
45 | enum themable_icons sb_get_icon(enum screen_type screen); | 45 | 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 { | |||
387 | void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll); | 387 | void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll); |
388 | bool (*gui_synclist_do_button)(struct gui_synclist * lists, | 388 | bool (*gui_synclist_do_button)(struct gui_synclist * lists, |
389 | int *action, enum list_wrap wrap); | 389 | int *action, enum list_wrap wrap); |
390 | void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title, | 390 | void (*gui_synclist_set_title)(struct gui_synclist *lists, const char* title, |
391 | enum themable_icons icon); | 391 | enum themable_icons icon); |
392 | enum yesno_res (*gui_syncyesno_run)(const struct text_message * main_message, | 392 | enum yesno_res (*gui_syncyesno_run)(const struct text_message * main_message, |
393 | const struct text_message * yes_message, | 393 | 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) | |||
234 | bool show_cursor = list_info->show_cursor; | 234 | bool show_cursor = list_info->show_cursor; |
235 | bool have_icons = list_info->have_icons; | 235 | bool have_icons = list_info->have_icons; |
236 | struct line_desc *linedes = list_info->linedes; | 236 | struct line_desc *linedes = list_info->linedes; |
237 | char *dsp_text = list_info->dsp_text; | 237 | const char *dsp_text = list_info->dsp_text; |
238 | struct viewport *vp = list_info->vp; | 238 | struct viewport *vp = list_info->vp; |
239 | int line = list_info->line; | 239 | int line = list_info->line; |
240 | 240 | ||