Fix MSVC warnings C4701 and C4703: Potentially uninitialized variable used

This commit is contained in:
Rémi Verschelde 2022-09-28 17:05:34 +02:00
parent 14e1f36e61
commit 85fe6ecc32
8 changed files with 17 additions and 15 deletions

View File

@ -268,7 +268,7 @@ public:
uint32_t remainder = count & page_size_mask;
T *remainder_page = nullptr;
uint32_t remainder_page_id;
uint32_t remainder_page_id = 0;
if (remainder > 0) {
uint32_t last_page = _get_pages_in_use() - 1;

View File

@ -4828,7 +4828,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve
for (uint32_t j = 0; j < binding_count; j++) {
const SpvReflectDescriptorBinding &binding = *bindings[j];
RenderingDeviceVulkanShaderBinaryDataBinding info;
RenderingDeviceVulkanShaderBinaryDataBinding info{};
bool need_array_dimensions = false;
bool need_block_size = false;
@ -4979,7 +4979,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve
for (uint32_t j = 0; j < sc_count; j++) {
int32_t existing = -1;
RenderingDeviceVulkanShaderBinarySpecializationConstant sconst;
RenderingDeviceVulkanShaderBinarySpecializationConstant sconst{};
SpvReflectSpecializationConstant *spc = spec_constants[j];
sconst.constant_id = spc->constant_id;

View File

@ -608,10 +608,10 @@ Error VulkanContext::_check_capabilities() {
device_properties_func = (PFN_vkGetPhysicalDeviceProperties2)vkGetInstanceProcAddr(inst, "vkGetPhysicalDeviceProperties2KHR");
}
if (device_properties_func != nullptr) {
VkPhysicalDeviceFragmentShadingRatePropertiesKHR vrsProperties;
VkPhysicalDeviceMultiviewProperties multiviewProperties;
VkPhysicalDeviceSubgroupProperties subgroupProperties;
VkPhysicalDeviceProperties2 physicalDeviceProperties;
VkPhysicalDeviceFragmentShadingRatePropertiesKHR vrsProperties{};
VkPhysicalDeviceMultiviewProperties multiviewProperties{};
VkPhysicalDeviceSubgroupProperties subgroupProperties{};
VkPhysicalDeviceProperties2 physicalDeviceProperties{};
void *nextptr = nullptr;
subgroupProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES;

View File

@ -301,7 +301,7 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
Vector<uint8_t> file_buffer;
// Data for compression
z_stream strm;
z_stream strm{};
Vector<uint8_t> strm_in;
strm_in.resize(BLOCK_SIZE);
Vector<uint8_t> strm_out;

View File

@ -129,8 +129,8 @@ bool GodotPhysicsDirectSpaceState2D::intersect_ray(const RayParameters &p_parame
bool collided = false;
Vector2 res_point, res_normal;
int res_shape;
const GodotCollisionObject2D *res_obj;
int res_shape = -1;
const GodotCollisionObject2D *res_obj = nullptr;
real_t min_d = 1e10;
for (int i = 0; i < amount; i++) {
@ -190,6 +190,7 @@ bool GodotPhysicsDirectSpaceState2D::intersect_ray(const RayParameters &p_parame
if (!collided) {
return false;
}
ERR_FAIL_NULL_V(res_obj, false); // Shouldn't happen but silences warning.
r_result.collider_id = res_obj->get_instance_id();
if (r_result.collider_id.is_valid()) {

View File

@ -120,8 +120,8 @@ bool GodotPhysicsDirectSpaceState3D::intersect_ray(const RayParameters &p_parame
bool collided = false;
Vector3 res_point, res_normal;
int res_shape;
const GodotCollisionObject3D *res_obj;
int res_shape = -1;
const GodotCollisionObject3D *res_obj = nullptr;
real_t min_d = 1e10;
for (int i = 0; i < amount; i++) {
@ -185,6 +185,7 @@ bool GodotPhysicsDirectSpaceState3D::intersect_ray(const RayParameters &p_parame
if (!collided) {
return false;
}
ERR_FAIL_NULL_V(res_obj, false); // Shouldn't happen but silences warning.
r_result.collider_id = res_obj->get_instance_id();
if (r_result.collider_id.is_valid()) {

View File

@ -5344,8 +5344,8 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
last_type = IDENTIFIER_MAX;
_set_tkpos(pos);
DataType data_type;
IdentifierType ident_type;
DataType data_type = TYPE_MAX;
IdentifierType ident_type = IDENTIFIER_MAX;
int array_size = 0;
StringName struct_name;
bool is_local = false;

View File

@ -483,7 +483,7 @@ public:
int array_size = 0;
union Value {
bool boolean;
bool boolean = false;
float real;
int32_t sint;
uint32_t uint;