diff mbox

[8/9] xl: Improve return and exit codes main_button_press(), main_trigger(), main_remus() and related functions.

Message ID 1456318407-3635-9-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 | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Dario Faggioli Feb. 25, 2016, 11:26 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>
>
About the subject lines: try to make them more abstract. It does not
scale to list all the changed functions! :-)

So, in this case, something like (just out of the top of my head!)
"debugging, special keys and triggering related functions".

And main_remus() does not really belong here, while main_sysrq(),
main_trigger(), and probably even main_debug_keys() and main_dmesg()
can well do.

> ---
>  tools/libxl/xl_cmdimpl.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index f7f7d7f..9e0a467 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -374,7 +374,7 @@ static void xvasprintf(char **strp, const char
> *fmt, va_list ap)
>      int r = vasprintf(strp, fmt, ap);
>      if (r == -1) {
>          perror("asprintf failed");
> -        exit(-ERROR_FAIL);
> +        exit(EXIT_FAILURE);
>
xvasprintf() doesn't fit here either.

Regards,
Dario
diff mbox

Patch

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index f7f7d7f..9e0a467 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -374,7 +374,7 @@  static void xvasprintf(char **strp, const char *fmt, va_list ap)
     int r = vasprintf(strp, fmt, ap);
     if (r == -1) {
         perror("asprintf failed");
-        exit(-ERROR_FAIL);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -5216,7 +5216,7 @@  static void button_press(uint32_t domid, const char *b)
         trigger = LIBXL_TRIGGER_SLEEP;
     } else {
         fprintf(stderr, "%s is an invalid button identifier\n", b);
-        exit(2);
+        exit(EXIT_FAILURE);
     }
 
     libxl_send_trigger(ctx, domid, trigger, 0);
@@ -6398,7 +6398,7 @@  int main_trigger(int argc, char **argv)
     trigger_name = argv[optind++];
     if (libxl_trigger_from_string(trigger_name, &trigger)) {
         fprintf(stderr, "Invalid trigger \"%s\"\n", trigger_name);
-        return -1;
+        return EXIT_FAILURE;
     }
 
     if (argv[optind]) {
@@ -6410,7 +6410,7 @@  int main_trigger(int argc, char **argv)
 
     libxl_send_trigger(ctx, domid, trigger, vcpuid);
 
-    return 0;
+    return EXIT_SUCCESS;
 }
 
 
@@ -8064,7 +8064,7 @@  int main_remus(int argc, char **argv)
         send_fd = open("/dev/null", O_RDWR, 0644);
         if (send_fd < 0) {
             perror("failed to open /dev/null");
-            exit(-1);
+            exit(EXIT_FAILURE);
         }
     } else {
 
@@ -8081,7 +8081,7 @@  int main_remus(int argc, char **argv)
         if (!config_len) {
             fprintf(stderr, "No config file stored for running domain and "
                     "none supplied - cannot start remus.\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         child = create_migration_child(rune, &send_fd, &recv_fd);
@@ -8102,7 +8102,7 @@  int main_remus(int argc, char **argv)
     if (libxl_domain_info(ctx, 0, domid)) {
         fprintf(stderr, "Remus: Primary domain has been destroyed.\n");
         close(send_fd);
-        return 0;
+        return EXIT_SUCCESS;
     }
 
     /* If we are here, it means remus setup/domain suspend/backup has
@@ -8117,7 +8117,7 @@  int main_remus(int argc, char **argv)
     }
 
     close(send_fd);
-    return -ERROR_FAIL;
+    return EXIT_FAILURE;
 }
 #endif