]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cfdisk: improve ui_get_size() warnings
authorKarel Zak <kzak@redhat.com>
Tue, 3 Feb 2015 12:06:20 +0000 (13:06 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Feb 2015 12:06:20 +0000 (13:06 +0100)
 - don't reset to default after error
 - clean previous warnings after users response
 - remove unnecessary warning

Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/cfdisk.c

index 911b6c8b44eac661732705f87fce50787d19bf44..d4e533f034f54bbabde4859753d523cd75154125 100644 (file)
@@ -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)