From mboxrd@z Thu Jan 1 00:00:00 1970 From: Harmandeep Kaur Subject: [PATCH v2 1/5] xl: convert exit codes to EXIT_[SUCCESS|FAILURE] Date: Sat, 24 Oct 2015 11:01:32 +0530 Message-ID: <1445664696-14258-2-git-send-email-write.harmandeep@gmail.com> References: <1445664696-14258-1-git-send-email-write.harmandeep@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZprRn-0007ER-N5 for xen-devel@lists.xenproject.org; Sat, 24 Oct 2015 05:32:55 +0000 Received: by wicuv6 with SMTP id uv6so8974064wic.2 for ; Fri, 23 Oct 2015 22:32:54 -0700 (PDT) In-Reply-To: <1445664696-14258-1-git-send-email-write.harmandeep@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org 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 List-Id: xen-devel@lists.xenproject.org turning main function xl exit codes towards using the EXIT_[SUCCESS|FAILURE] macros, 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 --- tools/libxl/xl.c | 12 ++++++------ tools/libxl/xl.h | 6 ++++++ 2 files changed, 12 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..0533398 100644 --- a/tools/libxl/xl.h +++ b/tools/libxl/xl.h @@ -30,6 +30,12 @@ struct cmd_spec { char *cmd_option; }; +/* +*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. +*/ + int main_vcpulist(int argc, char **argv); int main_info(int argc, char **argv); int main_sharing(int argc, char **argv); -- 1.9.1