From: Pali Rohár Date: Tue, 6 Jul 2021 13:35:25 +0000 (+0200) Subject: fdisk: do not print error message when partition reordering is not needed X-Git-Tag: v2.38-rc1~373^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b948bbf991a2b019a94bba980b248a80a99f468f;p=thirdparty%2Futil-linux.git fdisk: do not print error message when partition reordering is not needed Option 'f' currently prints following RED error message: Nothing to do. Ordering is correct already. Failed to fix partitions order. This change removes RED error message when ordering is already correct. Signed-off-by: Pali Rohár --- diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c index 9f09eea83e..42bffb5587 100644 --- a/disk-utils/fdisk-menu.c +++ b/disk-utils/fdisk-menu.c @@ -636,10 +636,17 @@ static int generic_menu_cb(struct fdisk_context **cxt0, break; case 'f': rc = fdisk_reorder_partitions(cxt); - if (rc) + switch (rc) { + default: fdisk_warnx(cxt, _("Failed to fix partitions order.")); - else + break; + case 0: fdisk_info(cxt, _("Partitions order fixed.")); + break; + case 1: + fdisk_info(cxt, _("Nothing to do. Ordering is correct already.")); + break; + } break; case 'r': rc = fdisk_enable_details(cxt, 0); diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index eabedcc572..ce545f8571 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -2442,10 +2442,8 @@ static int dos_reorder(struct fdisk_context *cxt) struct pte *pei, *pek; size_t i,k; - if (!wrong_p_order(cxt, NULL)) { - fdisk_info(cxt, _("Nothing to do. Ordering is correct already.")); + if (!wrong_p_order(cxt, NULL)) return 1; - } while ((i = wrong_p_order(cxt, &k)) != 0 && i < 4) { /* partition i should have come earlier, move it */ diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index 5bda051de5..3ab0e74ff5 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -3097,10 +3097,8 @@ static int gpt_reorder(struct fdisk_context *cxt) (const void *) gpt_get_entry(gpt, i), (const void *) gpt_get_entry(gpt, i + 1)) > 0; - if (!mess) { - fdisk_info(cxt, _("Nothing to do. Ordering is correct already.")); + if (!mess) return 1; - } qsort(gpt->ents, nparts, sizeof(struct gpt_entry), gpt_entry_cmp_start);