aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2015-02-03 13:06:20 +0100
committerKarel Zak <kzak@redhat.com>2015-02-03 13:06:20 +0100
commit29e9b787da11b279c817731e6d321ecfcedc7ba3 (patch)
treecb60d719f36e38eb5b04115e446c360ef77656cf
parent1bb387bdbd25b241929ddf5e28f187f4968677a1 (diff)
downloadutil-linux-playground-29e9b787da11b279c817731e6d321ecfcedc7ba3.tar.gz
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 <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--disk-utils/cfdisk.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c
index 911b6c8b44..d4e533f034 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)