aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-03-27 22:03:24 +0100
committerErwan Velu <erwan.velu@free.fr>2009-03-27 22:03:24 +0100
commitfdc0486c5d47ca692c755b8a03550e42f5f14257 (patch)
tree1d22351eeb72d6401fa6bbb3171d4f3fdab4ee8d
parentee72d1d5f191e2462edfec1c3b9be741633744c6 (diff)
downloadsyslinux.git-fdc0486c5d47ca692c755b8a03550e42f5f14257.tar.gz
syslinux.git-fdc0486c5d47ca692c755b8a03550e42f5f14257.tar.xz
syslinux.git-fdc0486c5d47ca692c755b8a03550e42f5f14257.zip
hdt: prevent unless disk's menu
Impact: none No need to compute disk's menu if no disk are detected
-rw-r--r--com32/hdt/hdt-common.c2
-rw-r--r--com32/hdt/hdt-common.h1
-rw-r--r--com32/hdt/hdt-menu-disk.c8
-rw-r--r--com32/hdt/hdt-menu.c2
-rw-r--r--com32/hdt/hdt-menu.h2
5 files changed, 11 insertions, 4 deletions
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index b2fdf8e7..8ab0f120 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -82,6 +82,7 @@ void init_hardware(struct s_hardware *hardware)
hardware->cpu_detection = false;
hardware->pci_detection = false;
hardware->disk_detection = false;
+ hardware->disks_count=0;
hardware->dmi_detection = false;
hardware->pxe_detection = false;
hardware->vesa_detection = false;
@@ -197,6 +198,7 @@ void detect_disks(struct s_hardware *hardware)
if (get_disk_params(drive, hardware->disk_info) != 0)
continue;
struct diskinfo *d = &hardware->disk_info[drive];
+ hardware->disks_count++;
printf
(" DISK 0x%X: %s : %s %s: sectors=%d, s/t=%d head=%d : EDD=%s\n",
drive, d->aid.model, d->host_bus_type, d->interface_type,
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index 9d6bc5fe..dc783281 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -96,6 +96,7 @@ struct s_hardware {
s_cpu cpu; /* CPU information */
struct pci_domain *pci_domain; /* PCI Devices */
struct diskinfo disk_info[256]; /* Disk Information */
+ int disks_count; /* Number of detected disks */
struct s_pxe pxe;
struct s_vesa vesa;
diff --git a/com32/hdt/hdt-menu-disk.c b/com32/hdt/hdt-menu-disk.c
index 1b273036..02f12f75 100644
--- a/com32/hdt/hdt-menu-disk.c
+++ b/com32/hdt/hdt-menu-disk.c
@@ -152,10 +152,15 @@ int compute_disk_module(struct s_my_menu *menu, int nb_sub_disk_menu,
}
/* Compute the Disks menu */
-void compute_disks(struct s_hdt_menu *menu, struct diskinfo *disk_info)
+void compute_disks(struct s_hdt_menu *menu, struct diskinfo *disk_info, struct s_hardware *hardware)
{
char buffer[MENULEN + 1];
int nb_sub_disk_menu = 0;
+
+ /* No need to compute that menu if no disks were detected */
+ menu->disk_menu.items_count = 0;
+ if (hardware->disks_count == 0) return;
+
for (int i = 0; i < 0xff; i++) {
if (compute_disk_module
((struct s_my_menu*) &(menu->disk_sub_menu), nb_sub_disk_menu, disk_info,
@@ -164,7 +169,6 @@ void compute_disks(struct s_hdt_menu *menu, struct diskinfo *disk_info)
}
menu->disk_menu.menu = add_menu(" Disks ", -1);
- menu->disk_menu.items_count = 0;
for (int i = 0; i < nb_sub_disk_menu; i++) {
snprintf(buffer, sizeof buffer, " Disk <%d> ", i);
diff --git a/com32/hdt/hdt-menu.c b/com32/hdt/hdt-menu.c
index 224974e0..a865e672 100644
--- a/com32/hdt/hdt-menu.c
+++ b/com32/hdt/hdt-menu.c
@@ -153,7 +153,7 @@ void compute_submenus(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
}
compute_processor(&(hdt_menu->cpu_menu), hardware);
- compute_disks(hdt_menu, hardware->disk_info);
+ compute_disks(hdt_menu, hardware->disk_info, hardware);
#ifdef WITH_PCI
compute_PCI(hdt_menu, hardware);
diff --git a/com32/hdt/hdt-menu.h b/com32/hdt/hdt-menu.h
index 7986c863..91809e2d 100644
--- a/com32/hdt/hdt-menu.h
+++ b/com32/hdt/hdt-menu.h
@@ -92,7 +92,7 @@ void compute_kernel(struct s_my_menu *menu, struct s_hardware *hardware);
// Disk Stuff
int compute_disk_module(struct s_my_menu *menu, int nb_sub_disk_menu,
struct diskinfo *d, int disk_number);
-void compute_disks(struct s_hdt_menu *menu, struct diskinfo *disk_info);
+void compute_disks(struct s_hdt_menu *menu, struct diskinfo *disk_info, struct s_hardware *hardware);
// DMI Stuff
void compute_motherboard(struct s_my_menu *menu, s_dmi * dmi);