mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-22 03:30:06 +00:00
Remove reference to protobuf internals from fuzzers (#4701)
In newer versions of protobuf the Status building code has been made internal, so that embedders cannot build their own instances like is being done here. Changing this code to just use the .ok() method on the status object, since if the status is OK or not is what is actually being tested. This will make it easier in the future to update external/protobuf.
This commit is contained in:
parent
ff91f9449b
commit
a383c476e6
@ -149,7 +149,7 @@ void DumpTransformationsJson(
|
||||
json_options.add_whitespace = true;
|
||||
auto json_generation_status = google::protobuf::util::MessageToJsonString(
|
||||
transformations, &json_string, json_options);
|
||||
if (json_generation_status == google::protobuf::util::Status::OK) {
|
||||
if (json_generation_status.ok()) {
|
||||
std::ofstream transformations_json_file(filename);
|
||||
transformations_json_file << json_string;
|
||||
transformations_json_file.close();
|
||||
|
@ -673,19 +673,6 @@ void DumpTransformationsBinary(
|
||||
transformations_file.close();
|
||||
}
|
||||
|
||||
// The Chromium project applies the following patch to the protobuf library:
|
||||
//
|
||||
// source.chromium.org/chromium/chromium/src/+/main:third_party/protobuf/patches/0003-remove-static-initializers.patch
|
||||
//
|
||||
// This affects how Status objects must be constructed. This method provides a
|
||||
// convenient way to get the OK status that works both with and without the
|
||||
// patch. With the patch OK is a StatusPod, from which a Status can be
|
||||
// constructed. Without the patch, OK is already a Status, and we harmlessly
|
||||
// copy-construct the result from it.
|
||||
google::protobuf::util::Status GetProtobufOkStatus() {
|
||||
return google::protobuf::util::Status(google::protobuf::util::Status::OK);
|
||||
}
|
||||
|
||||
// Dumps |transformations| to file |filename| in JSON format. Useful for
|
||||
// interactive debugging.
|
||||
void DumpTransformationsJson(
|
||||
@ -696,7 +683,7 @@ void DumpTransformationsJson(
|
||||
json_options.add_whitespace = true;
|
||||
auto json_generation_status = google::protobuf::util::MessageToJsonString(
|
||||
transformations, &json_string, json_options);
|
||||
if (json_generation_status == GetProtobufOkStatus()) {
|
||||
if (json_generation_status.ok()) {
|
||||
std::ofstream transformations_json_file(filename);
|
||||
transformations_json_file << json_string;
|
||||
transformations_json_file.close();
|
||||
@ -747,8 +734,9 @@ int main(int argc, const char** argv) {
|
||||
std::string facts_json_string((std::istreambuf_iterator<char>(facts_input)),
|
||||
std::istreambuf_iterator<char>());
|
||||
facts_input.close();
|
||||
if (GetProtobufOkStatus() != google::protobuf::util::JsonStringToMessage(
|
||||
facts_json_string, &initial_facts)) {
|
||||
if (!google::protobuf::util::JsonStringToMessage(facts_json_string,
|
||||
&initial_facts)
|
||||
.ok()) {
|
||||
spvtools::Error(FuzzDiagnostic, nullptr, {}, "Error reading facts data");
|
||||
return 1;
|
||||
}
|
||||
@ -828,7 +816,7 @@ int main(int argc, const char** argv) {
|
||||
json_options.add_whitespace = true;
|
||||
auto json_generation_status = google::protobuf::util::MessageToJsonString(
|
||||
transformations_applied, &json_string, json_options);
|
||||
if (json_generation_status != GetProtobufOkStatus()) {
|
||||
if (!json_generation_status.ok()) {
|
||||
spvtools::Error(FuzzDiagnostic, nullptr, {},
|
||||
"Error writing out transformations in JSON format");
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user