1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-14 13:41:12 +00:00

Fixes logically dead code (Coverity)

Fixes reported logically dead codes by Coverity

* image.cpp: Doesn't really need any modification. But to remove the bug
report then we have to move the MAX call away from the for loop
statement.

* rasterizer_gles3.cpp: Removes unnecessary elif condition since it is
checked earlier in the function

* collada.cpp: If stamement never reached due to macro ERR_CONTINUE does
the same.

* navigation_mesh.cpp: Variables should always be null - however, also
checked for the very same condition in their function call. Leaving this
for review (whether the function call is necessary or not)

* path_editor_plugin.cpp: If cancel is true, then it should restore the
edited value to the original provided.
http://docs.godotengine.org/en/3.0/classes/class_editorspatialgizmo.html#class-editorspatialgizmo-commit-handle

* spatial_editor_gizmos.cpp: the very condition of i >= 3 is
predetermined in the if case right before it. Thus case 1 is always '1'
and case 2 is always '-1'

* grid_map_editor.cpp: Same as above in spatial_editor_gizmos.cpp

* voxel_light_baker.cpp: Same as above in spatial_editor_gizmos.cpp

* visual_server.cpp: Same as above in spatial_editor_gizmos.cpp

* visual_script_expression.cpp: char '-' is already true in the switch
case mechanism. Thus it can never reach to default case.

* particles.cpp: Case 'PARAM_MAX' is unreachable due to index checking
right before the switch execution.

* shader_language.cpp: Invalid index is handled in switch default case.
`type < TYPE_FLOAT && type > TYPE_VEC4` -> `(type < TYPE_FLOAT || type > TYPE_VEC4`)
Fixes the "always false problem" in TODO comment.
This commit is contained in:
Crazy-P
2018-04-21 22:35:23 +08:00
parent 7d6f210ccb
commit e6deba8d19
13 changed files with 38 additions and 65 deletions

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);
if (hf) {
rcFreeHeightField(hf);
hf = 0;
}
if (chf) {
rcFreeCompactHeightfield(chf);
chf = 0;
}
if (cset) {
rcFreeContourSet(cset);
cset = 0;
}
if (poly_mesh) {
rcFreePolyMesh(poly_mesh);
poly_mesh = 0;
}
if (detail_mesh) {
rcFreePolyMeshDetail(detail_mesh);
detail_mesh = 0;
}
rcFreeHeightField(hf);
hf = 0;
rcFreeCompactHeightfield(chf);
chf = 0;
rcFreeContourSet(cset);
cset = 0;
rcFreePolyMesh(poly_mesh);
poly_mesh = 0;
rcFreePolyMeshDetail(detail_mesh);
detail_mesh = 0;
}
ep.step(TTR("Done!"), 11);
}