]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: fix error message on 'd' command
authorKarel Zak <kzak@redhat.com>
Wed, 1 Aug 2018 07:29:12 +0000 (09:29 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 1 Aug 2018 07:29:12 +0000 (09:29 +0200)
Command (m for help): d
No partition is defined yet!
Could not delete partition 93840461057817    <--- !

Don't print 'Could not delete..' if no partition is defined yet.

Addresses: https://github.com/karelzak/util-linux/issues/667
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fdisk-menu.c

index b2cb0d7cb9571cbd2e77cdcc421cb601ac127a58..a6f43515fb4dd03b28528d21df80d2c754930fc8 100644 (file)
@@ -650,8 +650,10 @@ static int generic_menu_cb(struct fdisk_context **cxt0,
        switch (ent->key) {
        case 'd':
                rc = fdisk_ask_partnum(cxt, &n, FALSE);
-               if (!rc)
-                       rc = fdisk_delete_partition(cxt, n);
+               if (rc)
+                       break; /* no partitions yet (or ENOMEM, ...) */
+
+               rc = fdisk_delete_partition(cxt, n);
                if (rc)
                        fdisk_warnx(cxt, _("Could not delete partition %zu"), n + 1);
                else