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>
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