[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 1/5] xl: convert exit codes to EXIT_[SUCCESS|FAILURE]



On Sat, Oct 24, 2015 at 11:01:32AM +0530, Harmandeep Kaur wrote:
> 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 <write.harmandeep@xxxxxxxxx>
> ---
>  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.

Please correctly format this comment. 

 /*
  * 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.
  */

Note the alignment.

>  int main_vcpulist(int argc, char **argv);
>  int main_info(int argc, char **argv);
>  int main_sharing(int argc, char **argv);
> -- 
> 1.9.1

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.