From: Francesco Cosoleto <cosoleto@gmail.com>
To: util-linux@vger.kernel.org
Cc: Francesco Cosoleto <cosoleto@gmail.com>
Subject: [PATCH 3/3] fdisk: split delete_partition() off from dos_delete_partition()
Date: Mon, 14 Nov 2011 14:47:19 +0100 [thread overview]
Message-ID: <1321278439-9392-3-git-send-email-cosoleto@gmail.com> (raw)
In-Reply-To: <1321278439-9392-1-git-send-email-cosoleto@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2011-11-14 13:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-14 13:47 [PATCH 1/3] fdisk: use ngettext() in str_units() for plural forms Francesco Cosoleto
2011-11-14 13:47 ` [PATCH 2/3] fdisk: avoid segfault validating a sgi label (boot/swap not set) Francesco Cosoleto
2011-11-14 14:23 ` Karel Zak
2011-11-14 16:06 ` Francesco Cosoleto
2011-11-14 13:47 ` Francesco Cosoleto [this message]
2011-11-14 14:23 ` [PATCH 3/3] fdisk: split delete_partition() off from dos_delete_partition() Karel Zak
2011-11-14 14:08 ` [PATCH 1/3] fdisk: use ngettext() in str_units() for plural forms Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1321278439-9392-3-git-send-email-cosoleto@gmail.com \
--to=cosoleto@gmail.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).