Browse Source

Fixed uninitialized variable warning.

Unfortunately there's not an easy way to annotate that the
"unexpected mode" case is unreachable (even GOOGLE_LOG(FATAL)
in a default: case doesn't do it).
Joshua Haberman 5 years ago
parent
commit
82bad2e1eb
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/google/protobuf/compiler/command_line_interface.cc

+ 4 - 1
src/google/protobuf/compiler/command_line_interface.cc

@@ -1531,7 +1531,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
   }
 
   // Check error cases that span multiple flag values.
-  bool missing_proto_definitions;
+  bool missing_proto_definitions = false;
   switch (mode_) {
     case MODE_COMPILE:
       missing_proto_definitions = input_files_.empty();
@@ -1555,6 +1555,9 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
     case MODE_PRINT:
       missing_proto_definitions =
           input_files_.empty() && descriptor_set_in_names_.empty();
+      break;
+    default:
+      GOOGLE_LOG(FATAL) << "Unexpected mode: " << mode_;
   }
   if (missing_proto_definitions) {
     std::cerr << "Missing input file." << std::endl;