Skip to content

Commit

Permalink
Merge pull request #22446 from akien-mga/fix-warnings
Browse files Browse the repository at this point in the history
Fix various warnings raised by GCC 5
  • Loading branch information
akien-mga authored Sep 27, 2018
2 parents cb5a629 + cdc411f commit 4cf5bb0
Show file tree
Hide file tree
Showing 80 changed files with 184 additions and 366 deletions.
5 changes: 3 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,13 @@ if selected_platform in platform_list:
# Set exception handling model to avoid warnings caused by Windows system headers.
env.Append(CCFLAGS=['/EHsc'])
else: # Rest of the world
disable_nonessential_warnings = ['-Wno-sign-compare']
if (env["warnings"] == 'extra'):
env.Append(CCFLAGS=['-Wall', '-Wextra'])
elif (env["warnings"] == 'all' or env["warnings"] == 'yes'):
env.Append(CCFLAGS=['-Wall'])
env.Append(CCFLAGS=['-Wall'] + disable_nonessential_warnings)
elif (env["warnings"] == 'moderate'):
env.Append(CCFLAGS=['-Wall', '-Wno-unused'])
env.Append(CCFLAGS=['-Wall', '-Wno-unused'] + disable_nonessential_warnings)
else: # 'no'
env.Append(CCFLAGS=['-w'])
env.Append(CCFLAGS=['-Werror=return-type'])
Expand Down
2 changes: 1 addition & 1 deletion core/io/resource_format_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,7 @@ void ResourceFormatSaverBinaryInstance::save_unicode_string(FileAccess *f, const

CharString utf8 = p_string.utf8();
if (p_bit_on_len) {
f->store_32(utf8.length() + 1 | 0x80000000);
f->store_32((utf8.length() + 1) | 0x80000000);
} else {
f->store_32(utf8.length() + 1);
}
Expand Down
2 changes: 1 addition & 1 deletion core/node_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ NodePath NodePath::get_as_property_path() const {

String initial_subname = data->path[0];

for (size_t i = 1; i < data->path.size(); i++) {
for (int i = 1; i < data->path.size(); i++) {
initial_subname += "/" + data->path[i];
}
new_path.insert(0, initial_subname);
Expand Down
4 changes: 2 additions & 2 deletions core/oa_hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class OAHashMap {
values = memnew_arr(TValue, capacity);
hashes = memnew_arr(uint32_t, capacity);

for (int i = 0; i < capacity; i++) {
for (uint32_t i = 0; i < capacity; i++) {
hashes[i] = 0;
}

Expand Down Expand Up @@ -311,7 +311,7 @@ class OAHashMap {
values = memnew_arr(TValue, p_initial_capacity);
hashes = memnew_arr(uint32_t, p_initial_capacity);

for (int i = 0; i < p_initial_capacity; i++) {
for (uint32_t i = 0; i < p_initial_capacity; i++) {
hashes[i] = 0;
}
}
Expand Down
1 change: 0 additions & 1 deletion core/os/file_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ bool FileAccess::backup_save = false;

FileAccess *FileAccess::create(AccessType p_access) {

ERR_FAIL_COND_V(!create_func, 0);
ERR_FAIL_INDEX_V(p_access, ACCESS_MAX, 0);

FileAccess *ret = create_func[p_access]();
Expand Down
4 changes: 2 additions & 2 deletions core/typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ T *_nullptr() {
/** Generic ABS function, for math uses please use Math::abs */

#ifndef ABS
#define ABS(m_v) ((m_v < 0) ? (-(m_v)) : (m_v))
#define ABS(m_v) (((m_v) < 0) ? (-(m_v)) : (m_v))
#endif

#ifndef SGN
#define SGN(m_v) ((m_v < 0) ? (-1.0) : (+1.0))
#define SGN(m_v) (((m_v) < 0) ? (-1.0) : (+1.0))
#endif

#ifndef MIN
Expand Down
2 changes: 0 additions & 2 deletions drivers/gles2/rasterizer_canvas_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons

bool rebind_shader = true;

Size2 rt_size = Size2(storage->frame.current_rt->width, storage->frame.current_rt->height);

state.current_tex = RID();
state.current_tex_ptr = NULL;
state.current_normal = RID();
Expand Down
13 changes: 0 additions & 13 deletions drivers/gles2/rasterizer_scene_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,10 +712,8 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
bool has_alpha = has_base_alpha || has_blend_alpha;

bool mirror = p_instance->mirror;
bool no_cull = false;

if (p_material->shader->spatial.cull_mode == RasterizerStorageGLES2::Shader::Spatial::CULL_MODE_DISABLED) {
no_cull = true;
mirror = false;
} else if (p_material->shader->spatial.cull_mode == RasterizerStorageGLES2::Shader::Spatial::CULL_MODE_FRONT) {
mirror = !mirror;
Expand All @@ -738,7 +736,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
//shader does not use discard and does not write a vertex position, use generic material
if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
p_material = storage->material_owner.getptr(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided);
no_cull = true;
mirror = false;
} else {
p_material = storage->material_owner.getptr(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material : default_material);
Expand Down Expand Up @@ -1136,8 +1133,6 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
bone_weight[3] = (weight_ptr[3] / (float)0xFFFF);
}

size_t offset = i * 12;

Transform transform;

Transform bone_transforms[4] = {
Expand Down Expand Up @@ -1202,7 +1197,6 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
} break;

case VS::INSTANCE_MULTIMESH: {
RasterizerStorageGLES2::MultiMesh *multi_mesh = static_cast<RasterizerStorageGLES2::MultiMesh *>(p_element->owner);
RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry);

glBindBuffer(GL_ARRAY_BUFFER, s->vertex_id);
Expand Down Expand Up @@ -2267,7 +2261,6 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
uint32_t y;
uint32_t width;
uint32_t height;
uint32_t vp_height;

float zfar = 0;
bool flip_facing = false;
Expand Down Expand Up @@ -2353,14 +2346,12 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
normal_bias = light->param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] * bias_mult;

fbo = directional_shadow.fbo;
vp_height = directional_shadow.size;
} else {
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
ERR_FAIL_COND(!shadow_atlas);
ERR_FAIL_COND(!shadow_atlas->shadow_owners.has(p_light));

fbo = shadow_atlas->fbo;
vp_height = shadow_atlas->size;

uint32_t key = shadow_atlas->shadow_owners[p_light];

Expand Down Expand Up @@ -2669,10 +2660,6 @@ void RasterizerSceneGLES2::initialize() {
}

shadow_filter_mode = SHADOW_FILTER_NEAREST;

RenderList::Element e;
e.sort_key = 0;
e.light_type1 = 1;
}

void RasterizerSceneGLES2::iteration() {
Expand Down
8 changes: 3 additions & 5 deletions drivers/gles2/rasterizer_storage_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_
GLenum type;

bool compressed = false;
bool srgb = false;

if (p_flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING) {
p_flags &= ~VS::TEXTURE_FLAG_MIPMAPS; // no mipies for video
Expand Down Expand Up @@ -4090,15 +4089,14 @@ void RasterizerStorageGLES2::initialize() {
}

config.shrink_textures_x2 = false;
config.float_texture_supported = config.extensions.find("GL_ARB_texture_float") != NULL || config.extensions.find("GL_OES_texture_float") != NULL;
config.s3tc_supported = config.extensions.find("GL_EXT_texture_compression_s3tc") != NULL;
config.etc1_supported = config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture") != NULL;
config.float_texture_supported = config.extensions.has("GL_ARB_texture_float") || config.extensions.has("GL_OES_texture_float");
config.s3tc_supported = config.extensions.has("GL_EXT_texture_compression_s3tc");
config.etc1_supported = config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture");

frame.count = 0;
frame.delta = 0;
frame.current_rt = NULL;
frame.clear_request = false;
// config.keep_original_textures = false;

glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &config.max_texture_image_units);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &config.max_texture_size);
Expand Down
11 changes: 1 addition & 10 deletions drivers/gles2/shader_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,11 +690,6 @@ void ShaderGLES2::use_material(void *p_material) {

Version *v = version_map.getptr(conditional_version);

CustomCode *cc = NULL;
if (v) {
cc = custom_code_map.getptr(v->code_version);
}

// bind uniforms
for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = material->shader->uniforms.front(); E; E = E->next()) {

Expand Down Expand Up @@ -982,7 +977,7 @@ void ShaderGLES2::use_material(void *p_material) {

value.second.resize(default_arg_size);

for (int i = 0; i < default_arg_size; i++) {
for (size_t i = 0; i < default_arg_size; i++) {
if (is_float) {
value.second.write[i].real = 0.0;
} else {
Expand All @@ -992,8 +987,6 @@ void ShaderGLES2::use_material(void *p_material) {
}
}

// GLint location = get_uniform_location(E->key());

GLint location;
if (v->custom_uniform_locations.has(E->key())) {
location = v->custom_uniform_locations[E->key()];
Expand All @@ -1013,8 +1006,6 @@ void ShaderGLES2::use_material(void *p_material) {
int tc = material->textures.size();
Pair<StringName, RID> *textures = material->textures.ptrw();

ShaderLanguage::ShaderNode::Uniform::Hint *texture_hints = material->shader->texture_hints.ptrw();

for (int i = 0; i < tc; i++) {

Pair<ShaderLanguage::DataType, Vector<ShaderLanguage::ConstantNode::Value> > value;
Expand Down
2 changes: 0 additions & 2 deletions drivers/gles3/rasterizer_canvas_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,8 +1223,6 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons

bool rebind_shader = true;

Size2 rt_size = Size2(storage->frame.current_rt->width, storage->frame.current_rt->height);

state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_DISTANCE_FIELD, false);

glBindBuffer(GL_UNIFORM_BUFFER, state.canvas_item_ubo);
Expand Down
9 changes: 4 additions & 5 deletions drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3036,13 +3036,14 @@ void RasterizerSceneGLES3::_setup_reflections(RID *p_reflection_probe_cull_resul
reflection_ubo.ambient[3] = rpi->probe_ptr->interior_ambient_probe_contrib;
} else {
Color ambient_linear;
float contrib = 0;
// FIXME: contrib was retrieved but never used, is it meant to be set as ambient[3]? (GH-20361)
//float contrib = 0;
if (p_env) {
ambient_linear = p_env->ambient_color.to_linear();
ambient_linear.r *= p_env->ambient_energy;
ambient_linear.g *= p_env->ambient_energy;
ambient_linear.b *= p_env->ambient_energy;
contrib = p_env->ambient_sky_contribution;
//contrib = p_env->ambient_sky_contribution;
}

reflection_ubo.ambient[0] = ambient_linear.r;
Expand Down Expand Up @@ -4501,7 +4502,7 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_
RasterizerStorageGLES3::Light *light = storage->light_owner.getornull(light_instance->light);
ERR_FAIL_COND(!light);

uint32_t x, y, width, height, vp_height;
uint32_t x, y, width, height;

float dp_direction = 0.0;
float zfar = 0;
Expand Down Expand Up @@ -4583,7 +4584,6 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_
bias = light->param[VS::LIGHT_PARAM_SHADOW_BIAS] * bias_mult;
normal_bias = light->param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] * bias_mult;
fbo = directional_shadow.fbo;
vp_height = directional_shadow.size;

} else {
//set from shadow atlas
Expand All @@ -4593,7 +4593,6 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_
ERR_FAIL_COND(!shadow_atlas->shadow_owners.has(p_light));

fbo = shadow_atlas->fbo;
vp_height = shadow_atlas->size;

uint32_t key = shadow_atlas->shadow_owners[p_light];

Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/rasterizer_storage_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer)
uint32_t *ptr = (uint32_t *)wb.ptr();
uint32_t num_pixels = data_size / 4;

for (int ofs = 0; ofs < num_pixels; ofs++) {
for (uint32_t ofs = 0; ofs < num_pixels; ofs++) {
uint32_t px = ptr[ofs];
uint32_t a = px >> 30 & 0xFF;

Expand Down
2 changes: 1 addition & 1 deletion drivers/pulseaudio/audio_driver_pulseaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
unsigned int out_idx = 0;

for (unsigned int i = 0; i < ad->buffer_frames; i++) {
for (unsigned int j = 0; j < ad->pa_map.channels - 1; j++) {
for (int j = 0; j < ad->pa_map.channels - 1; j++) {
ad->samples_out.write[out_idx++] = ad->samples_in[in_idx++] >> 16;
}
uint32_t l = ad->samples_in[in_idx++];
Expand Down
2 changes: 1 addition & 1 deletion drivers/unix/net_socket_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ void NetSocketPosix::set_ipv6_only_enabled(bool p_enabled) {

void NetSocketPosix::set_tcp_no_delay_enabled(bool p_enabled) {
ERR_FAIL_COND(!is_open());
ERR_FAIL_COND(_ip_type != TYPE_TCP);
ERR_FAIL_COND(!_is_stream); // Not TCP

int par = p_enabled ? 1 : 0;
if (setsockopt(_sock, IPPROTO_TCP, TCP_NODELAY, SOCK_CBUF(&par), sizeof(int)) < 0) {
Expand Down
4 changes: 1 addition & 3 deletions editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/*************************************************************************/

#include "animation_track_editor.h"

#include "animation_track_editor_plugins.h"
#include "core/os/keyboard.h"
#include "editor/animation_bezier_editor.h"
Expand Down Expand Up @@ -772,9 +773,6 @@ void AnimationTimelineEdit::_notification(int p_what) {
hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height());
draw_texture(hsize_icon, hsize_rect.position);

float keys_from = get_value();
float keys_to = keys_from + zoomw / scale;

{
float time_min = 0;
float time_max = animation->get_length();
Expand Down
5 changes: 0 additions & 5 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,6 @@ void EditorProperty::_notification(int p_what) {
} else {
keying_rect = Rect2();
}

//int vs = get_constant("vseparation", "Tree");
Color guide_color = get_color("guide_color", "Tree");
int vs_height = get_size().height; // vs / 2;
// draw_line(Point2(0, vs_height), Point2(get_size().width, vs_height), guide_color);
}
}

Expand Down
3 changes: 2 additions & 1 deletion editor/editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "scene/3d/camera.h"
#include "scene/gui/popup_menu.h"
#include "servers/visual_server.h"

Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_size) {

Vector<Ref<Mesh> > meshes;
Expand Down Expand Up @@ -522,7 +523,7 @@ int EditorPlugin::update_overlays() const {

if (SpatialEditor::get_singleton()->is_visible()) {
int count = 0;
for (int i = 0; i < SpatialEditor::VIEWPORTS_COUNT; i++) {
for (uint32_t i = 0; i < SpatialEditor::VIEWPORTS_COUNT; i++) {
SpatialEditorViewport *vp = SpatialEditor::get_singleton()->get_editor_viewport(i);
if (vp->is_visible()) {
vp->update_surface();
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_properties_array_dict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ void EditorPropertyDictionary::update_property() {
page->connect("value_changed", this, "_page_changed");
} else {
// Queue childs for deletion, delete immediately might cause errors.
for (size_t i = 1; i < vbox->get_child_count(); i++) {
for (int i = 1; i < vbox->get_child_count(); i++) {
vbox->get_child(i)->queue_delete();
}
}
Expand Down
Loading

0 comments on commit 4cf5bb0

Please sign in to comment.