]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: avoid an intermediate variable in command_prompt()
authorFrancesco Cosoleto <cosoleto@gmail.com>
Thu, 15 Dec 2011 19:02:46 +0000 (20:02 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 16 Dec 2011 13:04:07 +0000 (14:04 +0100)
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
fdisk/fdisk.c

index 53eed250a38c2c26c8cff822b6880319bf0d2d96..acf0e673d8f3f91633da02e8f417ae096d0f2f58 100644 (file)
@@ -1635,6 +1635,9 @@ static void dos_delete_partition(int i)
 static void
 delete_partition(int i)
 {
+       if (i < 0)
+               return;
+
        if (warn_geometry())
                return;         /* C/H/S not set */
 
@@ -2869,7 +2872,7 @@ unknown_command(int c) {
 
 static void command_prompt(void)
 {
-       int c, j;
+       int c;
 
        if (disklabel == OSF_LABEL) {
                putchar('\n');
@@ -2921,9 +2924,7 @@ static void command_prompt(void)
                                unknown_command(c);
                        break;
                case 'd':
-                       j = get_existing_partition(1, partitions);
-                       if (j >= 0)
-                               delete_partition(j);
+                       delete_partition(get_existing_partition(1, partitions));
                        break;
                case 'i':
                        if (disklabel == SGI_LABEL)