[CRIU] [PATCH] plugins: Don't strdup libdir arg

Pavel Emelyanov xemul at parallels.com
Wed Dec 25 08:22:51 PST 2013


It's not freed anywhere. Makes code look simpler.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 crtools.c |  6 +-----
 plugin.c  | 13 +++++--------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/crtools.c b/crtools.c
index 87397dd..fb04e20 100644
--- a/crtools.c
+++ b/crtools.c
@@ -280,11 +280,7 @@ int main(int argc, char *argv[])
 			opts.check_ms_kernel = true;
 			break;
 		case 'L':
-			opts.libdir = strdup(optarg);
-			if (opts.libdir == NULL) {
-				pr_perror("Can't allocate memory");
-				return -1;
-			}
+			opts.libdir = optarg;
 			break;
 		case 'V':
 			pr_msg("Version: %s\n", CRIU_VERSION);
diff --git a/plugin.c b/plugin.c
index 222a2f5..542abdd 100644
--- a/plugin.c
+++ b/plugin.c
@@ -166,16 +166,13 @@ int cr_plugin_init(void)
 
 	if (opts.libdir == NULL) {
 		path = getenv("CRIU_LIBS_DIR");
-		if (path) {
-			opts.libdir = strdup(path);
-		} else {
+		if (path)
+			opts.libdir = path;
+		else {
 			if (access(CR_PLUGIN_DEFAULT, F_OK))
 				return 0;
-			opts.libdir = strdup(CR_PLUGIN_DEFAULT);
-		}
-		if (opts.libdir == NULL) {
-			pr_perror("Can't allocate memory");
-			return -1;
+
+			opts.libdir = CR_PLUGIN_DEFAULT;
 		}
 	}
 
-- 
1.8.3.1


More information about the CRIU mailing list