From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
Cc: Containers
<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
Subject: [PATCH 06/13][user-cr]: restart: Remove args->input
Date: Wed, 3 Mar 2010 23:47:59 -0800 [thread overview]
Message-ID: <20100304074759.GG29320@us.ibm.com> (raw)
In-Reply-To: <20100304074354.GA29320-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Date: Mon, 1 Mar 2010 20:24:15 -0800
Subject: [PATCH 06/13][user-cr]: restart: Remove args->input
Having both ->input and ->infd in 'struct args' is redundant.
The args->input field is used to store the name of the input file
(checkpoint-image). If we move the code that opens this file from
main() to parse_args() and use the existing args->infd field, we
can remove the ->input field from struct args.
Signed-off-by: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
---
restart.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/restart.c b/restart.c
index eda864d..d028890 100644
--- a/restart.c
+++ b/restart.c
@@ -383,7 +383,6 @@ struct args {
int show_status;
int copy_status;
char *freezer;
- char *input;
int infd;
int klogfd;
long warn;
@@ -489,6 +488,7 @@ static void parse_args(struct args *args, int argc, char *argv[])
int no_pidns;
char *klogfile;
+ char *input;
/* defaults */
memset(args, 0, sizeof(*args));
@@ -500,6 +500,7 @@ static void parse_args(struct args *args, int argc, char *argv[])
no_pidns = 0;
klogfile = NULL;
+ input = NULL;
while (1) {
int c = getopt_long(argc, argv, optc, opts, &optind);
@@ -517,7 +518,7 @@ static void parse_args(struct args *args, int argc, char *argv[])
args->inspect = 1;
break;
case 'i':
- args->input = optarg;
+ input = optarg;
break;
case 7:
args->infd = str2num(optarg);
@@ -641,11 +642,20 @@ static void parse_args(struct args *args, int argc, char *argv[])
exit(1);
}
- if (args->input && args->infd >= 0) {
+ if (input && args->infd >= 0) {
ckpt_err("Invalid use of both -i/--input and --input-fd\n");
exit(1);
}
+ /* input file ? */
+ if (input) {
+ args->infd = open(input, O_RDONLY, 0);
+ if (args->infd < 0) {
+ ckpt_perror("open input file");
+ exit(1);
+ }
+ }
+
if (klogfile && args->klogfd >= 0) {
ckpt_err("Invalid use of both -l/--logfile and --logfile-fd\n");
exit(1);
@@ -817,15 +827,6 @@ int main(int argc, char *argv[])
parse_args(&args, argc, argv);
ctx.args = &args;
- /* input file ? */
- if (args.input) {
- args.infd = open(args.input, O_RDONLY, 0);
- if (args.infd < 0) {
- ckpt_perror("open input file");
- exit(1);
- }
- }
-
/* input file descriptor (default: stdin) */
if (args.infd >= 0) {
if (dup2(args.infd, STDIN_FILENO) < 0) {
--
1.6.0.4
next prev parent reply other threads:[~2010-03-04 7:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-04 7:43 [PATCH 00/13][user-cr]: Cleanups checkpoint.c, restart.c Sukadev Bhattiprolu
[not found] ` <20100304074354.GA29320-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-04 7:46 ` Sukadev Bhattiprolu
2010-03-04 7:46 ` [PATCH 02/13][user-cr]: restart: Rename args->logfd Sukadev Bhattiprolu
2010-03-04 7:47 ` [PATCH 03/13][user-cr]: restart: Remove args->logfile Sukadev Bhattiprolu
2010-03-04 7:47 ` [PATCH 04/13][user-cr]: restart: Use ckpt_msg() to log Sukadev Bhattiprolu
2010-03-04 7:47 ` [PATCH 05/13][user-cr]: restart: Use ckpt_perror() Sukadev Bhattiprolu
2010-03-04 7:47 ` Sukadev Bhattiprolu [this message]
2010-03-04 7:48 ` [PATCH 07/13][user-cr]: Define app_restart() Sukadev Bhattiprolu
2010-03-04 7:48 ` [PATCH 08/13][user-cr]: restart: Rename struct args Sukadev Bhattiprolu
2010-03-04 7:49 ` [PATCH 09/13][user-cr]: checkpoint: Remove args->output Sukadev Bhattiprolu
2010-03-04 7:49 ` [PATCH 10/13][user-cr]: checkpoint: Remove ->logfile Sukadev Bhattiprolu
2010-03-04 7:50 ` [PATCH 11/13][user-cr]: checkpoint: Rename struct args Sukadev Bhattiprolu
2010-03-04 7:50 ` [PATCH 12/13][user-cr]: Define app_checkpoint() Sukadev Bhattiprolu
2010-03-04 7:51 ` [PATCH 13/13][user-cr]: checkpoint: Use ckpt_perror() Sukadev Bhattiprolu
2010-03-05 21:51 ` [PATCH 00/13][user-cr]: Cleanups checkpoint.c, restart.c Serge E. Hallyn
2010-03-15 3:49 ` Oren Laadan
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=20100304074759.GG29320@us.ibm.com \
--to=sukadev-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org \
/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