Merge pull request #18321 from Crazy-P/Fixes-logically-dead-code

Fixes logically dead code (Coverity)
This commit is contained in:
Rémi Verschelde 2018-05-01 08:35:10 +02:00 committed by GitHub
commit 4cce6f3417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 38 additions and 65 deletions

View File

@ -366,6 +366,8 @@ int Image::get_mipmap_count() const {
template <uint32_t read_bytes, bool read_alpha, uint32_t write_bytes, bool write_alpha, bool read_gray, bool write_gray> template <uint32_t read_bytes, bool read_alpha, uint32_t write_bytes, bool write_alpha, bool read_gray, bool write_gray>
static void _convert(int p_width, int p_height, const uint8_t *p_src, uint8_t *p_dst) { static void _convert(int p_width, int p_height, const uint8_t *p_src, uint8_t *p_dst) {
uint32_t max_bytes = MAX(read_bytes, write_bytes);
for (int y = 0; y < p_height; y++) { for (int y = 0; y < p_height; y++) {
for (int x = 0; x < p_width; x++) { for (int x = 0; x < p_width; x++) {
@ -379,7 +381,8 @@ static void _convert(int p_width, int p_height, const uint8_t *p_src, uint8_t *p
rgba[1] = rofs[0]; rgba[1] = rofs[0];
rgba[2] = rofs[0]; rgba[2] = rofs[0];
} else { } else {
for (uint32_t i = 0; i < MAX(read_bytes, write_bytes); i++) {
for (uint32_t i = 0; i < max_bytes; i++) {
rgba[i] = (i < read_bytes) ? rofs[i] : 0; rgba[i] = (i < read_bytes) ? rofs[i] : 0;
} }

View File

@ -264,8 +264,9 @@ NodePath NodePath::get_as_property_path() const {
Vector<StringName> new_path = data->subpath; Vector<StringName> new_path = data->subpath;
String initial_subname = data->path[0]; String initial_subname = data->path[0];
for (size_t i = 1; i < data->path.size(); i++) { for (size_t i = 1; i < data->path.size(); i++) {
initial_subname += i == 0 ? data->path[i].operator String() : "/" + data->path[i]; initial_subname += "/" + data->path[i];
} }
new_path.insert(0, initial_subname); new_path.insert(0, initial_subname);

View File

@ -111,8 +111,6 @@ static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GL
strcpy(debType, "Portability"); strcpy(debType, "Portability");
else if (type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB) else if (type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB)
strcpy(debType, "Performance"); strcpy(debType, "Performance");
else if (type == _EXT_DEBUG_TYPE_OTHER_ARB)
strcpy(debType, "Other");
if (severity == _EXT_DEBUG_SEVERITY_HIGH_ARB) if (severity == _EXT_DEBUG_SEVERITY_HIGH_ARB)
strcpy(debSev, "High"); strcpy(debSev, "High");

View File

@ -2266,10 +2266,8 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) {
} }
node = node->parent; node = node->parent;
} }
ERR_CONTINUE(!sk);
if (!sk) ERR_CONTINUE(!sk);
continue; //bleh
if (!skeleton) { if (!skeleton) {
skeleton = sk; skeleton = sk;

View File

@ -280,26 +280,20 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
_build_recast_navigation_mesh(p_nav_mesh, &ep, hf, chf, cset, poly_mesh, detail_mesh, vertices, indices); _build_recast_navigation_mesh(p_nav_mesh, &ep, hf, chf, cset, poly_mesh, detail_mesh, vertices, indices);
if (hf) { rcFreeHeightField(hf);
rcFreeHeightField(hf); hf = 0;
hf = 0;
} rcFreeCompactHeightfield(chf);
if (chf) { chf = 0;
rcFreeCompactHeightfield(chf);
chf = 0; rcFreeContourSet(cset);
} cset = 0;
if (cset) {
rcFreeContourSet(cset); rcFreePolyMesh(poly_mesh);
cset = 0; poly_mesh = 0;
}
if (poly_mesh) { rcFreePolyMeshDetail(detail_mesh);
rcFreePolyMesh(poly_mesh); detail_mesh = 0;
poly_mesh = 0;
}
if (detail_mesh) {
rcFreePolyMeshDetail(detail_mesh);
detail_mesh = 0;
}
} }
ep.step(TTR("Done!"), 11); ep.step(TTR("Done!"), 11);
} }

View File

@ -167,18 +167,12 @@ void PathSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p
Vector3 ofs; Vector3 ofs;
if (p_cancel) {
return;
}
if (t == 0) { if (t == 0) {
if (p_cancel) { if (p_cancel) {
c->set_point_in(p_idx, p_restore); c->set_point_in(p_idx, p_restore);
return; return;
} }
ur->create_action(TTR("Set Curve In Position")); ur->create_action(TTR("Set Curve In Position"));
ur->add_do_method(c.ptr(), "set_point_in", idx, c->get_point_in(idx)); ur->add_do_method(c.ptr(), "set_point_in", idx, c->get_point_in(idx));
ur->add_undo_method(c.ptr(), "set_point_in", idx, p_restore); ur->add_undo_method(c.ptr(), "set_point_in", idx, p_restore);
@ -186,10 +180,11 @@ void PathSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p
} else { } else {
if (p_cancel) { if (p_cancel) {
c->set_point_out(idx, p_restore); c->set_point_out(idx, p_restore);
return; return;
} }
ur->create_action(TTR("Set Curve Out Position")); ur->create_action(TTR("Set Curve Out Position"));
ur->add_do_method(c.ptr(), "set_point_out", idx, c->get_point_out(idx)); ur->add_do_method(c.ptr(), "set_point_out", idx, c->get_point_out(idx));
ur->add_undo_method(c.ptr(), "set_point_out", idx, p_restore); ur->add_undo_method(c.ptr(), "set_point_out", idx, p_restore);

View File

@ -4052,9 +4052,9 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
for (int k = 0; k < 3; k++) { for (int k = 0; k < 3; k++) {
if (i < 3) if (i < 3)
face_points[j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1); face_points[j][(i + k) % 3] = v[k];
else else
face_points[3 - j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1); face_points[3 - j][(i + k) % 3] = -v[k];
} }
} }
//tri 1 //tri 1

View File

@ -1154,9 +1154,9 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
for (int k = 0; k < 3; k++) { for (int k = 0; k < 3; k++) {
if (i < 3) if (i < 3)
face_points[j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1); face_points[j][(i + k) % 3] = v[k];
else else
face_points[3 - j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1); face_points[3 - j][(i + k) % 3] = -v[k];
} }
} }

View File

@ -455,7 +455,7 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
break; break;
} }
if (cchar == '-' || (cchar >= '0' && cchar <= '9')) { if (cchar >= '0' && cchar <= '9') {
//a number //a number
String num; String num;
@ -466,11 +466,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
#define READING_DONE 4 #define READING_DONE 4
int reading = READING_INT; int reading = READING_INT;
if (cchar == '-') {
num += '-';
cchar = GET_CHAR();
}
CharType c = cchar; CharType c = cchar;
bool exp_sign = false; bool exp_sign = false;
bool exp_beg = false; bool exp_beg = false;

View File

@ -1028,8 +1028,6 @@ void ParticlesMaterial::set_param(Parameter p_param, float p_value) {
case PARAM_ANIM_OFFSET: { case PARAM_ANIM_OFFSET: {
VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset, p_value); VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset, p_value);
} break; } break;
case PARAM_MAX: {
};
} }
} }
float ParticlesMaterial::get_param(Parameter p_param) const { float ParticlesMaterial::get_param(Parameter p_param) const {
@ -1082,8 +1080,6 @@ void ParticlesMaterial::set_param_randomness(Parameter p_param, float p_value) {
case PARAM_ANIM_OFFSET: { case PARAM_ANIM_OFFSET: {
VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_random, p_value); VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_random, p_value);
} break; } break;
case PARAM_MAX: {
};
} }
} }
float ParticlesMaterial::get_param_randomness(Parameter p_param) const { float ParticlesMaterial::get_param_randomness(Parameter p_param) const {
@ -1160,8 +1156,6 @@ void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture>
case PARAM_ANIM_OFFSET: { case PARAM_ANIM_OFFSET: {
VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_texture, p_texture); VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_texture, p_texture);
} break; } break;
case PARAM_MAX: {
};
} }
_queue_shader_change(); _queue_shader_change();

View File

@ -2338,9 +2338,9 @@ Ref<MultiMesh> VoxelLightBaker::create_debug_multimesh(DebugMode p_mode) {
for (int k = 0; k < 3; k++) { for (int k = 0; k < 3; k++) {
if (i < 3) if (i < 3)
face_points[j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1); face_points[j][(i + k) % 3] = v[k];
else else
face_points[3 - j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1); face_points[3 - j][(i + k) % 3] = -v[k];
} }
} }

View File

@ -2677,7 +2677,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
return NULL; return NULL;
} }
bool index_valid = false;
DataType member_type = TYPE_VOID; DataType member_type = TYPE_VOID;
switch (expr->get_datatype()) { switch (expr->get_datatype()) {
@ -2696,7 +2695,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
_set_error("Only integer constants are allowed as index at the moment"); _set_error("Only integer constants are allowed as index at the moment");
return NULL; return NULL;
} }
index_valid = true;
switch (expr->get_datatype()) { switch (expr->get_datatype()) {
case TYPE_BVEC2: member_type = TYPE_BOOL; break; case TYPE_BVEC2: member_type = TYPE_BOOL; break;
case TYPE_VEC2: member_type = TYPE_FLOAT; break; case TYPE_VEC2: member_type = TYPE_FLOAT; break;
@ -2721,7 +2720,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
_set_error("Only integer constants are allowed as index at the moment"); _set_error("Only integer constants are allowed as index at the moment");
return NULL; return NULL;
} }
index_valid = true;
switch (expr->get_datatype()) { switch (expr->get_datatype()) {
case TYPE_BVEC3: member_type = TYPE_BOOL; break; case TYPE_BVEC3: member_type = TYPE_BOOL; break;
case TYPE_VEC3: member_type = TYPE_FLOAT; break; case TYPE_VEC3: member_type = TYPE_FLOAT; break;
@ -2745,7 +2744,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
_set_error("Only integer constants are allowed as index at the moment"); _set_error("Only integer constants are allowed as index at the moment");
return NULL; return NULL;
} }
index_valid = true;
switch (expr->get_datatype()) { switch (expr->get_datatype()) {
case TYPE_BVEC4: member_type = TYPE_BOOL; break; case TYPE_BVEC4: member_type = TYPE_BOOL; break;
case TYPE_VEC4: member_type = TYPE_FLOAT; break; case TYPE_VEC4: member_type = TYPE_FLOAT; break;
@ -2760,11 +2759,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
} }
} }
if (!index_valid) {
_set_error("Invalid index");
return NULL;
}
OperatorNode *op = alloc_node<OperatorNode>(); OperatorNode *op = alloc_node<OperatorNode>();
op->op = OP_INDEX; op->op = OP_INDEX;
op->return_cache = member_type; op->return_cache = member_type;
@ -3662,7 +3656,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
_set_error("void datatype not allowed here"); _set_error("void datatype not allowed here");
return ERR_PARSE_ERROR; return ERR_PARSE_ERROR;
} }
if (!uniform && type < TYPE_FLOAT && type > TYPE_VEC4) { // FIXME: always false! should it be || instead?
if (!uniform && (type < TYPE_FLOAT || type > TYPE_VEC4)) {
_set_error("Invalid type for varying, only float,vec2,vec3,vec4 allowed."); _set_error("Invalid type for varying, only float,vec2,vec3,vec4 allowed.");
return ERR_PARSE_ERROR; return ERR_PARSE_ERROR;
} }

View File

@ -214,9 +214,9 @@ RID VisualServer::_make_test_cube() {
for (int k = 0; k < 3; k++) { for (int k = 0; k < 3; k++) {
if (i < 3) if (i < 3)
face_points[j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1); face_points[j][(i + k) % 3] = v[k];
else else
face_points[3 - j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1); face_points[3 - j][(i + k) % 3] = -v[k];
} }
normal_points[j] = Vector3(); normal_points[j] = Vector3();
normal_points[j][i % 3] = (i >= 3 ? -1 : 1); normal_points[j][i % 3] = (i >= 3 ? -1 : 1);