diff options
| author | Hristo Kovachev <bger@rockbox.org> | 2006-04-03 10:06:39 +0000 |
|---|---|---|
| committer | Hristo Kovachev <bger@rockbox.org> | 2006-04-03 10:06:39 +0000 |
| commit | f709ad77dac94462832f2fb025878285745d4739 (patch) | |
| tree | 6ccbd17beb48707598a303bb97e0f6a3a0a61cea /apps | |
| parent | 38deb8f13a9896f2d6eb884c6a8bbc9b10001255 (diff) | |
| download | rockbox-f709ad77dac94462832f2fb025878285745d4739.zip rockbox-f709ad77dac94462832f2fb025878285745d4739.tar.gz rockbox-f709ad77dac94462832f2fb025878285745d4739.tar.bz2 rockbox-f709ad77dac94462832f2fb025878285745d4739.tar.xz | |
FMRadio: Zero the presets struct on new "preset scan", also replace the hardcoded .name's length with a define
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9452 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/recorder/radio.c | 29 | ||||
| -rw-r--r-- | apps/recorder/radio.h | 4 |
2 files changed, 19 insertions, 14 deletions
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 3fef950..c1e5d9a 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c @@ -1086,8 +1086,8 @@ void radio_load_presets(char *filename) if(f) /* For backwards compatibility */ { presets[num_presets].frequency = f; - strncpy(presets[num_presets].name, name, 27); - presets[num_presets].name[27] = 0; + strncpy(presets[num_presets].name, name, MAX_FMPRESET_LEN); + presets[num_presets].name[MAX_FMPRESET_LEN] = 0; num_presets++; } } @@ -1119,15 +1119,15 @@ static void rebuild_preset_menu(void) bool radio_add_preset(void) { - char buf[27]; + char buf[MAX_FMPRESET_LEN]; if(num_presets < MAX_PRESETS) { - memset(buf, 0, 27); + memset(buf, 0, MAX_FMPRESET_LEN); - if (!kbd_input(buf, 27)) + if (!kbd_input(buf, MAX_FMPRESET_LEN)) { - buf[27] = 0; + buf[MAX_FMPRESET_LEN] = 0; strcpy(presets[num_presets].name, buf); presets[num_presets].frequency = curr_freq; #ifdef FM_PRESET_ADD /* only for archos */ @@ -1173,13 +1173,13 @@ static int handle_radio_presets_menu_cb(int key, int m) static bool radio_edit_preset(void) { int pos = menu_cursor(preset_menu); - char buf[27]; + char buf[MAX_FMPRESET_LEN]; - strncpy(buf, menu_description(preset_menu, pos), 27); + strncpy(buf, menu_description(preset_menu, pos), MAX_FMPRESET_LEN); - if (!kbd_input(buf, 27)) + if (!kbd_input(buf, MAX_FMPRESET_LEN)) { - buf[27] = 0; + buf[MAX_FMPRESET_LEN] = 0; strcpy(presets[pos].name, buf); presets_changed = true; } @@ -1459,7 +1459,7 @@ static bool toggle_radio_mode(void) static bool scan_presets(void) { bool tuned = false, do_scan = true; - char buf[27]; + char buf[MAX_FMPRESET_LEN]; int freq, i; if(num_presets > 0) /* Do that to avoid 2 questions. */ @@ -1469,13 +1469,15 @@ static bool scan_presets(void) { curr_freq = MIN_FREQ; num_presets = 0; + memset(presets, 0, sizeof(presets)); while(curr_freq <= MAX_FREQ) { if (num_presets >= MAX_PRESETS) break; freq = curr_freq /100000; - snprintf(buf, 27, str(LANG_FM_SCANNING), freq/10, freq % 10); + snprintf(buf, MAX_FMPRESET_LEN, str(LANG_FM_SCANNING), + freq/10, freq % 10); gui_syncsplash(0, true, buf); /* Tune in and delay */ @@ -1491,7 +1493,8 @@ static bool scan_presets(void) /* add preset */ if(tuned){ - snprintf(buf, 27, str(LANG_FM_DEFAULT_PRESET_NAME),freq/10, freq % 10); + snprintf(buf, MAX_FMPRESET_LEN, + str(LANG_FM_DEFAULT_PRESET_NAME),freq/10, freq % 10); strcpy(presets[num_presets].name,buf); presets[num_presets].frequency = curr_freq; num_presets++; diff --git a/apps/recorder/radio.h b/apps/recorder/radio.h index 4763d11..86ce04c 100644 --- a/apps/recorder/radio.h +++ b/apps/recorder/radio.h @@ -34,10 +34,12 @@ void radio_stop(void); bool radio_hardware_present(void); int get_radio_status(void); +#define MAX_FMPRESET_LEN 27 + struct fmstation { int frequency; /* In Hz */ - char name[28]; + char name[MAX_FMPRESET_LEN+1]; }; #endif |