summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/bookmark.c16
-rw-r--r--apps/cuesheet.c8
-rw-r--r--apps/debug_menu.c15
-rw-r--r--apps/filetypes.c6
-rw-r--r--apps/gui/bitmap/list.c2
-rw-r--r--apps/gui/charcell/list.c2
-rw-r--r--apps/gui/list.c10
-rw-r--r--apps/gui/list.h4
-rw-r--r--apps/gui/option_select.c22
-rw-r--r--apps/gui/option_select.h2
-rw-r--r--apps/gui/quickscreen.c4
-rw-r--r--apps/menu.c10
-rw-r--r--apps/menus/eq_menu.c9
-rw-r--r--apps/menus/eq_menu.h6
-rw-r--r--apps/menus/main_menu.c28
-rw-r--r--apps/menus/recording_menu.c2
-rw-r--r--apps/playlist_catalog.c4
-rw-r--r--apps/playlist_viewer.c14
-rw-r--r--apps/plugin.h6
-rw-r--r--apps/plugins/calendar.c2
-rw-r--r--apps/plugins/chessbox/chessbox_pgn.c8
-rw-r--r--apps/plugins/disktidy.c4
-rw-r--r--apps/plugins/doom/rockdoom.c8
-rw-r--r--apps/plugins/goban/goban.c20
-rw-r--r--apps/plugins/goban/types.h2
-rw-r--r--apps/plugins/goban/util.c2
-rw-r--r--apps/plugins/keybox.c4
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c13
-rw-r--r--apps/plugins/properties.c6
-rw-r--r--apps/plugins/random_folder_advance_config.c4
-rw-r--r--apps/plugins/rockboy/menu.c6
-rw-r--r--apps/plugins/rockpaint.c10
-rw-r--r--apps/plugins/shortcuts/shortcuts_view.c8
-rw-r--r--apps/plugins/superdom.c4
-rw-r--r--apps/plugins/text_editor.c4
-rw-r--r--apps/recorder/radio.c4
-rw-r--r--apps/recorder/recording.c4
-rw-r--r--apps/screens.c16
-rw-r--r--apps/settings.c13
-rw-r--r--apps/settings.h4
-rw-r--r--apps/settings_list.c37
-rw-r--r--apps/settings_list.h4
-rw-r--r--apps/tree.c4
43 files changed, 191 insertions, 170 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c
index 5b92767796..cee9abdfa8 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -86,10 +86,10 @@ static bool parse_bookmark(const char *bookmark,
bool *shuffle,
char* file_name);
static int buffer_bookmarks(struct bookmark_list* bookmarks, int first_line);
-static char* get_bookmark_info(int list_index,
- void* data,
- char *buffer,
- size_t buffer_len);
+static const char* get_bookmark_info(int list_index,
+ void* data,
+ char *buffer,
+ size_t buffer_len);
static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resume);
static bool system_check(void);
static bool write_bookmark(bool create_bookmark_file, const char *bookmark);
@@ -515,10 +515,10 @@ static int buffer_bookmarks(struct bookmark_list* bookmarks, int first_line)
return bookmarks->start + bookmarks->count;
}
-static char* get_bookmark_info(int list_index,
- void* data,
- char *buffer,
- size_t buffer_len)
+static const char* get_bookmark_info(int list_index,
+ void* data,
+ char *buffer,
+ size_t buffer_len)
{
struct bookmark_list* bookmarks = (struct bookmark_list*) data;
int index = list_index / 2;
diff --git a/apps/cuesheet.c b/apps/cuesheet.c
index deb0769320..6f29d68716 100644
--- a/apps/cuesheet.c
+++ b/apps/cuesheet.c
@@ -234,10 +234,10 @@ int cue_find_current_track(struct cuesheet *cue, unsigned long curpos)
}
/* callback that gives list item titles for the cuesheet browser */
-static char *list_get_name_cb(int selected_item,
- void *data,
- char *buffer,
- size_t buffer_len)
+static const char* list_get_name_cb(int selected_item,
+ void *data,
+ char *buffer,
+ size_t buffer_len)
{
struct cuesheet *cue = (struct cuesheet *)data;
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index ea53d445fd..4ca8b3fa4f 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -141,8 +141,8 @@ static char thread_status_char(unsigned status)
return thread_status_chars[status];
}
-static char* threads_getname(int selected_item, void *data,
- char *buffer, size_t buffer_len)
+static const char* threads_getname(int selected_item, void *data,
+ char *buffer, size_t buffer_len)
{
(void)data;
struct thread_entry *thread;
@@ -183,6 +183,7 @@ static char* threads_getname(int selected_item, void *data,
return buffer;
}
+
static int dbg_threads_action_callback(int action, struct gui_synclist *lists)
{
(void)lists;
@@ -783,8 +784,8 @@ static bool dbg_hw_info(void)
#endif /* !SIMULATOR */
#ifndef SIMULATOR
-static char* dbg_partitions_getname(int selected_item, void *data,
- char *buffer, size_t buffer_len)
+static const char* dbg_partitions_getname(int selected_item, void *data,
+ char *buffer, size_t buffer_len)
{
(void)data;
int partition = selected_item/2;
@@ -2796,12 +2797,14 @@ static int menu_action_callback(int btn, struct gui_synclist *lists)
}
return btn;
}
-static char* dbg_menu_getname(int item, void * data,
- char *buffer, size_t buffer_len)
+
+static const char* dbg_menu_getname(int item, void * data,
+ char *buffer, size_t buffer_len)
{
(void)data; (void)buffer; (void)buffer_len;
return menuitems[item].desc;
}
+
bool debug_menu(void)
{
struct simplelist_info info;
diff --git a/apps/filetypes.c b/apps/filetypes.c
index 210b949578..ffa7161693 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -435,13 +435,13 @@ static enum themable_icons openwith_get_icon(int selected_item, void * data)
return filetypes[items[selected_item]].icon;
}
-static char * openwith_get_name(int selected_item, void * data,
- char * buffer, size_t buffer_len)
+static const char* openwith_get_name(int selected_item, void * data,
+ char * buffer, size_t buffer_len)
{
(void)buffer; (void)buffer_len;
struct cb_data *info = (struct cb_data *)data;
int *items = info->items;
- char *s = strrchr(filetypes[items[selected_item]].plugin, '/');
+ const char *s = strrchr(filetypes[items[selected_item]].plugin, '/');
if (s)
return s+1;
else return filetypes[items[selected_item]].plugin;
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 8e4cd44d21..71c74dbd09 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -173,7 +173,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
for (i=start; i<end && i<list->nb_items; i++)
{
/* do the text */
- unsigned char *s;
+ unsigned const char *s;
char entry_buffer[MAX_PATH];
unsigned char *entry_name;
int text_pos = 0;
diff --git a/apps/gui/charcell/list.c b/apps/gui/charcell/list.c
index 8d91c2f6b8..2374156f0b 100644
--- a/apps/gui/charcell/list.c
+++ b/apps/gui/charcell/list.c
@@ -69,7 +69,7 @@ void list_draw(struct screen *display, struct gui_synclist *gui_list)
for (i = start; i < end; i++)
{
- unsigned char *s;
+ unsigned const char *s;
char entry_buffer[MAX_PATH];
unsigned char *entry_name;
int current_item = gui_list->start_item[display->screen_type] + i;
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 332459c57f..9b139dd47c 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -827,10 +827,10 @@ void simplelist_addline(int line_number, const char *fmt, ...)
va_end(ap);
}
-static char* simplelist_static_getname(int item,
- void * data,
- char *buffer,
- size_t buffer_len)
+static const char* simplelist_static_getname(int item,
+ void * data,
+ char *buffer,
+ size_t buffer_len)
{
(void)data; (void)buffer; (void)buffer_len;
return simplelist_text[item];
@@ -841,7 +841,7 @@ bool simplelist_show_list(struct simplelist_info *info)
struct gui_synclist lists;
int action, old_line_count = simplelist_line_count;
int oldbars = viewportmanager_set_statusbar(VP_SB_ALLSCREENS);
- char* (*getname)(int item, void * data, char *buffer, size_t buffer_len);
+ const char* (*getname)(int item, void * data, char *buffer, size_t buffer_len);
int wrap = LIST_WRAP_UNLESS_HELD;
if (info->get_name)
getname = info->get_name;
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 7148e340cc..8a36acb005 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -64,8 +64,8 @@ typedef enum themable_icons list_get_icon(int selected_item, void * data);
* - buffer_len : length of the buffer
* Returns a pointer to a string that contains the text to display
*/
-typedef char * list_get_name(int selected_item, void * data,
- char * buffer, size_t buffer_len);
+typedef const char * list_get_name(int selected_item, void * data,
+ char * buffer, size_t buffer_len);
/*
* Voice callback
* - selected_item : an integer that tells the number of the item to speak
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index 01259c4136..d806a0aa08 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -69,10 +69,11 @@ static const char *unit_strings[] =
/* these two vars are needed so arbitrary values can be added to the
TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */
static int table_setting_oldval = 0, table_setting_array_position = 0;
-char *option_get_valuestring(const struct settings_list *setting,
- char *buffer, int buf_len,
- intptr_t temp_var)
+const char *option_get_valuestring(const struct settings_list *setting,
+ char *buffer, int buf_len,
+ intptr_t temp_var)
{
+ const char* str = buffer;
if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING)
{
bool val = (bool)temp_var;
@@ -93,7 +94,7 @@ char *option_get_valuestring(const struct settings_list *setting,
const struct int_setting *int_info = setting->int_setting;
const struct table_setting *tbl_info = setting->table_setting;
const char *unit;
- void (*formatter)(char*, size_t, int, const char*);
+ const char* (*formatter)(char*, size_t, int, const char*);
if ((setting->flags & F_INT_SETTING) == F_INT_SETTING)
{
formatter = int_info->formatter;
@@ -105,7 +106,7 @@ char *option_get_valuestring(const struct settings_list *setting,
unit = unit_strings[tbl_info->unit];
}
if (formatter)
- formatter(buffer, buf_len, (int)temp_var, unit);
+ str = formatter(buffer, buf_len, (int)temp_var, unit);
else
snprintf(buffer, buf_len, "%d %s", (int)temp_var, unit?unit:"");
}
@@ -152,7 +153,7 @@ char *option_get_valuestring(const struct settings_list *setting,
strlcpy(buffer, val, buf_len);
}
}
- return buffer;
+ return str;
}
void option_talk_value(const struct settings_list *setting, int value, bool enqueue)
{
@@ -363,10 +364,11 @@ static int selection_to_val(const struct settings_list *setting, int selection)
}
return max- (selection * step);
}
-static char * value_setting_get_name_cb(int selected_item,
- void * data,
- char *buffer,
- size_t buffer_len)
+
+static const char * value_setting_get_name_cb(int selected_item,
+ void * data,
+ char *buffer,
+ size_t buffer_len)
{
selected_item = selection_to_val(data, selected_item);
return option_get_valuestring(data, buffer, buffer_len, selected_item);
diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h
index b1a4a86e65..a8661fb8ad 100644
--- a/apps/gui/option_select.h
+++ b/apps/gui/option_select.h
@@ -33,7 +33,7 @@ bool option_screen(const struct settings_list *setting,
void option_select_next_val(const struct settings_list *setting,
bool previous, bool apply);
#endif
-char *option_get_valuestring(const struct settings_list *setting,
+const char *option_get_valuestring(const struct settings_list *setting,
char *buffer, int buf_len,
intptr_t temp_var);
void option_talk_value(const struct settings_list *setting, int value, bool enqueue);
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c
index 20d27380d2..d6d662b1f1 100644
--- a/apps/gui/quickscreen.c
+++ b/apps/gui/quickscreen.c
@@ -147,7 +147,7 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
vps[screen][QUICKSCREEN_BOTTOM].y - vp_icons[screen].y;
}
-static void quickscreen_draw_text(char *s, int item, bool title,
+static void quickscreen_draw_text(const char *s, int item, bool title,
struct screen *display, struct viewport *vp)
{
int nb_lines = viewport_get_nb_lines(vp);
@@ -186,7 +186,7 @@ static void gui_quickscreen_draw(struct gui_quickscreen *qs,
int i;
char buf[MAX_PATH];
- unsigned char *title, *value;
+ unsigned const char *title, *value;
void *setting;
int temp;
display->set_viewport(parent);
diff --git a/apps/menu.c b/apps/menu.c
index 348095cd31..b442d4423d 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -93,10 +93,10 @@ static int find_menu_selection(int selected)
return i;
return 0;
}
-static char * get_menu_item_name(int selected_item,
- void * data,
- char *buffer,
- size_t buffer_len)
+static const char* get_menu_item_name(int selected_item,
+ void * data,
+ char *buffer,
+ size_t buffer_len)
{
const struct menu_item_ex *menu = (const struct menu_item_ex *)data;
int type = (menu->flags&MENU_TYPE_MASK);
@@ -109,7 +109,7 @@ static char * get_menu_item_name(int selected_item,
if (menu->flags&MENU_DYNAMIC_DESC)
return menu->menu_get_name_and_icon->list_get_name(selected_item,
menu->menu_get_name_and_icon->list_get_name_data, buffer);
- return (char*)menu->strings[selected_item];
+ return menu->strings[selected_item];
}
menu = menu->submenus[selected_item];
diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c
index 6087ebfd5b..0e04dddc18 100644
--- a/apps/menus/eq_menu.c
+++ b/apps/menus/eq_menu.c
@@ -51,15 +51,18 @@
* Utility functions
*/
-void eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit)
+const char* eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit)
{
- snprintf(buffer, buffer_size, "%d.%d %s", value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit);
+ snprintf(buffer, buffer_size, "%d.%d %s", value / EQ_USER_DIVISOR,
+ value % EQ_USER_DIVISOR, unit);
+ return buffer;
}
-void eq_precut_format(char* buffer, size_t buffer_size, int value, const char* unit)
+const char* eq_precut_format(char* buffer, size_t buffer_size, int value, const char* unit)
{
snprintf(buffer, buffer_size, "%s%d.%d %s", value == 0 ? " " : "-",
value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit);
+ return buffer;
}
/*
diff --git a/apps/menus/eq_menu.h b/apps/menus/eq_menu.h
index 6be099113a..6c8301c572 100644
--- a/apps/menus/eq_menu.h
+++ b/apps/menus/eq_menu.h
@@ -43,7 +43,9 @@ bool eq_browse_presets(void);
bool eq_menu_graphical(void);
/* utility functions for settings_list.c */
-void eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit);
-void eq_precut_format(char* buffer, size_t buffer_size, int value, const char* unit);
+const char* eq_q_format(char* buffer, size_t buffer_size, int value,
+ const char* unit);
+const char* eq_precut_format(char* buffer, size_t buffer_size, int value,
+ const char* unit);
#endif
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c
index 1e7465559e..99c73f2cdb 100644
--- a/apps/menus/main_menu.c
+++ b/apps/menus/main_menu.c
@@ -164,8 +164,8 @@ static const unsigned char *byte_units[] =
ID2P(LANG_MEGABYTE)
};
-static char* info_getname(int selected_item, void *data,
- char *buffer, size_t buffer_len)
+static const char* info_getname(int selected_item, void *data,
+ char *buffer, size_t buffer_len)
{
struct info_data *info = (struct info_data*)data;
char s1[32];
@@ -199,27 +199,27 @@ static char* info_getname(int selected_item, void *data,
#if CONFIG_CHARGING == CHARGING_SIMPLE
/* Only know if plugged */
if (charger_inserted())
- return (char *)str(LANG_BATTERY_CHARGE);
+ return str(LANG_BATTERY_CHARGE);
else
#elif CONFIG_CHARGING >= CHARGING_MONITOR
#ifdef ARCHOS_RECORDER
/* Report the particular algorithm state */
if (charge_state == CHARGING)
- return (char *)str(LANG_BATTERY_CHARGE);
+ return str(LANG_BATTERY_CHARGE);
else if (charge_state == TOPOFF)
- return (char *)str(LANG_BATTERY_TOPOFF_CHARGE);
+ return str(LANG_BATTERY_TOPOFF_CHARGE);
else if (charge_state == TRICKLE)
- return (char *)str(LANG_BATTERY_TRICKLE_CHARGE);
+ return str(LANG_BATTERY_TRICKLE_CHARGE);
else
#else /* !ARCHOS_RECORDER */
/* Go by what power management reports */
if (charging_state())
- return (char *)str(LANG_BATTERY_CHARGE);
+ return str(LANG_BATTERY_CHARGE);
else
#endif /* ARCHOS_RECORDER */
#endif /* CONFIG_CHARGING = */
if (battery_level() >= 0)
- snprintf(buffer, buffer_len, (char *)str(LANG_BATTERY_TIME),
+ snprintf(buffer, buffer_len, str(LANG_BATTERY_TIME),
battery_level(), battery_time() / 60, battery_time() % 60);
else
return "(n/a)";
@@ -399,19 +399,19 @@ MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO),
/* sleep Menu */
-static void sleep_timer_formatter(char* buffer, size_t buffer_size, int value,
- const char* unit)
+static const char* sleep_timer_formatter(char* buffer, size_t buffer_size,
+ int value, const char* unit)
{
- int minutes, hours;
-
(void) unit;
+ int minutes, hours;
if (value) {
hours = value / 60;
minutes = value - (hours * 60);
snprintf(buffer, buffer_size, "%d:%02d", hours, minutes);
- } else {
- strlcpy(buffer, str(LANG_OFF), buffer_size);
+ return buffer;
+ } else {
+ return str(LANG_OFF);
}
}
diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c
index c15a18291c..7b99b48a2d 100644
--- a/apps/menus/recording_menu.c
+++ b/apps/menus/recording_menu.c
@@ -415,7 +415,7 @@ static enum themable_icons trigger_get_icon(int selected_item, void * data)
return Icon_NOICON;
}
-static char * trigger_get_name(int selected_item, void * data,
+static const char * trigger_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
{
const struct settings_list **settings =
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index a4950e22e8..5e8cf02c96 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -184,8 +184,8 @@ exit:
}
/* Callback for gui_synclist */
-static char* playlist_callback_name(int selected_item, void* data,
- char* buffer, size_t buffer_len)
+static const char* playlist_callback_name(int selected_item, void* data,
+ char* buffer, size_t buffer_len)
{
char** playlists = (char**) data;
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index 7d3ff4ef9e..a829fc96f6 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -559,10 +559,10 @@ static int get_track_num( struct playlist_viewer * local_viewer,
return selected_item;
}
-static char *playlist_callback_name(int selected_item,
- void *data,
- char *buffer,
- size_t buffer_len)
+static const char* playlist_callback_name(int selected_item,
+ void *data,
+ char *buffer,
+ size_t buffer_len)
{
struct playlist_viewer * local_viewer = (struct playlist_viewer *)data;
@@ -778,15 +778,15 @@ exit:
return ret;
}
-static char *playlist_search_callback_name(int selected_item, void * data,
- char *buffer, size_t buffer_len)
+static const char* playlist_search_callback_name(int selected_item, void * data,
+ char *buffer, size_t buffer_len)
{
(void)buffer_len; /* this should probably be used */
int *found_indicies = (int*)data;
static struct playlist_track_info track;
playlist_get_track_info(viewer.playlist, found_indicies[selected_item], &track);
format_name(buffer, track.filename);
- return(buffer);
+ return buffer;
}
bool search_playlist(void)
diff --git a/apps/plugin.h b/apps/plugin.h
index 4cf319210c..4981230df3 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -133,12 +133,12 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 170
+#define PLUGIN_API_VERSION 171
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
-#define PLUGIN_MIN_API_VERSION 170
+#define PLUGIN_MIN_API_VERSION 171
/* plugin return codes */
enum plugin_status {
@@ -672,7 +672,7 @@ struct plugin_api {
bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit,
const int* variable, void (*function)(int), int step,
int min, int max,
- void (*formatter)(char*, size_t, int, const char*) );
+ const char* (*formatter)(char*, size_t, int, const char*) );
bool (*set_bool)(const char* string, const bool* variable );
#ifdef HAVE_LCD_COLOR
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index cfb92909bf..20b7fa9226 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -669,7 +669,7 @@ static bool edit_memo(int change, struct shown *shown)
return false;
}
-static char * get_event_text(int selected, void *data,
+static const char* get_event_text(int selected, void *data,
char *buffer, size_t buffer_len)
{
struct shown *shown = (struct shown *) data;
diff --git a/apps/plugins/chessbox/chessbox_pgn.c b/apps/plugins/chessbox/chessbox_pgn.c
index cd163a5e1c..512fb0ca15 100644
--- a/apps/plugins/chessbox/chessbox_pgn.c
+++ b/apps/plugins/chessbox/chessbox_pgn.c
@@ -528,11 +528,10 @@ void coords_to_pgn(struct pgn_ply_node* ply){
}
}
-char * get_game_text(int selected_item, void *data,
- char *buffer, size_t buffer_len){
+static const char* get_game_text(int selected_item, void *data,
+ char *buffer, size_t buffer_len){
int i;
struct pgn_game_node *temp_node = (struct pgn_game_node *)data;
- char text_buffer[50];
for (i=0;i<selected_item && temp_node != NULL;i++){
temp_node = temp_node->next_node;
@@ -540,10 +539,9 @@ char * get_game_text(int selected_item, void *data,
if (temp_node == NULL){
return NULL;
}
- rb->snprintf(text_buffer, 50,"%s vs. %s (%s)", temp_node->white_player,
+ rb->snprintf(buffer, buffer_len,"%s vs. %s (%s)", temp_node->white_player,
temp_node->black_player, temp_node->game_date);
- rb->strlcpy(buffer, text_buffer, buffer_len);
return buffer;
}
diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c
index b7b9aa1770..84cc220891 100644
--- a/apps/plugins/disktidy.c
+++ b/apps/plugins/disktidy.c
@@ -380,8 +380,8 @@ enum themable_icons get_icon(int item, void * data)
return Icon_NOICON;
}
-char * get_name(int selected_item, void * data,
- char * buffer, size_t buffer_len)
+static const char* get_name(int selected_item, void * data,
+ char * buffer, size_t buffer_len)
{
(void)data;
if (tidy_types[selected_item].directory)
diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c
index ca08ec1665..1d065cc981 100644
--- a/apps/plugins/doom/rockdoom.c
+++ b/apps/plugins/doom/rockdoom.c
@@ -550,14 +550,15 @@ static bool Doptions()
return (1);
}
-char* choice_get_name(int selected_item, void * data,
- char * buffer, size_t buffer_len)
+static const char* choice_get_name(int selected_item, void * data,
+ char * buffer, size_t buffer_len)
{
- char **names = (char **) data;
+ const char **names = (const char **) data;
(void) buffer;
(void) buffer_len;
return names[selected_item];
}
+
int list_action_callback(int action, struct gui_synclist *lists)
{
(void) lists;
@@ -565,6 +566,7 @@ int list_action_callback(int action, struct gui_synclist *lists)
return ACTION_STD_CANCEL;
return action;
}
+
bool menuchoice(char **names, int count, int *selected)
{
struct simplelist_info info;
diff --git a/apps/plugins/goban/goban.c b/apps/plugins/goban/goban.c
index 65a03f6953..4e20e71a37 100644
--- a/apps/plugins/goban/goban.c
+++ b/apps/plugins/goban/goban.c
@@ -114,37 +114,39 @@ set_defaults (void)
autosave_time = 7;
}
-static void
+static const char*
komi_formatter (char *dest, size_t size, int menu_item, const char *unknown)
{
(void) unknown;
snprint_fixed (dest, size, menu_item);
+ return dest;
}
-static void
+static const char*
ruleset_formatter (char *dest, size_t size, int menu_item, const char *unknown)
{
- (void) unknown;
- rb->snprintf (dest, size, "%s", ruleset_names[menu_item]);
+ (void)dest, (void)size, (void)unknown;
+ return ruleset_names[menu_item];
}
-static void
+static const char*
autosave_formatter (char *dest, size_t size, int menu_item, const char *
unknown)
{
(void) unknown;
if (menu_item == 0)
{
- rb->snprintf (dest, size, "Off");
+ return "Off";
}
else
{
rb->snprintf (dest, size, "%d minute%s", menu_item,
menu_item == 1 ? "" : "s");
+ return dest;
}
}
-static void
+static const char*
time_formatter (char *dest, size_t size, int menu_item, const char *unknown)
{
int time_values[4]; /* days hours minutes seconds */
@@ -183,8 +185,7 @@ time_formatter (char *dest, size_t size, int menu_item, const char *unknown)
if (max_set == -1)
{
- rb->snprintf (dest, size, "0");
- return;
+ return "0";
}
for (i = min_set; i <= 3; ++i)
@@ -236,6 +237,7 @@ time_formatter (char *dest, size_t size, int menu_item, const char *unknown)
dest += temp;
size -= temp;
}
+ return dest;
}
enum plugin_status
diff --git a/apps/plugins/goban/types.h b/apps/plugins/goban/types.h
index 216d41bc21..a7c2b9b0ae 100644
--- a/apps/plugins/goban/types.h
+++ b/apps/plugins/goban/types.h
@@ -218,7 +218,7 @@ struct prop_t
/* The names of the rulesets, ex. "AGA", "Japanese", etc. */
-extern char *ruleset_names[];
+extern const char *ruleset_names[];
/* IMPORTANT! keep in sync with ruleset_names!!! */
enum ruleset_t
diff --git a/apps/plugins/goban/util.c b/apps/plugins/goban/util.c
index e9966311ef..0e83173f40 100644
--- a/apps/plugins/goban/util.c
+++ b/apps/plugins/goban/util.c
@@ -210,7 +210,7 @@ char *prop_names[] = {
/* These seems to be specified by the SGF specification. You can do free
form ones as well, but I haven't implemented that (and don't plan to) */
-char *ruleset_names[] = { "AGA", "Japanese", "Chinese", "NZ", "GOE" };
+const char *ruleset_names[] = { "AGA", "Japanese", "Chinese", "NZ", "GOE" };
diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c
index 733c6e95cd..d926105962 100644
--- a/apps/plugins/keybox.c
+++ b/apps/plugins/keybox.c
@@ -122,8 +122,8 @@ MENUITEM_STRINGLIST(context_m, "Context menu", context_item_cb,
"Delete entry",
"Playback Control");
-static char * kb_list_cb(int selected_item, void *data,
- char *buffer, size_t buffer_len)
+static const char* kb_list_cb(int selected_item, void *data,
+ char *buffer, size_t buffer_len)
{
(void)data;
int i;
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index 62293d101f..3868d759f6 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -317,7 +317,7 @@ static bool mpeg_set_int(const char *string, const char *unit,
void (*function)(int), int step,
int min,
int max,
- void (*formatter)(char*, size_t, int, const char*))
+ const char* (*formatter)(char*, size_t, int, const char*))
{
mpeg_menu_sysevent_clear();
@@ -350,15 +350,16 @@ static void backlight_brightness_function(int value)
mpeg_backlight_update_brightness(value);
}
-static void backlight_brightness_formatter(char *buf, size_t length,
- int value, const char *input)
+static const char* backlight_brightness_formatter(char *buf, size_t length,
+ int value, const char *input)
{
+ (void)input;
+
if (value < 0)
- rb->strlcpy(buf, BACKLIGHT_OPTION_DEFAULT, length);
+ return BACKLIGHT_OPTION_DEFAULT;
else
rb->snprintf(buf, length, "%d", value + MIN_BRIGHTNESS_SETTING);
-
- (void)input;
+ return buf;
}
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index c76a25b06a..7cd29c126f 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -228,7 +228,8 @@ static bool dir_properties(char* selected_file)
return true;
}
-char * get_props(int selected_item, void* data, char *buffer, size_t buffer_len)
+static const char * get_props(int selected_item, void* data,
+ char *buffer, size_t buffer_len)
{
(void)data;
@@ -263,8 +264,7 @@ char * get_props(int selected_item, void* data, char *buffer, size_t buffer_len)
rb->strlcpy(buffer, its_a_dir ? "" : str_duration, buffer_len);
break;
default:
- rb->strlcpy(buffer, "ERROR", buffer_len);
- break;
+ return "ERROR";
}
return buffer;
}
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c
index c9ffaed319..ba3f0d3f7e 100644
--- a/apps/plugins/random_folder_advance_config.c
+++ b/apps/plugins/random_folder_advance_config.c
@@ -234,7 +234,9 @@ void generate(void)
rb->close(fd);
rb->splash(HZ, "Done");
}
-char *list_get_name_cb(int selected_item, void* data, char* buf, size_t buf_len)
+
+static const char* list_get_name_cb(int selected_item, void* data,
+ char* buf, size_t buf_len)
{
(void)data;
rb->strlcpy(buf, list->folder[selected_item], buf_len);
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c
index 455c91b5b6..bd4088300c 100644
--- a/apps/plugins/rockboy/menu.c
+++ b/apps/plugins/rockboy/menu.c
@@ -270,10 +270,10 @@ static void slot_info(char *info_buf, size_t info_bufsiz, size_t slot_id) {
/*
* slot_get_name
*/
-static char *slot_get_name(int selected_item, void * data,
- char * buffer, size_t buffer_len)
+static const char* slot_get_name(int selected_item, void * data,
+ char * buffer, size_t buffer_len)
{
- char (*items)[20] = data;
+ const char (*items)[20] = data;
(void) buffer;
(void) buffer_len;
return items[selected_item];
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index a4084a2ca7..219f013ed8 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -600,8 +600,8 @@ char bbuf[MAX_PATH+1]; /* used by file and font browsers */
char bbuf_s[MAX_PATH+1]; /* used by file and font browsers */
struct tree_context *tree = NULL;
-static char * browse_get_name_cb( int selected_item, void *data,
- char *buffer, size_t buffer_len )
+static const char* browse_get_name_cb(int selected_item, void *data,
+ char *buffer, size_t buffer_len)
{
int *indexes = (int *) data;
struct entry* dc = tree->dircache;
@@ -609,7 +609,7 @@ static char * browse_get_name_cb( int selected_item, void *data,
(void) buffer;
(void) buffer_len;
- return (e->name);
+ return e->name;
}
static bool browse( char *dst, int dst_size, const char *start )
@@ -633,8 +633,8 @@ static bool browse( char *dst, int dst_size, const char *start )
}
bbuf_s[0] = '\0';
- rb->gui_synclist_init( &browse_list, browse_get_name_cb,
- (void*) indexes, false, 1, NULL );
+ rb->gui_synclist_init(&browse_list, browse_get_name_cb,
+ (void*) indexes, false, 1, NULL);
tree = rb->tree_get_context();
backup = *tree;
diff --git a/apps/plugins/shortcuts/shortcuts_view.c b/apps/plugins/shortcuts/shortcuts_view.c
index f6a26a519d..b964968737 100644
--- a/apps/plugins/shortcuts/shortcuts_view.c
+++ b/apps/plugins/shortcuts/shortcuts_view.c
@@ -40,8 +40,8 @@ static bool usb_connected = false;
enum sc_list_action_type draw_sc_list(struct gui_synclist *gui_sc);
/* Will be passed sc_file* as data */
-char* build_sc_list(int selected_item, void *data,
- char *buffer, size_t buffer_len);
+static const char* build_sc_list(int selected_item, void *data,
+ char *buffer, size_t buffer_len);
/* Returns true iff we should leave the main loop */
bool list_sc(void);
@@ -89,8 +89,8 @@ enum sc_list_action_type draw_sc_list(struct gui_synclist *gui_sc)
}
-char* build_sc_list(int selected_item, void *data,
- char *buffer, size_t buffer_len)
+static const char* build_sc_list(int selected_item, void *data,
+ char *buffer, size_t buffer_len)
{
sc_file_t *file = (sc_file_t*)data;
diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c
index d6b9621343..dc078170e9 100644
--- a/apps/plugins/superdom.c
+++ b/apps/plugins/superdom.c
@@ -1251,8 +1251,8 @@ int movement_menu(void) {
return RET_VAL_OK;
}
-static char * inventory_data(int selected_item, void * data,
- char * buffer, size_t buffer_len) {
+static const char* inventory_data(int selected_item, void * data,
+ char * buffer, size_t buffer_len) {
(void)data;
switch(selected_item) {
case 0:
diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c
index 473bb68ead..dc792046fa 100644
--- a/apps/plugins/text_editor.c
+++ b/apps/plugins/text_editor.c
@@ -121,8 +121,8 @@ int _do_action(int action, char* str, int line)
last_char_index = c;
return 1;
}
-char *list_get_name_cb(int selected_item, void* data,
- char* buf, size_t buf_len)
+static const char* list_get_name_cb(int selected_item, void* data,
+ char* buf, size_t buf_len)
{
(void)data;
char *b = &buffer[do_action(ACTION_GET,0,selected_item)];
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index c5729ba8b2..31610a363e 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -1347,8 +1347,8 @@ MAKE_MENU(handle_radio_preset_menu, ID2P(LANG_PRESET),
radio_preset_callback, Icon_NOICON, &radio_edit_preset_item,
&radio_delete_preset_item);
/* present a list of preset stations */
-static char * presets_get_name(int selected_item, void *data,
- char *buffer, size_t buffer_len)
+static const char* presets_get_name(int selected_item, void *data,
+ char *buffer, size_t buffer_len)
{
(void)data;
struct fmstation *p = &presets[selected_item];
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 2716d932b5..d461df555d 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -848,8 +848,8 @@ enum rec_list_items_spdif {
static int listid_to_enum[ITEM_COUNT];
-static char * reclist_get_name(int selected_item, void * data,
- char * buffer, size_t buffer_len)
+static const char* reclist_get_name(int selected_item, void * data,
+ char * buffer, size_t buffer_len)
{
char buf2[32];
#ifdef HAVE_AGC
diff --git a/apps/screens.c b/apps/screens.c
index 2bdd2dd061..ead6735a95 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -789,20 +789,22 @@ static const int id3_headers[]=
#endif
LANG_ID3_PATH,
};
+
struct id3view_info {
struct mp3entry* id3;
int count;
- int info_id[sizeof(id3_headers)/sizeof(id3_headers[0])];
+ int info_id[ARRAYLEN(id3_headers)];
};
-static char * id3_get_info(int selected_item, void* data,
- char *buffer, size_t buffer_len)
+
+static const char* id3_get_info(int selected_item, void* data,
+ char *buffer, size_t buffer_len)
{
struct id3view_info *info = (struct id3view_info*)data;
struct mp3entry* id3 =info->id3;
int info_no=selected_item/2;
if(!(selected_item%2))
{/* header */
- return( str(id3_headers[info->info_id[info_no]]));
+ return(str(id3_headers[info->info_id[info_no]]));
}
else
{/* data */
@@ -903,7 +905,7 @@ bool browse_id3(void)
struct id3view_info info;
info.count = 0;
info.id3 = id3;
- for (i=0; i<sizeof(id3_headers)/sizeof(id3_headers[0]); i++)
+ for (i = 0; i < ARRAYLEN(id3_headers); i++)
{
char temp[8];
info.info_id[i] = i;
@@ -924,8 +926,8 @@ bool browse_id3(void)
}
}
-static char* runtime_get_data(int selected_item, void* data,
- char* buffer, size_t buffer_len)
+static const char* runtime_get_data(int selected_item, void* data,
+ char* buffer, size_t buffer_len)
{
(void)data;
int t;
diff --git a/apps/settings.c b/apps/settings.c
index b76468280e..98cd6ebc95 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -1083,7 +1083,7 @@ bool set_int(const unsigned char* string,
int step,
int min,
int max,
- void (*formatter)(char*, size_t, int, const char*) )
+ const char* (*formatter)(char*, size_t, int, const char*) )
{
return set_int_ex(string, unit, voice_unit, variable, function,
step, min, max, formatter, NULL);
@@ -1097,7 +1097,7 @@ bool set_int_ex(const unsigned char* string,
int step,
int min,
int max,
- void (*formatter)(char*, size_t, int, const char*),
+ const char* (*formatter)(char*, size_t, int, const char*),
int32_t (*get_talk_id)(int, int))
{
(void)unit;
@@ -1117,17 +1117,18 @@ bool set_int_ex(const unsigned char* string,
static const struct opt_items *set_option_options;
-static void set_option_formatter(char* buf, size_t size, int item, const char* unit)
+static const char* set_option_formatter(char* buf, size_t size, int item, const char* unit)
{
- (void)unit;
- const unsigned char *text = set_option_options[item].string;
- strlcpy(buf, P2STR(text), size);
+ (void)buf, (void)unit, (void)size;
+ return P2STR(set_option_options[item].string);
}
+
static int32_t set_option_get_talk_id(int value, int unit)
{
(void)unit;
return set_option_options[value].voice_id;
}
+
bool set_option(const char* string, const void* variable, enum optiontype type,
const struct opt_items* options,
int numoptions, void (*function)(int))
diff --git a/apps/settings.h b/apps/settings.h
index c45e3b3110..cbd7b6d3b3 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -271,13 +271,13 @@ bool set_bool(const char* string, const bool* variable);
bool set_int(const unsigned char* string, const char* unit, int voice_unit,
const int* variable,
void (*function)(int), int step, int min, int max,
- void (*formatter)(char*, size_t, int, const char*) );
+ const char* (*formatter)(char*, size_t, int, const char*) );
/* use this one if you need to create a lang from the value (i.e with TALK_ID()) */
bool set_int_ex(const unsigned char* string, const char* unit, int voice_unit,
const int* variable,
void (*function)(int), int step, int min, int max,
- void (*formatter)(char*, size_t, int, const char*),
+ const char* (*formatter)(char*, size_t, int, const char*),
int32_t (*get_talk_id)(int, int));
void set_file(const char* filename, char* setting, int maxlen);
diff --git a/apps/settings_list.c b/apps/settings_list.c
index a9cfd79952..450d0eada4 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -269,13 +269,14 @@ static const char graphic_numeric[] = "graphic,numeric";
#endif /* HAVE_RECORDING */
-static void formatter_unit_0_is_off(char *buffer, size_t buffer_size,
+static const char* formatter_unit_0_is_off(char *buffer, size_t buffer_size,
int val, const char *unit)
{
if (val == 0)
- strcpy(buffer, str(LANG_OFF));
+ return str(LANG_OFF);
else
snprintf(buffer, buffer_size, "%d %s", val, unit);
+ return buffer;
}
static int32_t getlang_unit_0_is_off(int value, int unit)
@@ -286,16 +287,17 @@ static int32_t getlang_unit_0_is_off(int value, int unit)
return TALK_ID(value,unit);
}
-static void formatter_unit_0_is_skip_track(char *buffer, size_t buffer_size,
+static const char* formatter_unit_0_is_skip_track(char *buffer, size_t buffer_size,
int val, const char *unit)
{
(void)unit;
if (val == 0)
- strcpy(buffer, str(LANG_SKIP_TRACK));
+ return str(LANG_SKIP_TRACK);
else if (val % 60 == 0)
snprintf(buffer, buffer_size, "%d min", val/60);
else
snprintf(buffer, buffer_size, "%d s", val);
+ return buffer;
}
static int32_t getlang_unit_0_is_skip_track(int value, int unit)
@@ -310,15 +312,16 @@ static int32_t getlang_unit_0_is_skip_track(int value, int unit)
}
#ifdef HAVE_BACKLIGHT
-static void backlight_formatter(char *buffer, size_t buffer_size,
+static const char* backlight_formatter(char *buffer, size_t buffer_size,
int val, const char *unit)
{
if (val == -1)
- strcpy(buffer, str(LANG_OFF));
+ return str(LANG_OFF);
else if (val == 0)
- strcpy(buffer, str(LANG_ON));
+ return str(LANG_ON);
else
snprintf(buffer, buffer_size, "%d %s", val, unit);
+ return buffer;
}
static int32_t backlight_getlang(int value, int unit)
{
@@ -332,14 +335,15 @@ static int32_t backlight_getlang(int value, int unit)
#endif
#ifndef HAVE_WHEEL_ACCELERATION
-static void scanaccel_formatter(char *buffer, size_t buffer_size,
+static const char* scanaccel_formatter(char *buffer, size_t buffer_size,
int val, const char *unit)
{
(void)unit;
if (val == 0)
- strcpy(buffer, str(LANG_OFF));
+ return str(LANG_OFF);
else
snprintf(buffer, buffer_size, "2x/%ds", val);
+ return buffer;
}
#endif
@@ -352,13 +356,14 @@ static void crossfeed_cross_set(int val)
global_settings.crossfeed_hf_cutoff);
}
-static void db_format(char* buffer, size_t buffer_size, int value,
+static const char* db_format(char* buffer, size_t buffer_size, int value,
const char* unit)
{
int v = abs(value);
snprintf(buffer, buffer_size, "%s%d.%d %s", value < 0 ? "-" : "",
v / 10, v % 10, unit);
+ return buffer;
}
static int32_t get_dec_talkid(int value, int unit)
@@ -384,27 +389,25 @@ static void set_superbass(bool value)
#endif
#ifdef HAVE_LCD_CHARCELLS
-static void jumpscroll_format(char* buffer, size_t buffer_size, int value,
+static const char* jumpscroll_format(char* buffer, size_t buffer_size, int value,
const char* unit)
{
(void)unit;
switch (value)
{
case 0:
- strcpy(buffer, str(LANG_OFF));
- break;
+ return str(LANG_OFF);
case 1:
- strcpy(buffer, str(LANG_ONE_TIME));
- break;
+ return str(LANG_ONE_TIME);
case 2:
case 3:
case 4:
snprintf(buffer, buffer_size, "%d", value);
break;
case 5:
- strcpy(buffer, str(LANG_ALWAYS));
- break;
+ return str(LANG_ALWAYS);
}
+ return buffer;
}
static int32_t jumpscroll_getlang(int value, int unit)
{
diff --git a/apps/settings_list.h b/apps/settings_list.h
index 1bc529c7d9..9f1805f169 100644
--- a/apps/settings_list.h
+++ b/apps/settings_list.h
@@ -73,7 +73,7 @@ struct int_setting {
int min;
int max;
int step;
- void (*formatter)(char*, size_t, int, const char*);
+ const char* (*formatter)(char*, size_t, int, const char*);
int32_t (*get_talk_id)(int, int);
};
#define F_INT_SETTING 0x80
@@ -92,7 +92,7 @@ struct choice_setting {
struct table_setting {
void (*option_callback)(int);
- void (*formatter)(char*, size_t, int, const char*);
+ const char* (*formatter)(char*, size_t, int, const char*);
int32_t (*get_talk_id)(int, int);
int unit;
int count;
diff --git a/apps/tree.c b/apps/tree.c
index 667aea0572..228f491c15 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -106,8 +106,8 @@ static int ft_play_dirname(char* name);
static void ft_play_filename(char *dir, char *file);
static void say_filetype(int attr);
-static char * tree_get_filename(int selected_item, void *data,
- char *buffer, size_t buffer_len)
+static const char* tree_get_filename(int selected_item, void *data,
+ char *buffer, size_t buffer_len)
{
struct tree_context * local_tc=(struct tree_context *)data;
char *name;