diff options
Diffstat (limited to 'apps/recorder')
-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 3fef9507c1..c1e5d9a8d2 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c | |||
@@ -1086,8 +1086,8 @@ void radio_load_presets(char *filename) | |||
1086 | if(f) /* For backwards compatibility */ | 1086 | if(f) /* For backwards compatibility */ |
1087 | { | 1087 | { |
1088 | presets[num_presets].frequency = f; | 1088 | presets[num_presets].frequency = f; |
1089 | strncpy(presets[num_presets].name, name, 27); | 1089 | strncpy(presets[num_presets].name, name, MAX_FMPRESET_LEN); |
1090 | presets[num_presets].name[27] = 0; | 1090 | presets[num_presets].name[MAX_FMPRESET_LEN] = 0; |
1091 | num_presets++; | 1091 | num_presets++; |
1092 | } | 1092 | } |
1093 | } | 1093 | } |
@@ -1119,15 +1119,15 @@ static void rebuild_preset_menu(void) | |||
1119 | 1119 | ||
1120 | bool radio_add_preset(void) | 1120 | bool radio_add_preset(void) |
1121 | { | 1121 | { |
1122 | char buf[27]; | 1122 | char buf[MAX_FMPRESET_LEN]; |
1123 | 1123 | ||
1124 | if(num_presets < MAX_PRESETS) | 1124 | if(num_presets < MAX_PRESETS) |
1125 | { | 1125 | { |
1126 | memset(buf, 0, 27); | 1126 | memset(buf, 0, MAX_FMPRESET_LEN); |
1127 | 1127 | ||
1128 | if (!kbd_input(buf, 27)) | 1128 | if (!kbd_input(buf, MAX_FMPRESET_LEN)) |
1129 | { | 1129 | { |
1130 | buf[27] = 0; | 1130 | buf[MAX_FMPRESET_LEN] = 0; |
1131 | strcpy(presets[num_presets].name, buf); | 1131 | strcpy(presets[num_presets].name, buf); |
1132 | presets[num_presets].frequency = curr_freq; | 1132 | presets[num_presets].frequency = curr_freq; |
1133 | #ifdef FM_PRESET_ADD /* only for archos */ | 1133 | #ifdef FM_PRESET_ADD /* only for archos */ |
@@ -1173,13 +1173,13 @@ static int handle_radio_presets_menu_cb(int key, int m) | |||
1173 | static bool radio_edit_preset(void) | 1173 | static bool radio_edit_preset(void) |
1174 | { | 1174 | { |
1175 | int pos = menu_cursor(preset_menu); | 1175 | int pos = menu_cursor(preset_menu); |
1176 | char buf[27]; | 1176 | char buf[MAX_FMPRESET_LEN]; |
1177 | 1177 | ||
1178 | strncpy(buf, menu_description(preset_menu, pos), 27); | 1178 | strncpy(buf, menu_description(preset_menu, pos), MAX_FMPRESET_LEN); |
1179 | 1179 | ||
1180 | if (!kbd_input(buf, 27)) | 1180 | if (!kbd_input(buf, MAX_FMPRESET_LEN)) |
1181 | { | 1181 | { |
1182 | buf[27] = 0; | 1182 | buf[MAX_FMPRESET_LEN] = 0; |
1183 | strcpy(presets[pos].name, buf); | 1183 | strcpy(presets[pos].name, buf); |
1184 | presets_changed = true; | 1184 | presets_changed = true; |
1185 | } | 1185 | } |
@@ -1459,7 +1459,7 @@ static bool toggle_radio_mode(void) | |||
1459 | static bool scan_presets(void) | 1459 | static bool scan_presets(void) |
1460 | { | 1460 | { |
1461 | bool tuned = false, do_scan = true; | 1461 | bool tuned = false, do_scan = true; |
1462 | char buf[27]; | 1462 | char buf[MAX_FMPRESET_LEN]; |
1463 | int freq, i; | 1463 | int freq, i; |
1464 | 1464 | ||
1465 | if(num_presets > 0) /* Do that to avoid 2 questions. */ | 1465 | if(num_presets > 0) /* Do that to avoid 2 questions. */ |
@@ -1469,13 +1469,15 @@ static bool scan_presets(void) | |||
1469 | { | 1469 | { |
1470 | curr_freq = MIN_FREQ; | 1470 | curr_freq = MIN_FREQ; |
1471 | num_presets = 0; | 1471 | num_presets = 0; |
1472 | memset(presets, 0, sizeof(presets)); | ||
1472 | while(curr_freq <= MAX_FREQ) | 1473 | while(curr_freq <= MAX_FREQ) |
1473 | { | 1474 | { |
1474 | if (num_presets >= MAX_PRESETS) | 1475 | if (num_presets >= MAX_PRESETS) |
1475 | break; | 1476 | break; |
1476 | 1477 | ||
1477 | freq = curr_freq /100000; | 1478 | freq = curr_freq /100000; |
1478 | snprintf(buf, 27, str(LANG_FM_SCANNING), freq/10, freq % 10); | 1479 | snprintf(buf, MAX_FMPRESET_LEN, str(LANG_FM_SCANNING), |
1480 | freq/10, freq % 10); | ||
1479 | gui_syncsplash(0, true, buf); | 1481 | gui_syncsplash(0, true, buf); |
1480 | 1482 | ||
1481 | /* Tune in and delay */ | 1483 | /* Tune in and delay */ |
@@ -1491,7 +1493,8 @@ static bool scan_presets(void) | |||
1491 | 1493 | ||
1492 | /* add preset */ | 1494 | /* add preset */ |
1493 | if(tuned){ | 1495 | if(tuned){ |
1494 | snprintf(buf, 27, str(LANG_FM_DEFAULT_PRESET_NAME),freq/10, freq % 10); | 1496 | snprintf(buf, MAX_FMPRESET_LEN, |
1497 | str(LANG_FM_DEFAULT_PRESET_NAME),freq/10, freq % 10); | ||
1495 | strcpy(presets[num_presets].name,buf); | 1498 | strcpy(presets[num_presets].name,buf); |
1496 | presets[num_presets].frequency = curr_freq; | 1499 | presets[num_presets].frequency = curr_freq; |
1497 | num_presets++; | 1500 | num_presets++; |
diff --git a/apps/recorder/radio.h b/apps/recorder/radio.h index 4763d117f8..86ce04c4b9 100644 --- a/apps/recorder/radio.h +++ b/apps/recorder/radio.h | |||
@@ -34,10 +34,12 @@ void radio_stop(void); | |||
34 | bool radio_hardware_present(void); | 34 | bool radio_hardware_present(void); |
35 | int get_radio_status(void); | 35 | int get_radio_status(void); |
36 | 36 | ||
37 | #define MAX_FMPRESET_LEN 27 | ||
38 | |||
37 | struct fmstation | 39 | struct fmstation |
38 | { | 40 | { |
39 | int frequency; /* In Hz */ | 41 | int frequency; /* In Hz */ |
40 | char name[28]; | 42 | char name[MAX_FMPRESET_LEN+1]; |
41 | }; | 43 | }; |
42 | 44 | ||
43 | #endif | 45 | #endif |