From 29e9b787da11b279c817731e6d321ecfcedc7ba3 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 3 Feb 2015 13:06:20 +0100 Subject: [PATCH] cfdisk: improve ui_get_size() warnings - don't reset to default after error - clean previous warnings after users response - remove unnecessary warning Reported-by: Benno Schulenberg Signed-off-by: Karel Zak --- disk-utils/cfdisk.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c index 911b6c8b4..d4e533f03 100644 --- a/disk-utils/cfdisk.c +++ b/disk-utils/cfdisk.c @@ -656,6 +656,12 @@ static void ui_warn(const char *fmt, ...) free(fmt_m); } +static void ui_clean_warn(void) +{ + move(WARN_LINE, 0); + clrtoeol(); +} + static int __attribute__((__noreturn__)) ui_errx(int rc, const char *fmt, ...) { va_list ap; @@ -1522,14 +1528,17 @@ static int ui_get_size(struct cfdisk *cf, const char *prompt, uintmax_t *res, ui_clean_info(); + snprintf(buf, sizeof(buf), "%s", dflt); + do { int pwr = 0, insec = 0; - snprintf(buf, sizeof(buf), "%s", dflt); rc = ui_get_string(cf, prompt, _("May be followed by M for MiB, G for GiB, " "T for TiB, or S for sectors."), buf, sizeof(buf)); + ui_clean_warn(); + if (rc == 0) { ui_warnx(_("Please, specify size.")); continue; /* nothing specified */ @@ -1970,10 +1979,6 @@ static int main_menu_action(struct cfdisk *cf, int key) break; secs = size / fdisk_get_sector_size(cf->cxt); - if (size && secs < 1) { - warn = _("Too small partition size specified."); - break; - } npa = fdisk_new_partition(); if (!npa)