From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: jdike@addtoit.com, richard@nod.at
Cc: user-mode-linux-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: [PATCH] um: umid: Use strdup to simplify code
Date: Wed, 8 Jul 2015 21:15:47 +0200 [thread overview]
Message-ID: <1436382947-13181-1-git-send-email-christophe.jaillet@wanadoo.fr> (raw)
Replace a malloc+strcpy by an equivalent strdup in order to improve
readability.
Turn a some spaces into a tab to be consistent with the rest of the code.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
arch/um/os-Linux/umid.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c
index c1dc892..cc9ac2e 100644
--- a/arch/um/os-Linux/umid.c
+++ b/arch/um/os-Linux/umid.c
@@ -48,15 +48,14 @@ static int __init make_uml_dir(void)
strlcat(dir, "/", sizeof(dir));
err = -ENOMEM;
- uml_dir = malloc(strlen(dir) + 1);
+ uml_dir = strdup(dir);
if (uml_dir == NULL) {
- printf("make_uml_dir : malloc failed, errno = %d\n", errno);
+ printf("make_uml_dir : strdup failed, errno = %d\n", errno);
goto err;
}
- strcpy(uml_dir, dir);
if ((mkdir(uml_dir, 0777) < 0) && (errno != EEXIST)) {
- printf("Failed to mkdir '%s': %s\n", uml_dir, strerror(errno));
+ printf("Failed to mkdir '%s': %s\n", uml_dir, strerror(errno));
err = -errno;
goto err_free;
}
--
2.1.4
next reply other threads:[~2015-07-08 19:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 19:15 Christophe JAILLET [this message]
2015-07-08 19:19 ` [PATCH] um: umid: Use strdup to simplify code Richard Weinberger
2015-07-09 5:06 ` [PATCH 1/2] um: umid: Use tab instead of spaces Christophe JAILLET
2015-07-09 5:06 ` [PATCH 2/2] um: umid: Use strdup to simplify code Christophe JAILLET
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=1436382947-13181-1-git-send-email-christophe.jaillet@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=jdike@addtoit.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=richard@nod.at \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).