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
This commit is contained in:
Robert Edmonds 2023-07-02 19:35:43 -04:00
parent ad48868dfe
commit 7b90330bff
2 changed files with 3 additions and 3 deletions

View File

@ -499,7 +499,7 @@ GenerateMessageDescriptor(io::Printer* printer, bool gen_init) {
// NOTE: not supported by protobuf // NOTE: not supported by protobuf
vars["maybe_static"] = ""; vars["maybe_static"] = "";
vars["field_dv_ctype"] = "{ ... }"; vars["field_dv_ctype"] = "{ ... }";
GOOGLE_LOG(DFATAL) << "Messages can't have default values!"; GOOGLE_LOG(FATAL) << "Messages can't have default values!";
break; break;
case FieldDescriptor::CPPTYPE_STRING: case FieldDescriptor::CPPTYPE_STRING:
if (fd->type() == FieldDescriptor::TYPE_BYTES || opt.string_as_bytes()) if (fd->type() == FieldDescriptor::TYPE_BYTES || opt.string_as_bytes())
@ -521,7 +521,7 @@ GenerateMessageDescriptor(io::Printer* printer, bool gen_init) {
break; break;
} }
default: default:
GOOGLE_LOG(DFATAL) << "Unknown CPPTYPE"; GOOGLE_LOG(FATAL) << "Unknown CPPTYPE";
break; break;
} }
if (!already_defined) if (!already_defined)

View File

@ -143,7 +143,7 @@ std::string PrimitiveFieldGenerator::GetDefaultValue() const
case FieldDescriptor::CPPTYPE_BOOL: case FieldDescriptor::CPPTYPE_BOOL:
return descriptor_->default_value_bool() ? "1" : "0"; return descriptor_->default_value_bool() ? "1" : "0";
default: default:
GOOGLE_LOG(DFATAL) << "unexpected CPPTYPE in c_primitive_field"; GOOGLE_LOG(FATAL) << "unexpected CPPTYPE in c_primitive_field";
return "UNEXPECTED_CPPTYPE"; return "UNEXPECTED_CPPTYPE";
} }
} }