From 7b90330bff40ab555bb3f0c5ee43ae208a275104 Mon Sep 17 00:00:00 2001 From: Robert Edmonds Date: Sun, 2 Jul 2023 19:35:43 -0400 Subject: [PATCH] Use GOOGLE_LOG(FATAL) instead of GOOGLE_LOG(DFATAL) Looking at where these identifiers are ultimately defined [0], it looks like "DFATAL" means either "ERROR" or "FATAL" depending on whether NDEBUG is defined. However, looking at the actual code sites in protoc-c where DFATAL is used, it's not clear why we couldn't just use FATAL unconditionally. This is aimed at supporting newer versions of protobuf where the DFATAL identifier apparently no longer exists. [0] https://github.com/protocolbuffers/protobuf/blob/v21.12/src/google/protobuf/stubs/logging.h#L61-L65 --- protoc-c/c_message.cc | 4 ++-- protoc-c/c_primitive_field.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/protoc-c/c_message.cc b/protoc-c/c_message.cc index 37e8bf8..af2974c 100755 --- a/protoc-c/c_message.cc +++ b/protoc-c/c_message.cc @@ -499,7 +499,7 @@ GenerateMessageDescriptor(io::Printer* printer, bool gen_init) { // NOTE: not supported by protobuf vars["maybe_static"] = ""; vars["field_dv_ctype"] = "{ ... }"; - GOOGLE_LOG(DFATAL) << "Messages can't have default values!"; + GOOGLE_LOG(FATAL) << "Messages can't have default values!"; break; case FieldDescriptor::CPPTYPE_STRING: if (fd->type() == FieldDescriptor::TYPE_BYTES || opt.string_as_bytes()) @@ -521,7 +521,7 @@ GenerateMessageDescriptor(io::Printer* printer, bool gen_init) { break; } default: - GOOGLE_LOG(DFATAL) << "Unknown CPPTYPE"; + GOOGLE_LOG(FATAL) << "Unknown CPPTYPE"; break; } if (!already_defined) diff --git a/protoc-c/c_primitive_field.cc b/protoc-c/c_primitive_field.cc index 6990893..1727af3 100644 --- a/protoc-c/c_primitive_field.cc +++ b/protoc-c/c_primitive_field.cc @@ -143,7 +143,7 @@ std::string PrimitiveFieldGenerator::GetDefaultValue() const case FieldDescriptor::CPPTYPE_BOOL: return descriptor_->default_value_bool() ? "1" : "0"; default: - GOOGLE_LOG(DFATAL) << "unexpected CPPTYPE in c_primitive_field"; + GOOGLE_LOG(FATAL) << "unexpected CPPTYPE in c_primitive_field"; return "UNEXPECTED_CPPTYPE"; } }