hdt: Don't show partition header if not needed
authorPierre-Alexandre Meyer <pierre@mouraf.org>
Thu, 6 Aug 2009 02:19:59 +0000 (19:19 -0700)
committerPierre-Alexandre Meyer <pierre@mouraf.org>
Thu, 6 Aug 2009 02:26:49 +0000 (19:26 -0700)
Don't blindly print the partition header: check if we are able to iterate
through them first.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
com32/hdt/hdt-cli-disk.c
com32/hdt/hdt-menu-disk.c

index 197d170..07f7293 100644 (file)
@@ -78,6 +78,9 @@ static void show_partition_information(struct driveinfo *drive_info,
        else
                memset(size, 0, sizeof size);
 
+       if (i == 1)
+               more_printf("   #  B       Start         End    Size Id Type\n");
+
        get_label(ptab->ostype, &parttype);
        more_printf("  %2d  %s %11d %11d %s %02X %s",
                    i, (ptab->active_flag == 0x80) ? "x" : " ",
@@ -143,7 +146,6 @@ void main_show_disk(int argc, char **argv,
                remove_spaces(d->edd_params.host_bus_type),
                remove_spaces(d->edd_params.interface_type));
 
-       more_printf("   #  B       Start         End    Size Id Type\n");
        if (parse_partition_table(d, &show_partition_information) == -1) {
                get_error(&error_buffer);
                more_printf("%s\n", error_buffer);
index 05aef70..487d1e4 100644 (file)
@@ -48,6 +48,9 @@ static void show_partition_information(struct driveinfo *drive_info,
        char menu_title[MENULEN + 1];
        char menu_title_ref[MENULEN + 1];
 
+       if (nb_partitions_seen == 1)
+               add_sep();
+
        memset(menu_title,0,sizeof menu_title);
        memset(menu_title_ref,0,sizeof menu_title_ref);
        snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d",
@@ -204,7 +207,6 @@ static int compute_disk_module(struct s_my_menu *menu, int nb_sub_disk_menu,
   add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
   menu[nb_sub_disk_menu].items_count++;
 
-  add_sep();
   dn=disk_number;
 
   parse_partition_table(&d[disk_number], &show_partition_information);