This accidentally fixes a mistake printing the "Partition n is deleted" message as the 'i' variable get decremented or incremented in case of logical partitions. Signed-off-by: Francesco Cosoleto <cosoleto@xxxxxxxxx> --- fdisk/fdisk.c | 36 ++++++++++++++++++++++-------------- 1 files changed, 22 insertions(+), 14 deletions(-) diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index 5b8e24a..d299c4c 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -1584,25 +1584,16 @@ toggle_dos_compatibility_flag(void) { update_sector_offset(); } -static void -delete_partition(int i) { +static void dos_delete_partition(int i) +{ struct pte *pe = &ptes[i]; struct partition *p = pe->part_table; struct partition *q = pe->ext_pointer; -/* Note that for the fifth partition (i == 4) we don't actually - * decrement partitions. - */ - - if (warn_geometry()) - return; /* C/H/S not set */ - pe->changed = 1; + /* Note that for the fifth partition (i == 4) we don't actually + decrement partitions. */ - if (disklabel == SUN_LABEL) - sun_delete_partition(i); - else if (disklabel == SGI_LABEL) - sgi_delete_partition(i); - else if (i < 4) { + if (i < 4) { if (IS_EXTENDED (p->sys_ind) && i == ext_index) { partitions = 4; ptes[ext_index].ext_pointer = NULL; @@ -1646,6 +1637,23 @@ delete_partition(int i) { /* the only logical: clear only */ clear_partition(ptes[i].part_table); } +} + +static void +delete_partition(int i) +{ + if (warn_geometry()) + return; /* C/H/S not set */ + + ptes[i].changed = 1; + + if (disklabel == DOS_LABEL) + dos_delete_partition(i); + else if (disklabel == SUN_LABEL) + sun_delete_partition(i); + else if (disklabel == SGI_LABEL) + sgi_delete_partition(i); + printf(_("Partition %d is deleted\n"), i + 1); } -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html