diff mbox

[9/9] xl: Improve return codes of main_domid(), main_domname() and main_sysrq() and related functions.

Message ID 1456318407-3635-10-git-send-email-write.harmandeep@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Harmandeep Kaur Feb. 24, 2016, 12:53 p.m. UTC
Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
---
 tools/libxl/xl_cmdimpl.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Dario Faggioli Feb. 25, 2016, 11:18 a.m. UTC | #1
On Wed, 2016-02-24 at 18:23 +0530, Harmandeep Kaur wrote:
> Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
>
So, this basically is "domain id and name related functions", or
"domain utility functions".

I'd rename the patch with something like that.

Also, I think find_domain() is fits nicely in here.

> ---
>  tools/libxl/xl_cmdimpl.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index 9e0a467..234977c 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c

>  int main_domname(int argc, char **argv)
> @@ -6343,13 +6343,13 @@ int main_domname(int argc, char **argv)
>      if (domid == 0 && !strcmp(endptr, argv[optind])) {
>          /*no digits at all*/
>          fprintf(stderr, "Invalid domain id.\n\n");
> -        return 1;
> +        return EXIT_FAILURE;
>      }
>  
>      domname = libxl_domid_to_name(ctx, domid);
>      if (!domname) {
>          fprintf(stderr, "Can't get domain name of domain id '%d',
> maybe this domain does not exist.\n", domid);
> -        return 1;
> +        return EXIT_SUCCESS;
>      }
>  
>      printf("%s\n", domname);
>
main_rename() can well be done in this patch as well.

> @@ -6431,12 +6431,12 @@ int main_sysrq(int argc, char **argv)
>
While this one, I'd do it in another patch. (I'd probably move it to
patch 8)

Thanks and Regards,
Dario
diff mbox

Patch

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 9e0a467..234977c 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -6320,12 +6320,12 @@  int main_domid(int argc, char **argv)
 
     if (libxl_name_to_domid(ctx, domname, &domid)) {
         fprintf(stderr, "Can't get domid of domain name '%s', maybe this domain does not exist.\n", domname);
-        return 1;
+        return EXIT_FAILURE;
     }
 
     printf("%d\n", domid);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 int main_domname(int argc, char **argv)
@@ -6343,13 +6343,13 @@  int main_domname(int argc, char **argv)
     if (domid == 0 && !strcmp(endptr, argv[optind])) {
         /*no digits at all*/
         fprintf(stderr, "Invalid domain id.\n\n");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     domname = libxl_domid_to_name(ctx, domid);
     if (!domname) {
         fprintf(stderr, "Can't get domain name of domain id '%d', maybe this domain does not exist.\n", domid);
-        return 1;
+        return EXIT_SUCCESS;
     }
 
     printf("%s\n", domname);
@@ -6431,12 +6431,12 @@  int main_sysrq(int argc, char **argv)
     if (sysrq[1] != '\0') {
         fprintf(stderr, "Invalid sysrq.\n\n");
         help("sysrq");
-        return 1;
+        return EXIT_FAILURE;
     }
 
     libxl_send_sysrq(ctx, domid, sysrq[0]);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 int main_debug_keys(int argc, char **argv)