All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: linux-mtd@lists.infradead.org
Cc: kernel@pengutronix.de, Sascha Hauer <s.hauer@pengutronix.de>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH v2 3/5] mkfs.ubifs: simplify make_path with xasprintf
Date: Thu, 12 Nov 2015 10:31:26 +0100	[thread overview]
Message-ID: <1447320688-3086-4-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1447320688-3086-1-git-send-email-mkl@pengutronix.de>

From: Sascha Hauer <s.hauer@pengutronix.de>

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>
---
 ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
index 049219b52cc5..a99c61382304 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;
 }
 
-- 
2.6.1

  parent reply	other threads:[~2015-11-12  9:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12  9:31 [PATCH v2 0/5] mkfs.ubifs: cleanups + extended attribute support Marc Kleine-Budde
2015-11-12  9:31 ` [PATCH v2 1/5] mkfs.ubifs: change add_directory argument to 'existing' Marc Kleine-Budde
2015-11-12  9:31 ` [PATCH v2 2/5] mkfs.ubifs: use xmalloc/xzalloc for allocating memory Marc Kleine-Budde
2015-11-12  9:31 ` Marc Kleine-Budde [this message]
2015-11-12  9:31 ` [PATCH v2 4/5] mkfs.ubifs: Add extended attribute support Marc Kleine-Budde
2015-11-12  9:31 ` [PATCH v2 5/5] mkfs.ubifs: Optionally create extended attribute with inode number Marc Kleine-Budde
2015-11-12  9:53 ` [PATCH v2 0/5] mkfs.ubifs: cleanups + extended attribute support Richard Weinberger
2015-11-12  9:56   ` Marc Kleine-Budde
2015-11-12 18:40     ` Brian Norris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447320688-3086-4-git-send-email-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=kernel@pengutronix.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.