[CRIU] [PATCH 5/9] Use xstrdup whether possible

Kir Kolyshkin kir at openvz.org
Mon Nov 7 13:37:49 PST 2016


Using xstrdup lets us have an error message printed if malloc() fails.

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 criu/files-reg.c | 2 +-
 criu/plugin.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/criu/files-reg.c b/criu/files-reg.c
index 03a7bcc..1c3d32e 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -81,7 +81,7 @@ static int note_link_remap(char *path, struct ns_id *nsid)
 	if (!rlb)
 		goto err;
 
-	rlb->path = strdup(path);
+	rlb->path = xstrdup(path);
 	if (!rlb->path)
 		goto err2;
 
diff --git a/criu/plugin.c b/criu/plugin.c
index 387b11f..6d95118 100644
--- a/criu/plugin.c
+++ b/criu/plugin.c
@@ -29,7 +29,7 @@ static cr_plugin_desc_t *cr_gen_plugin_desc(void *h, char *path)
 	if (!d)
 		return NULL;
 
-	d->name		= strdup(path);
+	d->name		= xstrdup(path);
 	d->max_hooks	= CR_PLUGIN_HOOK__MAX;
 	d->version	= CRIU_PLUGIN_VERSION_OLD;
 
-- 
2.7.4



More information about the CRIU mailing list