Merge pull request #52736 from aaronfranke/lgtm-mult
Fix some LGTM errors of "Multiplication result converted to larger type"
This commit is contained in:
commit
0fd50ff217
12 changed files with 25 additions and 23 deletions
|
@ -233,7 +233,7 @@ uint64_t FileAccessCompressed::get_position() const {
|
|||
if (writing) {
|
||||
return write_pos;
|
||||
} else {
|
||||
return read_block * block_size + read_pos;
|
||||
return (uint64_t)read_block * block_size + read_pos;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ static int godot_testerror(voidpf opaque, voidpf stream) {
|
|||
}
|
||||
|
||||
static voidpf godot_alloc(voidpf opaque, uInt items, uInt size) {
|
||||
return memalloc(items * size);
|
||||
return memalloc((size_t)items * size);
|
||||
}
|
||||
|
||||
static void godot_free(voidpf opaque, voidpf address) {
|
||||
|
|
|
@ -100,7 +100,7 @@ int zipio_testerror(voidpf opaque, voidpf stream) {
|
|||
}
|
||||
|
||||
voidpf zipio_alloc(voidpf opaque, uInt items, uInt size) {
|
||||
voidpf ptr = memalloc(items * size);
|
||||
voidpf ptr = memalloc((size_t)items * size);
|
||||
memset(ptr, 0, items * size);
|
||||
return ptr;
|
||||
}
|
||||
|
|
|
@ -2488,17 +2488,17 @@ bool Main::iteration() {
|
|||
|
||||
iterating++;
|
||||
|
||||
uint64_t ticks = OS::get_singleton()->get_ticks_usec();
|
||||
const uint64_t ticks = OS::get_singleton()->get_ticks_usec();
|
||||
Engine::get_singleton()->_frame_ticks = ticks;
|
||||
main_timer_sync.set_cpu_ticks_usec(ticks);
|
||||
main_timer_sync.set_fixed_fps(fixed_fps);
|
||||
|
||||
uint64_t ticks_elapsed = ticks - last_ticks;
|
||||
const uint64_t ticks_elapsed = ticks - last_ticks;
|
||||
|
||||
int physics_ticks_per_second = Engine::get_singleton()->get_physics_ticks_per_second();
|
||||
float physics_step = 1.0 / physics_ticks_per_second;
|
||||
const int physics_ticks_per_second = Engine::get_singleton()->get_physics_ticks_per_second();
|
||||
const double physics_step = 1.0 / physics_ticks_per_second;
|
||||
|
||||
float time_scale = Engine::get_singleton()->get_time_scale();
|
||||
const double time_scale = Engine::get_singleton()->get_time_scale();
|
||||
|
||||
MainFrameTime advance = main_timer_sync.advance(physics_step, physics_ticks_per_second);
|
||||
double process_step = advance.process_step;
|
||||
|
|
|
@ -65,7 +65,7 @@ Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
|
|||
|
||||
Vector<uint8_t> imgdata;
|
||||
|
||||
imgdata.resize(height * width * sizeof(uint32_t));
|
||||
imgdata.resize(height * width * (int)sizeof(uint32_t));
|
||||
|
||||
{
|
||||
uint8_t *w = imgdata.ptrw();
|
||||
|
@ -75,7 +75,7 @@ Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
|
|||
if (width < 8 || width >= 32768) {
|
||||
// Read flat data
|
||||
|
||||
f->get_buffer(ptr, width * height * 4);
|
||||
f->get_buffer(ptr, (uint64_t)width * height * 4);
|
||||
} else {
|
||||
// Read RLE-encoded data
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ void AudioStreamPlaybackMP3::seek(float p_time) {
|
|||
}
|
||||
|
||||
frames_mixed = uint32_t(mp3_stream->sample_rate * p_time);
|
||||
mp3dec_ex_seek(mp3d, frames_mixed * mp3_stream->channels);
|
||||
mp3dec_ex_seek(mp3d, (uint64_t)frames_mixed * mp3_stream->channels);
|
||||
}
|
||||
|
||||
AudioStreamPlaybackMP3::~AudioStreamPlaybackMP3() {
|
||||
|
|
|
@ -117,14 +117,15 @@ Error AudioDriverJavaScript::init() {
|
|||
if (output_rb) {
|
||||
memdelete_arr(output_rb);
|
||||
}
|
||||
output_rb = memnew_arr(float, buffer_length *channel_count);
|
||||
const size_t array_size = buffer_length * (size_t)channel_count;
|
||||
output_rb = memnew_arr(float, array_size);
|
||||
if (!output_rb) {
|
||||
return ERR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (input_rb) {
|
||||
memdelete_arr(input_rb);
|
||||
}
|
||||
input_rb = memnew_arr(float, buffer_length *channel_count);
|
||||
input_rb = memnew_arr(float, array_size);
|
||||
if (!input_rb) {
|
||||
return ERR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -123,12 +123,12 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, real_t p_s
|
|||
Point2 new_ofs = (screen_offset + (p_offset - screen_offset) * motion_scale) + motion_offset * p_scale + orig_offset * p_scale;
|
||||
|
||||
if (mirroring.x) {
|
||||
double den = mirroring.x * p_scale;
|
||||
real_t den = mirroring.x * p_scale;
|
||||
new_ofs.x -= den * ceil(new_ofs.x / den);
|
||||
}
|
||||
|
||||
if (mirroring.y) {
|
||||
double den = mirroring.y * p_scale;
|
||||
real_t den = mirroring.y * p_scale;
|
||||
new_ofs.y -= den * ceil(new_ofs.y / den);
|
||||
}
|
||||
|
||||
|
|
|
@ -475,7 +475,7 @@ Ref<Image> GPUParticlesCollisionSDF::bake() {
|
|||
_create_bvh(bvh, face_pos.ptr(), face_pos.size(), faces.ptr(), th);
|
||||
|
||||
Vector<uint8_t> data;
|
||||
data.resize(sdf_size.z * sdf_size.y * sdf_size.x * sizeof(float));
|
||||
data.resize(sdf_size.z * sdf_size.y * sdf_size.x * (int)sizeof(float));
|
||||
|
||||
if (bake_step_function) {
|
||||
bake_step_function(0, "Baking SDF");
|
||||
|
|
|
@ -46,7 +46,7 @@ Error AudioDriverDummy::init() {
|
|||
int latency = GLOBAL_GET("audio/driver/output_latency");
|
||||
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
|
||||
|
||||
samples_in = memnew_arr(int32_t, buffer_frames * channels);
|
||||
samples_in = memnew_arr(int32_t, (size_t)buffer_frames * channels);
|
||||
|
||||
thread.start(AudioDriverDummy::thread_func, this);
|
||||
|
||||
|
|
|
@ -176,8 +176,9 @@ Error AudioRBResampler::setup(int p_channels, int p_src_mix_rate, int p_target_m
|
|||
rb_bits = desired_rb_bits;
|
||||
rb_len = (1 << rb_bits);
|
||||
rb_mask = rb_len - 1;
|
||||
rb = memnew_arr(float, rb_len *p_channels);
|
||||
read_buf = memnew_arr(float, rb_len *p_channels);
|
||||
const size_t array_size = rb_len * (size_t)p_channels;
|
||||
rb = memnew_arr(float, array_size);
|
||||
read_buf = memnew_arr(float, array_size);
|
||||
}
|
||||
|
||||
src_mix_rate = p_src_mix_rate;
|
||||
|
|
|
@ -3959,7 +3959,7 @@ void RendererStorageRD::_multimesh_make_local(MultiMesh *multimesh) const {
|
|||
memcpy(w, r, buffer.size());
|
||||
}
|
||||
} else {
|
||||
memset(w, 0, multimesh->instances * multimesh->stride_cache * sizeof(float));
|
||||
memset(w, 0, (size_t)multimesh->instances * multimesh->stride_cache * sizeof(float));
|
||||
}
|
||||
}
|
||||
uint32_t data_cache_dirty_region_count = (multimesh->instances - 1) / MULTIMESH_DIRTY_REGION_SIZE + 1;
|
||||
|
@ -4372,13 +4372,13 @@ void RendererStorageRD::_update_dirty_multimeshes() {
|
|||
|
||||
if (multimesh->data_cache_used_dirty_regions > 32 || multimesh->data_cache_used_dirty_regions > visible_region_count / 2) {
|
||||
//if there too many dirty regions, or represent the majority of regions, just copy all, else transfer cost piles up too much
|
||||
RD::get_singleton()->buffer_update(multimesh->buffer, 0, MIN(visible_region_count * region_size, multimesh->instances * multimesh->stride_cache * sizeof(float)), data);
|
||||
RD::get_singleton()->buffer_update(multimesh->buffer, 0, MIN(visible_region_count * region_size, multimesh->instances * (uint32_t)multimesh->stride_cache * (uint32_t)sizeof(float)), data);
|
||||
} else {
|
||||
//not that many regions? update them all
|
||||
for (uint32_t i = 0; i < visible_region_count; i++) {
|
||||
if (multimesh->data_cache_dirty_regions[i]) {
|
||||
uint64_t offset = i * region_size;
|
||||
uint64_t size = multimesh->stride_cache * multimesh->instances * sizeof(float);
|
||||
uint32_t offset = i * region_size;
|
||||
uint32_t size = multimesh->stride_cache * (uint32_t)multimesh->instances * (uint32_t)sizeof(float);
|
||||
RD::get_singleton()->buffer_update(multimesh->buffer, offset, MIN(region_size, size - offset), &data[i * region_size]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue