[Lldb-commits] [PATCH] D99701: [lldb-vscode] Consistently use return EXIT_SUCCESS and EXIT_FAILURE (NFC)

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 31 21:26:28 PDT 2021


JDevlieghere created this revision.
JDevlieghere added reviewers: wallace, clayborg.
JDevlieghere requested review of this revision.

Consistently use `return` with `EXIT_SUCCESS` or `EXIT_FAILURE` instead of mix-and-matching `return`, `exit` `0,` `1` etc.


https://reviews.llvm.org/D99701

Files:
  lldb/tools/lldb-vscode/lldb-vscode.cpp


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===================================================================
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -3105,7 +3105,7 @@
     } else {
       llvm::errs() << "\"--launch-target\" requires \"--comm-file\" to be "
                       "specified\n";
-      exit(EXIT_FAILURE);
+      return EXIT_FAILURE;
     }
   }
 
@@ -3118,7 +3118,7 @@
 
   if (input_args.hasArg(OPT_help)) {
     printHelp(T, llvm::sys::path::filename(argv[0]));
-    return 0;
+    return EXIT_SUCCESS;
   }
 
   if (auto *arg = input_args.getLastArg(OPT_port)) {
@@ -3127,7 +3127,7 @@
     portno = strtol(optarg, &remainder, 0);
     if (remainder == optarg || *remainder != '\0') {
       fprintf(stderr, "'%s' is not a valid port number.\n", optarg);
-      exit(1);
+      return EXIT_FAILURE;
     }
   }
 
@@ -3144,7 +3144,7 @@
       g_vsc.input.descriptor = StreamDescriptor::from_socket(socket_fd, true);
       g_vsc.output.descriptor = StreamDescriptor::from_socket(socket_fd, false);
     } else {
-      exit(1);
+      return EXIT_FAILURE;
     }
   } else {
     g_vsc.input.descriptor = StreamDescriptor::from_file(fileno(stdin), false);
@@ -3158,15 +3158,15 @@
     if (status == lldb_vscode::PacketStatus::EndOfFile)
       break;
     if (status != lldb_vscode::PacketStatus::Success)
-      return 1; // Fatal error
+      return EXIT_FAILURE;
 
     if (!g_vsc.HandleObject(object))
-      return 1;
+      return EXIT_FAILURE;
     ++packet_idx;
   }
 
   // We must terminate the debugger in a thread before the C++ destructor
   // chain messes everything up.
   lldb::SBDebugger::Terminate();
-  return 0;
+  return EXIT_SUCCESS;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99701.334585.patch
Type: text/x-patch
Size: 1734 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210401/4bebd45b/attachment-0001.bin>


More information about the lldb-commits mailing list