From 46943ad40c835999c24b345e4b19e37161f078b6 Mon Sep 17 00:00:00 2001 From: Nils Wallménius Date: Sun, 11 Oct 2009 08:45:47 +0000 Subject: Avoid more useless string copys and make some random cleanups git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23092 a1c6a512-1295-4272-9138-f99709370657 --- apps/menus/time_menu.c | 14 ++++++++------ apps/recorder/radio.c | 8 ++++---- apps/recorder/recording.c | 9 ++++----- 3 files changed, 16 insertions(+), 15 deletions(-) (limited to 'apps') diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c index e6cbb230da..cb0e4aac5b 100644 --- a/apps/menus/time_menu.c +++ b/apps/menus/time_menu.c @@ -160,8 +160,8 @@ static void talk_timedate(void) } } -static void vp_puts_center(struct viewport *vp, struct screen *display, int line, - char *str) +static void vp_puts_center(struct viewport *vp, struct screen *display, + int line, const char *str) { int w, offset; @@ -180,6 +180,7 @@ static void draw_timedate(struct viewport *vp, struct screen *display) struct tm *tm = get_time(); int line; char time[16], date[16]; + const char *t = time, *d = date; if (vp->height == 0) return; display->set_viewport(vp); @@ -205,13 +206,13 @@ static void draw_timedate(struct viewport *vp, struct screen *display) } else { - snprintf(time, 16, "%s", "--:--:--"); - snprintf(date, 16, "%s", str(LANG_UNKNOWN)); + t = "--:--:--"; + d = str(LANG_UNKNOWN); } - vp_puts_center(vp, display, line, time); + vp_puts_center(vp, display, line, t); line++; - vp_puts_center(vp, display, line, date); + vp_puts_center(vp, display, line, d); display->update_viewport(); } @@ -307,3 +308,4 @@ int time_screen(void* ignored) return 0; return ret; } + diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index c98f0f621d..9929fba82f 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c @@ -951,11 +951,11 @@ int radio_screen(void) freq / 100, freq % 100); FOR_NB_SCREENS(i) screens[i].puts_scroll(0, top_of_screen + 1, buf); - - snprintf(buf, 128, "%s", stereo?str(LANG_CHANNEL_STEREO): - str(LANG_CHANNEL_MONO)); + FOR_NB_SCREENS(i) - screens[i].puts_scroll(0, top_of_screen + 2, buf); + screens[i].puts_scroll(0, top_of_screen + 2, + stereo ? str(LANG_CHANNEL_STEREO) : + str(LANG_CHANNEL_MONO)); snprintf(buf, 128, "%s %s", str(LANG_MODE), radio_mode ? str(LANG_PRESET) : diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index b86c884c7a..ffa4b2df7e 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -965,7 +965,7 @@ static const char* reclist_get_name(int selected_item, void * data, } else { - strlcpy(buffer, str(LANG_RECORDING_FILENAME), buffer_len); + return str(LANG_RECORDING_FILENAME); } break; } @@ -1970,7 +1970,7 @@ static bool f2_rec_screen(void) } while (!exit) { - const char* ptr=NULL; + const char* ptr; FOR_NB_SCREENS(i) { @@ -2090,7 +2090,7 @@ static bool f3_rec_screen(void) bool used = false; int w, h, i; int button; - char *src_str[] = + const char *src_str[] = { str(LANG_SYSFONT_RECORDING_SRC_MIC), str(LANG_SYSFONT_LINE_IN), @@ -2105,8 +2105,7 @@ static bool f3_rec_screen(void) } while (!exit) { - char* ptr=NULL; - ptr = src_str[global_settings.rec_source]; + const char* ptr = src_str[global_settings.rec_source]; FOR_NB_SCREENS(i) { screens[i].clear_display(); -- cgit v1.2.3