diff --git a/fuzzers/tint_spirv_tools_fuzzer/cli.cc b/fuzzers/tint_spirv_tools_fuzzer/cli.cc index f304ed743b..b94242152a 100644 --- a/fuzzers/tint_spirv_tools_fuzzer/cli.cc +++ b/fuzzers/tint_spirv_tools_fuzzer/cli.cc @@ -191,8 +191,8 @@ void PrintHelpMessage(const char* help_message) { } bool ParseUint32(const char* param, uint32_t* out) { - auto value = strtoul(param, nullptr, 10); - if (value > std::numeric_limits::max()) { + uint64_t value = static_cast(strtoul(param, nullptr, 10)); + if (value > static_cast(std::numeric_limits::max())) { return false; } *out = static_cast(value); diff --git a/fuzzers/tint_spirv_tools_fuzzer/fuzzer.cc b/fuzzers/tint_spirv_tools_fuzzer/fuzzer.cc index 18c072a5f8..4d3b8aa99a 100644 --- a/fuzzers/tint_spirv_tools_fuzzer/fuzzer.cc +++ b/fuzzers/tint_spirv_tools_fuzzer/fuzzer.cc @@ -70,7 +70,8 @@ std::unique_ptr CreateMutator(const std::vector& binary, assert(!types.empty() && "At least one mutator type must be specified"); RandomGenerator generator(seed); - auto mutator_type = types[generator.GetUInt64(types.size())]; + auto mutator_type = + types[generator.GetUInt32(static_cast(types.size()))]; const auto& mutator_params = context->params.mutator_params; switch (mutator_type) { diff --git a/fuzzers/tint_spirv_tools_fuzzer/spirv_opt_mutator.cc b/fuzzers/tint_spirv_tools_fuzzer/spirv_opt_mutator.cc index 0b75ed3973..d52d8ef2f0 100644 --- a/fuzzers/tint_spirv_tools_fuzzer/spirv_opt_mutator.cc +++ b/fuzzers/tint_spirv_tools_fuzzer/spirv_opt_mutator.cc @@ -105,7 +105,8 @@ SpirvOptMutator::Result SpirvOptMutator::Mutate() { std::vector passes; while (passes.size() < num_of_passes) { - auto idx = generator_.GetUInt64(opt_passes_.size()); + auto idx = + generator_.GetUInt32(static_cast(opt_passes_.size())); passes.push_back(opt_passes_[idx]); } diff --git a/fuzzers/tint_spirv_tools_fuzzer/spirv_reduce_mutator.h b/fuzzers/tint_spirv_tools_fuzzer/spirv_reduce_mutator.h index 2f2514680f..df5cf9b807 100644 --- a/fuzzers/tint_spirv_tools_fuzzer/spirv_reduce_mutator.h +++ b/fuzzers/tint_spirv_tools_fuzzer/spirv_reduce_mutator.h @@ -73,14 +73,14 @@ class SpirvReduceMutator : public Mutator { template T* GetRandomElement(std::vector* arr) { assert(!arr->empty() && "Can't get random element from an empty vector"); - auto index = generator_.GetUInt64(arr->size()); + auto index = generator_.GetUInt32(static_cast(arr->size())); return &(*arr)[index]; } template T* GetRandomElement(std::vector>* arr) { assert(!arr->empty() && "Can't get random element from an empty vector"); - auto index = generator_.GetUInt64(arr->size()); + auto index = generator_.GetUInt32(static_cast(arr->size())); return (*arr)[index].get(); } diff --git a/fuzzers/tint_spirv_tools_fuzzer/util.cc b/fuzzers/tint_spirv_tools_fuzzer/util.cc index bd574a2f2b..d25bfde04c 100644 --- a/fuzzers/tint_spirv_tools_fuzzer/util.cc +++ b/fuzzers/tint_spirv_tools_fuzzer/util.cc @@ -129,7 +129,7 @@ bool ReadBinary(const std::string& path, std::vector* out) { return false; } - auto size = file.tellg(); + size_t size = static_cast(file.tellg()); if (!file) { return false; } @@ -139,7 +139,7 @@ bool ReadBinary(const std::string& path, std::vector* out) { return false; } - std::vector binary(static_cast(size)); + std::vector binary(size); if (!file.read(binary.data(), size)) { return false; }