[Devel] [PATCH 10/13][user-cr]: checkpoint: Remove ->logfile
Sukadev Bhattiprolu
sukadev at linux.vnet.ibm.com
Wed Mar 3 23:49:42 PST 2010
From: Sukadev Bhattiprolu <sukadev at linux.vnet.ibm.com>
Date: Wed, 3 Mar 2010 11:03:52 -0800
Subject: [PATCH 10/13][user-cr]: checkpoint: Remove ->logfile
'struct args' has both an 'logfd' and a 'logfile' field. The ->logfile
field is only needed to parse arguments and by moving the open of
the logfile into parse_args(), we can drop the ->logfile field and just
use ->logfd.
Signed-off-by: Sukadev Bhattiprolu <sukadev at linux.vnet.ibm.com>
---
checkpoint.c | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/checkpoint.c b/checkpoint.c
index df405cb..ca77d8b 100644
--- a/checkpoint.c
+++ b/checkpoint.c
@@ -41,7 +41,6 @@ static char usage_str[] =
struct args {
int outfd;
- char *logfile;
int logfd;
int container;
int verbose;
@@ -84,11 +83,13 @@ static void parse_args(struct args *args, int argc, char *argv[])
};
static char optc[] = "hvco:l:";
char *output;
+ char *logfile;
/* defaults */
args->outfd = -1;
args->logfd = -1;
output = NULL;
+ logfile = NULL;
while (1) {
int c = getopt_long(argc, argv, optc, opts, NULL);
@@ -110,7 +111,7 @@ static void parse_args(struct args *args, int argc, char *argv[])
}
break;
case 'l':
- args->logfile = optarg;
+ logfile = optarg;
break;
case 2:
args->logfd = str2num(optarg);
@@ -144,10 +145,19 @@ static void parse_args(struct args *args, int argc, char *argv[])
}
}
- if (args->logfile && args->logfd >= 0) {
- printf("Invalid used of both -l/--logfile and --logfile-fd\n");
+ if (logfile && args->logfd >= 0) {
+ printf("Invalid use of both -l/--logfile and --logfile-fd\n");
exit(1);
}
+
+ /* (optional) log file */
+ if (logfile) {
+ args->logfd = open(logfile, O_RDWR | O_CREAT | O_EXCL, 0644);
+ if (args->logfd < 0) {
+ perror("open log file");
+ exit(1);
+ }
+ }
}
int main(int argc, char *argv[])
@@ -177,16 +187,6 @@ int main(int argc, char *argv[])
if (args.outfd < 0)
args.outfd = STDOUT_FILENO;
- /* (optional) log file */
- if (args.logfile) {
- args.logfd = open(args.logfile,
- O_RDWR | O_CREAT | O_EXCL, 0644);
- if (args.logfd < 0) {
- perror("open log file");
- exit(1);
- }
- }
-
/* output file descriptor (default: none) */
if (args.logfd < 0)
args.logfd = CHECKPOINT_FD_NONE;
--
1.6.0.4
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
More information about the Devel
mailing list