From: Harmandeep Kaur <write.harmandeep@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: lars.kurth@citrix.com, wei.liu2@citrix.com,
ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com,
dario.faggioli@citrix.com, ian.jackson@eu.citrix.com,
george.dunlap@citrix.com,
Harmandeep Kaur <write.harmandeep@gmail.com>
Subject: [PATCH v4 1/5] xl: convert main() exit codes to EXIT_[SUCCESS|FAILURE]
Date: Tue, 27 Oct 2015 18:18:54 +0530 [thread overview]
Message-ID: <1445950138-9908-2-git-send-email-write.harmandeep@gmail.com> (raw)
In-Reply-To: <1445950138-9908-1-git-send-email-write.harmandeep@gmail.com>
Turning main() function exit codes towards using the EXIT_[SUCCESS|FAILURE]
constants, instead of instead of arbitrary numbers or libxl return codes.
Also includes a document comment in xl.h stating xl process should always
return EXIT_FOO and main_* can be treated as main() as if they are returning
a process exit status and not a function return value)
Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
---
v3->v4: Aligned comment correctly.
v2->v3: Commented more precisely and aligned comment properly.
v1->v2: Applied new approach (main() functions return
EXIT_SUCCESS/FAILURE and other functions return 0/1).
tools/libxl/xl.c | 12 ++++++------
tools/libxl/xl.h | 7 +++++++
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index 5316ad9..dfae84a 100644
--- a/tools/libxl/xl.c
+++ b/tools/libxl/xl.c
@@ -318,7 +318,7 @@ int main(int argc, char **argv)
break;
default:
fprintf(stderr, "unknown global option\n");
- exit(2);
+ exit(EXIT_FAILURE);
}
}
@@ -326,13 +326,13 @@ int main(int argc, char **argv)
if (!cmd) {
help(NULL);
- exit(1);
+ exit(EXIT_FAILURE);
}
opterr = 0;
logger = xtl_createlogger_stdiostream(stderr, minmsglevel,
(progress_use_cr ? XTL_STDIOSTREAM_PROGRESS_USE_CR : 0));
- if (!logger) exit(1);
+ if (!logger) exit(EXIT_FAILURE);
atexit(xl_ctx_free);
@@ -355,16 +355,16 @@ int main(int argc, char **argv)
if (cspec) {
if (dryrun_only && !cspec->can_dryrun) {
fprintf(stderr, "command does not implement -N (dryrun) option\n");
- ret = 1;
+ ret = EXIT_FAILURE;
goto xit;
}
ret = cspec->cmd_impl(argc, argv);
} else if (!strcmp(cmd, "help")) {
help(argv[1]);
- ret = 0;
+ ret = EXIT_SUCCESS;
} else {
fprintf(stderr, "command not implemented\n");
- ret = 1;
+ ret = EXIT_FAILURE;
}
xit:
diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h
index 0021112..c6fb1da 100644
--- a/tools/libxl/xl.h
+++ b/tools/libxl/xl.h
@@ -30,6 +30,13 @@ struct cmd_spec {
char *cmd_option;
};
+/*
+ * The xl process should always return either EXIT_SUCCESS or
+ * EXIT_FAILURE. main_* functions, implementing the various xl
+ * commands, can be treated as main() as if they are returning
+ * a process exit status and not a function return value.
+ */
+
int main_vcpulist(int argc, char **argv);
int main_info(int argc, char **argv);
int main_sharing(int argc, char **argv);
--
1.9.1
next prev parent reply other threads:[~2015-10-27 12:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-27 12:48 [PATCH v4 0/5] xl: convert exit codes to EXIT_[SUCCESS|FAILURE] Harmandeep Kaur
2015-10-27 12:48 ` Harmandeep Kaur [this message]
2015-10-27 12:48 ` [PATCH v4 2/5] xl: improve return and exit codes of scheduling related functions Harmandeep Kaur
2015-10-27 13:50 ` Wei Liu
2015-10-27 14:30 ` Dario Faggioli
2015-10-27 12:48 ` [PATCH v4 3/5] xl: improve return and exit codes of vcpu " Harmandeep Kaur
2015-10-27 12:48 ` [PATCH v4 4/5] xl: improve return and exit codes of cpupool " Harmandeep Kaur
2015-10-27 12:48 ` [PATCH v4 5/5] xl: improve return and exit codes of parse " Harmandeep Kaur
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=1445950138-9908-2-git-send-email-write.harmandeep@gmail.com \
--to=write.harmandeep@gmail.com \
--cc=dario.faggioli@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=lars.kurth@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).