aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@google.com>2020-07-14 11:17:39 -0400
committerDavid Neto <dneto@google.com>2020-07-27 09:02:54 -0700
commit25a8165f50bce8328686e0b9b567f6c55f087516 (patch)
tree4439f5ae5da175157cde4d3de6b9ee5ac755a69e
parent34c9aac3f30d0ba84a5d974fc93f95277519223b (diff)
downloadshaderc-25a8165f50bce8328686e0b9b567f6c55f087516.tar.gz
Clean up issues discovered by Infer
-rw-r--r--libshaderc_spvc/include/spvc/spvc.hpp3
-rw-r--r--spvc/src/main.cc7
2 files changed, 7 insertions, 3 deletions
diff --git a/libshaderc_spvc/include/spvc/spvc.hpp b/libshaderc_spvc/include/spvc/spvc.hpp
index 1c2e7d4..cca320f 100644
--- a/libshaderc_spvc/include/spvc/spvc.hpp
+++ b/libshaderc_spvc/include/spvc/spvc.hpp
@@ -78,6 +78,9 @@ class CompilationResult {
uint32_t binary_length;
status =
shaderc_spvc_result_get_binary_length(result_.get(), &binary_length);
+ if (status != shaderc_spvc_status_success) {
+ return status;
+ }
if (!binary_output || !binary_length) {
*data = std::vector<uint32_t>();
} else {
diff --git a/spvc/src/main.cc b/spvc/src/main.cc
index b8e03e9..96fb886 100644
--- a/spvc/src/main.cc
+++ b/spvc/src/main.cc
@@ -111,14 +111,15 @@ bool ReadFile(const std::string& path, std::vector<uint32_t>* out) {
out->resize(ftell(file) / sizeof((*out)[0]));
rewind(file);
+ bool status = true;
if (fread(out->data(), sizeof((*out)[0]), out->size(), file) != out->size()) {
std::cerr << "Failed to read SPIR-V file: " << path << std::endl;
out->clear();
- return false;
+ status = false;
}
fclose(file);
- return true;
+ return status;
}
bool StringPieceToEnvEnum(const string_piece& str, shaderc_spvc_spv_env* env) {
@@ -325,7 +326,7 @@ int main(int argc, char** argv) {
options.SetMSLDiscreteDescriptorSets(msl_discrete_descriptor);
shaderc_spvc::CompilationResult result;
- shaderc_spvc_status status = shaderc_spvc_status_configuration_error;
+ shaderc_spvc_status status;
if (output_language == "glsl") {
status = context.InitializeForGlsl((const uint32_t*)input.data(),