info_menu: Don't print a line for volumes that don't exist

This is an example of what could happen:

 HD1: Not present
 ouping Not present
 ouping Not present
 ouping Not present

We have up to 4 fixed volume slots (==partitions) per drive, but
shouldn't display an entry if the slot isn't used, ie the normal case.
Instead, we _were_ displaying a partially-unitialized entry!

There is a special case for targets that support multiple *drives*, in
that we want to show 'not present' for the first volume slot of the
2nd drive.

Change-Id: I717edd305cd654ff4e13ba9ffb57e7a4c9935c17
This commit is contained in:
Solomon Peachy 2024-11-23 19:47:45 -05:00
parent 213686b55c
commit a41a001258

View file

@ -132,13 +132,13 @@ static int show_legal(void)
#define SIZE_FMT "%s %s" #define SIZE_FMT "%s %s"
struct info_data struct info_data
{ {
sector_t size[NUM_VOLUMES]; sector_t size[NUM_VOLUMES];
sector_t free[NUM_VOLUMES]; sector_t free[NUM_VOLUMES];
unsigned long name[NUM_VOLUMES]; unsigned long name[NUM_VOLUMES];
bool new_data; bool new_data;
}; };
enum infoscreenorder enum infoscreenorder
{ {
INFO_BATTERY = 0, INFO_BATTERY = 0,
@ -171,6 +171,7 @@ static int refresh_data(struct info_data *info)
int max = -1; int max = -1;
#endif #endif
int drive = 0; int drive = 0;
int special = 0;
for (i = 0 ; CHECK_VOL(i) ; i++) { for (i = 0 ; CHECK_VOL(i) ; i++) {
#endif #endif
volume_size(IF_MV(i,) &info->size[i], &info->free[i]); volume_size(IF_MV(i,) &info->size[i], &info->free[i]);
@ -178,19 +179,32 @@ static int refresh_data(struct info_data *info)
#ifdef HAVE_MULTIDRIVE #ifdef HAVE_MULTIDRIVE
drive = volume_drive(i); drive = volume_drive(i);
#endif #endif
if (drive > 0 || info->size[i] == 0) if (drive > 0)
info->name[i] = LANG_DISK_NAME_MMC; info->name[i] = LANG_DISK_NAME_MMC;
else else
#endif #endif
info->name[i] = LANG_DISK_NAME_INTERNAL; info->name[i] = LANG_DISK_NAME_INTERNAL;
#ifdef HAVE_MULTIDRIVE #ifdef HAVE_MULTIDRIVE
if (drive > max) if (drive > max) {
max = drive; max = drive;
else if (drive < max) } else if (drive < max) {
break; if (max == 0) {
#elif defined(HAVE_MULTIVOLUME) && (defined(HAVE_HOTSWAP) || defined(HAVE_HOTSWAP) || defined(HAVE_DIRCACHE) || defined(HAVE_BOOTDATA)) /* Special case, make sure we display a single entry for
if (volume_partition(i) == -1) secondary drive too */
break; special = 1;
}
#endif
#if defined(HAVE_MULTIVOLUME) && (defined(HAVE_HOTSWAP) || defined(HAVE_HOTSWAP) || defined(HAVE_DIRCACHE) || defined(HAVE_BOOTDATA))
if (volume_partition(i) == -1) {
if (special)
info->name[i] = LANG_DISK_NAME_MMC;
else
info->name[i] = 0;
break; /* ie stop when we run out of valid partitions */
}
#endif
#ifdef HAVE_MULTIDRIVE
}
#endif #endif
#ifdef HAVE_MULTIVOLUME #ifdef HAVE_MULTIVOLUME
} }
@ -301,7 +315,7 @@ static int info_speak_item(int selected_item, void * data)
talk_id(LANG_DISK_SIZE_INFO, true); talk_id(LANG_DISK_SIZE_INFO, true);
output_dyn_value(NULL, 0, info->size[i], kibyte_units, 3, true); output_dyn_value(NULL, 0, info->size[i], kibyte_units, 3, true);
#ifdef HAVE_MULTIVOLUME #ifdef HAVE_MULTIVOLUME
} else { } else if (info->name[i]) {
talk_ids(true, info->name[i], LANG_NOT_PRESENT); talk_ids(true, info->name[i], LANG_NOT_PRESENT);
#endif #endif
} }
@ -335,7 +349,7 @@ static int info_action_callback(int action, struct gui_synclist *lists)
info->new_data = true; info->new_data = true;
splash(0, ID2P(LANG_SCANNING_DISK)); splash(0, ID2P(LANG_SCANNING_DISK));
#if (CONFIG_PLATFORM & PLATFORM_NATIVE) #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
for (int i = 0; i < NUM_VOLUMES; i++) for (int i = 0; CHECK_VOL(i); i++)
volume_recalc_free(IF_MV(i)); volume_recalc_free(IF_MV(i));
#endif #endif
gui_synclist_speak_item(lists); gui_synclist_speak_item(lists);
@ -420,13 +434,13 @@ static int info_action_callback(int action, struct gui_synclist *lists)
} }
#endif #endif
/* INFO_DISK, capacity/free on internal */ /* INFO_DISK, capacity/free on internal */
for (int i = 0; i < NUM_VOLUMES; i++) { for (int i = 0; CHECK_VOL(i) ; i++) {
if (info->size[i]) { if (info->size[i]) {
output_dyn_value(s1, sizeof s1, info->free[i], kibyte_units, 3, true); output_dyn_value(s1, sizeof s1, info->free[i], kibyte_units, 3, true);
output_dyn_value(s2, sizeof s2, info->size[i], kibyte_units, 3, true); output_dyn_value(s2, sizeof s2, info->size[i], kibyte_units, 3, true);
simplelist_addline("%s %s/%s", str(info->name[i]), s1, s2); simplelist_addline("%s %s/%s", str(info->name[i]), s1, s2);
#ifdef HAVE_MULTIVOLUME #ifdef HAVE_MULTIVOLUME
} else { } else if (info->name[i]) {
simplelist_addline("%s %s", str(info->name[i]), simplelist_addline("%s %s", str(info->name[i]),
str(LANG_NOT_PRESENT)); str(LANG_NOT_PRESENT));
#endif #endif