summaryrefslogtreecommitdiff
path: root/ubifs-utils
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-11-12 10:31:26 +0100
committerRichard Weinberger <richard@nod.at>2015-11-12 10:50:04 +0100
commit978494f76e110154a3035cb1cdbe92965c5552ce (patch)
tree6381c3e08507114feda155f92d9f5f8c101bef4b /ubifs-utils
parentf53b9de7f3383d7cf7b27bc08d5a503069c59457 (diff)
mkfs.ubifs: simplify make_path with xasprintf
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'ubifs-utils')
-rw-r--r--ubifs-utils/mkfs.ubifs/mkfs.ubifs.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
index 049219b..a99c613 100644
--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
@@ -227,13 +227,9 @@ static char *make_path(const char *dir, const char *name)
{
char *s;
- s = malloc(strlen(dir) + strlen(name) + 2);
- if (!s)
- return NULL;
- strcpy(s, dir);
- if (dir[strlen(dir) - 1] != '/')
- strcat(s, "/");
- strcat(s, name);
+ xasprintf(&s, "%s%s%s",
+ dir, dir[strlen(dir) - 1] == '/' ? "" : "/", name);
+
return s;
}