]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: use fdisk_{info,warn} on more places
authorKarel Zak <kzak@redhat.com>
Tue, 3 Sep 2013 10:18:33 +0000 (12:18 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Sep 2013 14:47:09 +0000 (16:47 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisks/fdisk-ask.c
fdisks/fdisk.c

index 2d689e558502133c8275ca3a59e8441060be0737..47ed7f5f37f7c335bb0917e5076db29e2c5607db 100644 (file)
@@ -115,7 +115,7 @@ static int ask_number(struct fdisk_context *cxt,
                if (rc == 0 && num >= low && num <= high)
                        return fdisk_ask_number_set_result(ask, num);
 
-               printf(_("Value out of range.\n"));
+               fdisk_warnx(cxt, _("Value out of range."));
        } while (1);
 
        return -1;
@@ -186,7 +186,7 @@ static int ask_offset(struct fdisk_context *cxt,
                                fdisk_ask_number_set_relative(ask, 1);
                        return fdisk_ask_number_set_result(ask, num);
                }
-               printf(_("Value out of range.\n"));
+               fdisk_warnx(cxt, _("Value out of range."));
        } while (1);
 
        return -1;
@@ -284,7 +284,6 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask,
        return rc;
 }
 
-
 struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt)
 {
        const char *q;
index ec0c5447f9e9e46ec40b68133a2465f5d9416980..6cf79485794d9ef6fc0f10043e2e45de1a1e05c4 100644 (file)
@@ -148,16 +148,14 @@ void toggle_dos_compatibility_flag(struct fdisk_context *cxt)
                return;
 
        flag = !fdisk_dos_is_compatible(lb);
-
-       if (flag)
-               printf(_("DOS Compatibility flag is set (DEPRECATED!)\n"));
-       else
-               printf(_("DOS Compatibility flag is not set\n"));
+       fdisk_info(cxt, flag ?
+                       _("DOS Compatibility flag is set (DEPRECATED!)") :
+                       _("DOS Compatibility flag is not set"));
 
        fdisk_dos_enable_compatible(lb, flag);
 
        if (fdisk_is_disklabel(cxt, DOS))
-               fdisk_reset_alignment(cxt);
+               fdisk_reset_alignment(cxt);     /* reset the current label */
 }
 
 void change_partition_type(struct fdisk_context *cxt)
@@ -173,7 +171,7 @@ void change_partition_type(struct fdisk_context *cxt)
 
        org_t = t = fdisk_get_partition_type(cxt, i);
        if (!t)
-                printf(_("Partition %zu does not exist yet!\n"), i + 1);
+                fdisk_warnx(cxt, _("Partition %zu does not exist yet!"), i + 1);
 
         else do {
                t = ask_partition_type(cxt);
@@ -181,11 +179,13 @@ void change_partition_type(struct fdisk_context *cxt)
                        continue;
 
                if (fdisk_set_partition_type(cxt, i, t) == 0) {
-                       printf (_("Changed type of partition '%s' to '%s'\n"),
+                       fdisk_info(cxt,
+                               _("Changed type of partition '%s' to '%s'"),
                                org_t ? org_t->name : _("Unknown"),
                                    t ?     t->name : _("Unknown"));
                } else {
-                       printf (_("Type of partition %zu is unchanged: %s\n"),
+                       fdisk_info(cxt,
+                               _("Type of partition %zu is unchanged: %s"),
                                i + 1,
                                org_t ? org_t->name : _("Unknown"));
                }
@@ -233,8 +233,8 @@ void list_disk_geometry(struct fdisk_context *cxt)
 
 
 #define MAX_PER_LINE   16
-static void
-print_buffer(struct fdisk_context *cxt, unsigned char pbuffer[]) {
+static void print_buffer(struct fdisk_context *cxt, unsigned char pbuffer[])
+{
        unsigned int i, l;
 
        for (i = 0, l = 0; i < cxt->sector_size; i++, l++) {
@@ -469,14 +469,14 @@ int main(int argc, char **argv)
 
                /* Here starts interactive mode, use fdisk_{warn,info,..} functions */
                color_enable(UL_COLOR_GREEN);
-               fdisk_info(cxt, _("Welcome to fdisk (%s).\n"), PACKAGE_STRING);
+               fdisk_info(cxt, _("Welcome to fdisk (%s)."), PACKAGE_STRING);
                color_disable();
                fdisk_info(cxt, _("Changes will remain in memory only, until you decide to write them.\n"
                                  "Be careful before using the write command.\n"));
                fflush(stdout);
 
                if (!fdisk_dev_has_disklabel(cxt)) {
-                       fdisk_warnx(cxt, _("Device does not contain a recognized partition table\n"));
+                       fdisk_warnx(cxt, _("Device does not contain a recognized partition table"));
                        fdisk_create_disklabel(cxt, NULL);
                }