]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: fix const char mess
authorKarel Zak <kzak@redhat.com>
Thu, 16 Jan 2020 11:56:18 +0000 (12:56 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 23 Jan 2020 14:50:42 +0000 (15:50 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/dos.c
libfdisk/src/gpt.c

index 98314dfa61edc52e82070accc0d63db9a4eb36d0..ae06e179da1d9b1d9897421636e9c8bf7b0cd05d 100644 (file)
@@ -709,7 +709,7 @@ static int dos_create_disklabel(struct fdisk_context *cxt)
 
 static int dos_set_disklabel_id(struct fdisk_context *cxt, const char *str)
 {
-       char *str0 = str;
+       char *buf = NULL;
        unsigned int id, old;
        struct fdisk_dos_label *l;
        int rc = 0;
@@ -723,9 +723,11 @@ static int dos_set_disklabel_id(struct fdisk_context *cxt, const char *str)
        l = self_label(cxt);
        old = mbr_get_id(cxt->firstsector);
 
-       if (!str)
+       if (!str) {
                rc = fdisk_ask_string(cxt,
-                       _("Enter the new disk identifier"), &str);
+                       _("Enter the new disk identifier"), &buf);
+               str = buf;
+       }
        if (!rc) {
                char *end = NULL;
 
@@ -737,8 +739,7 @@ static int dos_set_disklabel_id(struct fdisk_context *cxt, const char *str)
                }
        }
 
-       if (!str0)
-               free(str);
+       free(buf);
        if (rc)
                return -EINVAL;
 
index 9608053a245f283fc1545e673c8bc56a33489c14..06820792b4287087c682b193339e644420f8d5f3 100644 (file)
@@ -2515,11 +2515,13 @@ static int gpt_set_disklabel_id(struct fdisk_context *cxt, const char *str)
 
        gpt = self_label(cxt);
        if (!str) {
+               char *buf = NULL;
+
                if (fdisk_ask_string(cxt,
-                               _("Enter new disk UUID (in 8-4-4-4-12 format)"), &str))
+                               _("Enter new disk UUID (in 8-4-4-4-12 format)"), &buf))
                        return -EINVAL;
-               rc = string_to_guid(str, &uuid);
-               free(str);
+               rc = string_to_guid(buf, &uuid);
+               free(buf);
        } else
                rc = string_to_guid(str, &uuid);