libfdisk: fix const char mess

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2020-01-16 12:56:18 +01:00
parent 65e27d545c
commit 3c3b7648c9
2 changed files with 11 additions and 8 deletions

View 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;

View 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);