diff options
author | Vaclav Dolezal | 2017-12-19 10:39:19 +0100 |
---|---|---|
committer | Vaclav Dolezal | 2017-12-19 10:48:13 +0100 |
commit | c116524184699ed30a823b3994d2e97684bb4505 (patch) | |
tree | 068fc9487503c91d72c943829e30288c01ff62e2 /libfdisk/src | |
parent | libfdisk: allocate enough bytes for ucs2 to utf8 encoding (diff) | |
download | kernel-qcow2-util-linux-c116524184699ed30a823b3994d2e97684bb4505.tar.gz kernel-qcow2-util-linux-c116524184699ed30a823b3994d2e97684bb4505.tar.xz kernel-qcow2-util-linux-c116524184699ed30a823b3994d2e97684bb4505.zip |
libfdisk: return bytes processed from gpt_entry_set_name(), process rc
Made gpt_entry_set_name() return number of utf8 bytes processed on
success, so info message about change can be accurate.
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Diffstat (limited to 'libfdisk/src')
-rw-r--r-- | libfdisk/src/gpt.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index 8598dbd2e..543b97199 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -420,7 +420,7 @@ static int gpt_entry_set_name(struct gpt_entry *e, char *str) for (i = 0; i < GPT_PART_NAME_LEN; i++) e->name[i] = cpu_to_le16(name[i]); - return 0; + return (int)((char *) in - str); } static int gpt_entry_set_uuid(struct gpt_entry *e, char *str) @@ -1900,11 +1900,14 @@ static int gpt_set_partition(struct fdisk_context *cxt, size_t n, } if (pa->name) { + int len; char *old = encode_to_utf8((unsigned char *)e->name, sizeof(e->name)); - gpt_entry_set_name(e, pa->name); - - fdisk_info(cxt, _("Partition name changed from '%s' to '%.*s'."), - old, (int) GPT_PART_NAME_LEN, pa->name); + len = gpt_entry_set_name(e, pa->name); + if (len < 0) + fdisk_info(cxt, _("Failed to translate partition name, name not changed.")); + else + fdisk_info(cxt, _("Partition name changed from '%s' to '%.*s'."), + old, len, pa->name); free(old); } |