[Devel] [PATCH 1/9] Initialize of args->{outfd, logfd, infd} in main c/r programs

Oren Laadan orenl at cs.columbia.edu
Wed Jan 26 08:19:00 PST 2011


The initialization belongs to the caller of the cr-library - i.e.
restart-main and checkpoint-main, and not in the cr-library.

Signed-off-by: Oren Laadan <orenl at cs.columbia.edu>
---
 checkpoint-main.c |    4 ++--
 checkpoint.c      |    8 --------
 restart-main.c    |    4 ++--
 3 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/checkpoint-main.c b/checkpoint-main.c
index a2a7d94..b2ec9c8 100644
--- a/checkpoint-main.c
+++ b/checkpoint-main.c
@@ -70,8 +70,8 @@ static void parse_args(struct cr_checkpoint_args *args, int argc, char *argv[])
 	char *logfile;
 
 	/* defaults */
-	args->outfd = -1;
-	args->logfd = -1;
+	args->outfd = fileno(stdout);
+	args->logfd = CHECKPOINT_FD_NONE;
 	args->uerrfd = fileno(stderr);
 	output = NULL;
 	logfile = NULL;
diff --git a/checkpoint.c b/checkpoint.c
index cce3d9d..f9b0b3b 100644
--- a/checkpoint.c
+++ b/checkpoint.c
@@ -37,14 +37,6 @@ int cr_checkpoint(int pid, struct cr_checkpoint_args *args)
 
 	global_uerrfd = args->uerrfd;
 
-	/* output file descriptor (default: stdout) */
-	if (args->outfd < 0)
-		args->outfd = STDOUT_FILENO;
-
-	/* output file descriptor (default: none) */
-	if (args->logfd < 0)
-		args->logfd = CHECKPOINT_FD_NONE;
-
 	if (!args->container)
 		args->flags |= CHECKPOINT_SUBTREE;
 
diff --git a/restart-main.c b/restart-main.c
index 6eed101..efa6a8f 100644
--- a/restart-main.c
+++ b/restart-main.c
@@ -146,10 +146,10 @@ static void parse_args(struct cr_restart_args *args, int argc, char *argv[])
 	/* defaults */
 	memset(args, 0, sizeof(*args));
 	args->wait = 1;
-	args->infd = -1;
-	args->klogfd = -1;
+	args->infd = fileno(stdin);
 	args->ulogfd = fileno(stdout);
 	args->uerrfd = fileno(stderr);
+	args->klogfd = CHECKPOINT_FD_NONE;
 	args->warn = CKPT_COND_WARN;
 	args->fail = CKPT_COND_FAIL;
 	no_pidns = 0;
-- 
1.7.1

_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list