mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 06:11:29 +03: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:
@@ -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>
|
||||
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 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[2] = rofs[0];
|
||||
} 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user