Fix various warnings: [-Waddress], [-Wpointer-arith], [-Wwrite-strings], [-Wreturn-local-addr] and more

Fixes the following GCC 5 warnings:
```
core/os/file_access.cpp:49:19: warning: the address of 'FileAccess::create_func' will always evaluate as 'true' [-Waddress]
servers/audio_server.cpp:192:70: warning: comparison with string literal results in unspecified behaviour [-Waddress]

drivers/gles2/rasterizer_storage_gles2.cpp:4095:90: warning: NULL used in arithmetic [-Wpointer-arith]

modules/gdnative/register_types.cpp:237:3: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
platform/android/export/export.cpp:207:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

modules/gdscript/gdscript.h:150:67: warning: returning reference to temporary [-Wreturn-local-addr]
servers/physics_2d/collision_object_2d_sw.h:119:56: warning: returning reference to temporary [-Wreturn-local-addr]
servers/physics_2d/collision_object_2d_sw.h:123:56: warning: returning reference to temporary [-Wreturn-local-addr]
servers/physics_2d/collision_object_2d_sw.h:127:50: warning: returning reference to temporary [-Wreturn-local-addr]
servers/physics_2d/collision_object_2d_sw.h:131:52: warning: returning reference to temporary [-Wreturn-local-addr]

editor/plugins/skeleton_editor_plugin.cpp:34:36: warning: extra tokens at end of #include directive
modules/bullet/bullet_types_converter.cpp:31:9: warning: #pragma once in main file

editor/import/editor_scene_importer_gltf.cpp:1996:51: warning: name lookup of 'i' changed
modules/visual_script/visual_script_property_selector.cpp:402:45: warning: name lookup of 'E' changed
scene/gui/tree.cpp:1268:25: warning: name lookup of 'i' changed
scene/resources/visual_shader.cpp:808:32: warning: name lookup of 'i' changed
```
This commit is contained in:
Rémi Verschelde 2018-09-27 13:11:41 +02:00
parent d95bbb8922
commit cdc411fd54
13 changed files with 38 additions and 41 deletions

View File

@ -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]();

View File

@ -4089,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);

View File

@ -1910,15 +1910,15 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
NodePath node_path;
GLTFNode *node = state.nodes[E->key()];
for (int i = 0; i < node->godot_nodes.size(); i++) {
for (int n = 0; n < node->godot_nodes.size(); n++) {
if (node->joints.size()) {
Skeleton *sk = (Skeleton *)node->godot_nodes[i];
Skeleton *sk = (Skeleton *)node->godot_nodes[n];
String path = ap->get_parent()->get_path_to(sk);
String bone = sk->get_bone_name(node->joints[i].godot_bone_index);
String bone = sk->get_bone_name(node->joints[n].godot_bone_index);
node_path = path + ":" + bone;
} else {
node_path = ap->get_parent()->get_path_to(node->godot_nodes[i]);
node_path = ap->get_parent()->get_path_to(node->godot_nodes[n]);
}
for (int i = 0; i < track.rotation_track.times.size(); i++) {
@ -1993,8 +1993,8 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
xform.basis.set_quat_scale(rot, scale);
xform.origin = pos;
Skeleton *skeleton = skeletons[node->joints[i].skin];
int bone = node->joints[i].godot_bone_index;
Skeleton *skeleton = skeletons[node->joints[n].skin];
int bone = node->joints[n].godot_bone_index;
xform = skeleton->get_bone_rest(bone).affine_inverse() * xform;
rot = xform.basis.get_rotation_quat();

View File

@ -29,9 +29,10 @@
/*************************************************************************/
#include "skeleton_editor_plugin.h"
#include "scene/3d/collision_shape.h"
#include "scene/3d/physics_body.h"
#include "scene/3d/physics_joint.h";
#include "scene/3d/physics_joint.h"
#include "scene/resources/capsule_shape.h"
#include "scene/resources/sphere_shape.h"
#include "spatial_editor_plugin.h"

View File

@ -28,8 +28,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#pragma once
#include "bullet_types_converter.h"
/**

View File

@ -29,19 +29,19 @@
/*************************************************************************/
#include "register_types.h"
#include "gdnative/gdnative.h"
#include "gdnative.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "arvr/register_types.h"
#include "nativescript/register_types.h"
#include "net/register_types.h"
#include "pluginscript/register_types.h"
#include "core/engine.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/os/os.h"
#include "core/project_settings.h"
@ -148,7 +148,7 @@ protected:
};
struct LibrarySymbol {
char *name;
const char *name;
bool is_required;
};

View File

@ -147,7 +147,7 @@ public:
const Map<StringName, Variant> &get_constants() const { return constants; }
const Set<StringName> &get_members() const { return members; }
const GDScriptDataType &get_member_type(const StringName &p_member) const {
ERR_FAIL_COND_V(!member_indices.has(p_member), GDScriptDataType());
CRASH_COND(!member_indices.has(p_member));
return member_indices[p_member].data_type;
}
const Map<StringName, GDScriptFunction *> &get_member_functions() const { return member_functions; }

View File

@ -386,8 +386,8 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
}
Vector<String> path = E->get().split("/");
bool is_filter = false;
for (Set<String>::Element *E = filter.front(); E; E = E->next()) {
if (path.size() >= 2 && path[1].findn(E->get()) != -1) {
for (Set<String>::Element *F = filter.front(); F; F = F->next()) {
if (path.size() >= 2 && path[1].findn(F->get()) != -1) {
is_filter = true;
break;
}

View File

@ -194,8 +194,8 @@ static const char *android_perms[] = {
};
struct LauncherIcon {
char *option_id;
char *export_path;
const char *option_id;
const char *export_path;
};
static const LauncherIcon launcher_icons[] = {

View File

@ -1254,13 +1254,13 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
String s = RTR("(Other)");
Vector<String> strings = p_item->cells[i].text.split(",");
for (int i = 0; i < strings.size(); i++) {
int value = i;
if (!strings[i].get_slicec(':', 1).empty()) {
value = strings[i].get_slicec(':', 1).to_int();
for (int j = 0; j < strings.size(); j++) {
int value = j;
if (!strings[j].get_slicec(':', 1).empty()) {
value = strings[j].get_slicec(':', 1).to_int();
}
if (option == value) {
s = strings[i].get_slicec(':', 0);
s = strings[j].get_slicec(':', 0);
break;
}
}

View File

@ -796,10 +796,10 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui
val.basis.transpose();
inputs[i] = "n_in" + itos(node) + "p" + itos(i);
Array values;
for (int i = 0; i < 3; i++) {
values.push_back(val.basis[i].x);
values.push_back(val.basis[i].y);
values.push_back(val.basis[i].z);
for (int j = 0; j < 3; j++) {
values.push_back(val.basis[j].x);
values.push_back(val.basis[j].y);
values.push_back(val.basis[j].z);
}
values.push_back(val.origin.x);
values.push_back(val.origin.y);

View File

@ -189,7 +189,7 @@ void AudioDriverManager::initialize(int p_driver) {
}
}
if (driver_count > 1 && AudioDriver::get_singleton()->get_name() == "Dummy") {
if (driver_count > 1 && String(AudioDriver::get_singleton()->get_name()) == "Dummy") {
WARN_PRINT("All audio drivers failed, falling back to the dummy driver.");
}
}

View File

@ -112,23 +112,23 @@ public:
_FORCE_INLINE_ int get_shape_count() const { return shapes.size(); }
_FORCE_INLINE_ Shape2DSW *get_shape(int p_index) const {
ERR_FAIL_INDEX_V(p_index, shapes.size(), NULL);
CRASH_BAD_INDEX(p_index, shapes.size());
return shapes[p_index].shape;
}
_FORCE_INLINE_ const Transform2D &get_shape_transform(int p_index) const {
ERR_FAIL_INDEX_V(p_index, shapes.size(), Transform2D());
CRASH_BAD_INDEX(p_index, shapes.size());
return shapes[p_index].xform;
}
_FORCE_INLINE_ const Transform2D &get_shape_inv_transform(int p_index) const {
ERR_FAIL_INDEX_V(p_index, shapes.size(), Transform2D());
CRASH_BAD_INDEX(p_index, shapes.size());
return shapes[p_index].xform_inv;
}
_FORCE_INLINE_ const Rect2 &get_shape_aabb(int p_index) const {
ERR_FAIL_INDEX_V(p_index, shapes.size(), Rect2());
CRASH_BAD_INDEX(p_index, shapes.size());
return shapes[p_index].aabb_cache;
}
_FORCE_INLINE_ const Variant &get_shape_metadata(int p_index) const {
ERR_FAIL_INDEX_V(p_index, shapes.size(), Variant());
CRASH_BAD_INDEX(p_index, shapes.size());
return shapes[p_index].metadata;
}
@ -138,16 +138,16 @@ public:
void set_shape_as_disabled(int p_idx, bool p_disabled);
_FORCE_INLINE_ bool is_shape_set_as_disabled(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, shapes.size(), false);
CRASH_BAD_INDEX(p_idx, shapes.size());
return shapes[p_idx].disabled;
}
_FORCE_INLINE_ void set_shape_as_one_way_collision(int p_idx, bool p_one_way_collision) {
ERR_FAIL_INDEX(p_idx, shapes.size());
CRASH_BAD_INDEX(p_idx, shapes.size());
shapes.write[p_idx].one_way_collision = p_one_way_collision;
}
_FORCE_INLINE_ bool is_shape_set_as_one_way_collision(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, shapes.size(), false);
CRASH_BAD_INDEX(p_idx, shapes.size());
return shapes[p_idx].one_way_collision;
}