Clean up: Coding style conformance adjustments in lttng-crash.c
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 5 Sep 2015 17:55:51 +0000 (13:55 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 5 Sep 2015 17:55:51 +0000 (13:55 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-crash/lttng-crash.c

index 4d186dd557fb995ecbfd3b29f8637d63110b59d2..45fe71be7b67aadbb83a7b3a1d357a21171571a7 100644 (file)
@@ -34,6 +34,7 @@
 #include <dirent.h>
 #include <byteswap.h>
 #include <inttypes.h>
+#include <stdbool.h>
 
 #include <version.h>
 #include <lttng/lttng.h>
@@ -1138,7 +1139,8 @@ int view_trace(const char *viewer_path, const char *trace_path)
  */
 int main(int argc, char *argv[])
 {
-       int ret, has_warning = 0;
+       int ret;
+       bool has_warning = false;
        const char *output_path = NULL;
        char tmppath[] = "/tmp/lttng-crash-XXXXXX";
 
@@ -1146,9 +1148,10 @@ int main(int argc, char *argv[])
 
        ret = parse_args(argc, argv);
        if (ret > 0) {
-               exit(EXIT_SUCCESS);
+               goto end;
        } else if (ret < 0) {
-               exit(EXIT_FAILURE);
+               has_warning = true;
+               goto end;
        }
 
        if (opt_output_path) {
@@ -1156,34 +1159,38 @@ int main(int argc, char *argv[])
                ret = mkdir(output_path, S_IRWXU | S_IRWXG);
                if (ret) {
                        PERROR("mkdir");
-                       exit(EXIT_FAILURE);
+                       has_warning = true;
+                       goto end;
                }
        } else {
                output_path = mkdtemp(tmppath);
                if (!output_path) {
                        PERROR("mkdtemp");
-                       exit(EXIT_FAILURE);
+                       has_warning = true;
+                       goto end;
                }
        }
 
        ret = extract_trace_recursive(output_path, input_path);
        if (ret < 0) {
-               exit(EXIT_FAILURE);
+               has_warning = true;
+               goto end;
        } else if (ret > 0) {
-               has_warning = 1;
+               /* extract_trace_recursive reported a warning. */
+               has_warning = true;
        }
        if (!opt_output_path) {
                /* View trace */
                ret = view_trace(opt_viewer_path, output_path);
-               if (ret)
-                       has_warning = 1;
-
+               if (ret) {
+                       has_warning = true;
+               }
                /* unlink temporary trace */
                ret = delete_trace(output_path);
-               if (ret)
-                       has_warning = 1;
+               if (ret) {
+                       has_warning = true;
+               }
        }
-       if (has_warning)
-               exit(EXIT_FAILURE);
-       exit(EXIT_SUCCESS);
+end:
+       exit(has_warning ? EXIT_FAILURE : EXIT_SUCCESS);
 }
This page took 0.027116 seconds and 4 git commands to generate.