2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 22:35:33 +00:00

mount: use xstrcat() in attach_option()

v2:
Check for empty string is simplified

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Stanislav Kinsburskiy
2015-12-17 15:29:07 +03:00
committed by Pavel Emelyanov
parent 16fd19895c
commit 696eeef6b4

23
mount.c
View File

@@ -1163,24 +1163,11 @@ out:
static int attach_option(struct mount_info *pm, char *opt) static int attach_option(struct mount_info *pm, char *opt)
{ {
char *buf; if (pm->options[0] == '\0')
int len, olen; pm->options = xstrcat(pm->options, "%s", opt);
else
len = strlen(pm->options); pm->options = xstrcat(pm->options, ",%s", opt);
olen = strlen(opt); return pm->options ? 0 : -1;
buf = xrealloc(pm->options, len + olen + 2);
if (buf == NULL)
return -1;
if (len && buf[len - 1] != ',') {
buf[len] = ',';
len++;
}
memcpy(buf + len, opt, olen + 1);
pm->options = buf;
return 0;
} }
/* Is it mounted w or w/o the newinstance option */ /* Is it mounted w or w/o the newinstance option */