Merge pull request #27676 from qarmin/small_fixes_2

Small fixes to static analyzer bugs
This commit is contained in:
Rémi Verschelde 2019-05-01 08:19:04 +02:00 committed by GitHub
commit ae41e35191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 59 additions and 72 deletions

View File

@ -503,7 +503,6 @@ public:
if (p_I->prev_ptr) if (p_I->prev_ptr)
p_I->prev_ptr->next_ptr = p_I->next_ptr; p_I->prev_ptr->next_ptr = p_I->next_ptr;
if (p_I->next_ptr)
p_I->next_ptr->prev_ptr = p_I->prev_ptr; p_I->next_ptr->prev_ptr = p_I->prev_ptr;
_data->last->next_ptr = p_I; _data->last->next_ptr = p_I;
@ -538,7 +537,6 @@ public:
if (_data->last == p_I) if (_data->last == p_I)
_data->last = p_I->prev_ptr; _data->last = p_I->prev_ptr;
if (p_I->prev_ptr)
p_I->prev_ptr->next_ptr = p_I->next_ptr; p_I->prev_ptr->next_ptr = p_I->next_ptr;
if (p_I->next_ptr) if (p_I->next_ptr)

View File

@ -67,7 +67,7 @@ struct Rect2 {
if (p_point.x < position.x) { if (p_point.x < position.x) {
real_t d = position.x - p_point.x; real_t d = position.x - p_point.x;
dist = inside ? d : MIN(dist, d); dist = d;
inside = false; inside = false;
} }
if (p_point.y < position.y) { if (p_point.y < position.y) {

View File

@ -846,6 +846,12 @@ void AnimationPlayerEditor::_update_player() {
onion_skinning->set_disabled(player == NULL); onion_skinning->set_disabled(player == NULL);
pin->set_disabled(player == NULL); pin->set_disabled(player == NULL);
if (!player) {
AnimationPlayerEditor::singleton->get_track_editor()->update_keying();
EditorNode::get_singleton()->update_keying();
return;
}
int active_idx = -1; int active_idx = -1;
for (List<StringName>::Element *E = animlist.front(); E; E = E->next()) { for (List<StringName>::Element *E = animlist.front(); E; E = E->next()) {
@ -858,12 +864,6 @@ void AnimationPlayerEditor::_update_player() {
active_idx = animation->get_item_count() - 1; active_idx = animation->get_item_count() - 1;
} }
if (!player) {
AnimationPlayerEditor::singleton->get_track_editor()->update_keying();
EditorNode::get_singleton()->update_keying();
return;
}
updating = false; updating = false;
if (active_idx != -1) { if (active_idx != -1) {
animation->select(active_idx); animation->select(active_idx);

View File

@ -1471,10 +1471,14 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
if (!use_single_axis || use_y) control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false); if (!use_single_axis || use_y) control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false);
break; break;
case DRAG_ANCHOR_ALL: case DRAG_ANCHOR_ALL:
if (!use_single_axis || !use_y) control->set_anchor(MARGIN_LEFT, new_anchor.x, false, true); if (!use_single_axis || !use_y) {
if (!use_single_axis || !use_y) control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, true); control->set_anchor(MARGIN_LEFT, new_anchor.x, false, true);
if (!use_single_axis || use_y) control->set_anchor(MARGIN_TOP, new_anchor.y, false, true); control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, true);
if (!use_single_axis || use_y) control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, true); }
if (!use_single_axis || use_y) {
control->set_anchor(MARGIN_TOP, new_anchor.y, false, true);
control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, true);
}
break; break;
default: default:
break; break;

View File

@ -407,10 +407,11 @@ public:
csi.resize(_debug_call_stack_pos); csi.resize(_debug_call_stack_pos);
for (int i = 0; i < _debug_call_stack_pos; i++) { for (int i = 0; i < _debug_call_stack_pos; i++) {
csi.write[_debug_call_stack_pos - i - 1].line = _call_stack[i].line ? *_call_stack[i].line : 0; csi.write[_debug_call_stack_pos - i - 1].line = _call_stack[i].line ? *_call_stack[i].line : 0;
if (_call_stack[i].function) if (_call_stack[i].function) {
csi.write[_debug_call_stack_pos - i - 1].func = _call_stack[i].function->get_name(); csi.write[_debug_call_stack_pos - i - 1].func = _call_stack[i].function->get_name();
csi.write[_debug_call_stack_pos - i - 1].file = _call_stack[i].function->get_script()->get_path(); csi.write[_debug_call_stack_pos - i - 1].file = _call_stack[i].function->get_script()->get_path();
} }
}
return csi; return csi;
} }

View File

@ -2178,7 +2178,6 @@ static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p
static void _find_call_arguments(const GDScriptCompletionContext &p_context, const GDScriptCompletionIdentifier &p_base, const StringName &p_method, int p_argidx, bool p_static, Set<String> &r_result, String &r_arghint) { static void _find_call_arguments(const GDScriptCompletionContext &p_context, const GDScriptCompletionIdentifier &p_base, const StringName &p_method, int p_argidx, bool p_static, Set<String> &r_result, String &r_arghint) {
Variant base = p_base.value; Variant base = p_base.value;
GDScriptParser::DataType base_type = p_base.type; GDScriptParser::DataType base_type = p_base.type;
bool _static = false;
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\""; const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
@ -2191,14 +2190,12 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
return; return;
} }
} }
if (!_static) {
for (int i = 0; i < base_type.class_type->functions.size(); i++) { for (int i = 0; i < base_type.class_type->functions.size(); i++) {
if (base_type.class_type->functions[i]->name == p_method) { if (base_type.class_type->functions[i]->name == p_method) {
r_arghint = _make_arguments_hint(base_type.class_type->functions[i], p_argidx); r_arghint = _make_arguments_hint(base_type.class_type->functions[i], p_argidx);
return; return;
} }
} }
}
if ((p_method == "connect" || p_method == "emit_signal") && p_argidx == 0) { if ((p_method == "connect" || p_method == "emit_signal") && p_argidx == 0) {
for (int i = 0; i < base_type.class_type->_signals.size(); i++) { for (int i = 0; i < base_type.class_type->_signals.size(); i++) {

View File

@ -282,7 +282,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
switch (tokenizer->get_token()) { switch (tokenizer->get_token()) {
case GDScriptTokenizer::TK_CURSOR: { case GDScriptTokenizer::TK_CURSOR: {
completion_cursor = StringName();
completion_type = COMPLETION_GET_NODE; completion_type = COMPLETION_GET_NODE;
completion_class = current_class; completion_class = current_class;
completion_function = current_function; completion_function = current_function;
@ -2870,8 +2869,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
lv->assign_op = op; lv->assign_op = op;
lv->assign = assigned; lv->assign = assigned;
lv->assign_op = op;
if (!_end_statement()) { if (!_end_statement()) {
_set_error("Expected end of statement (var)"); _set_error("Expected end of statement (var)");
return; return;
@ -6226,8 +6223,8 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
return DataType(); return DataType();
} }
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (var_op == Variant::OP_DIVIDE && argument_a_type.has_type && argument_a_type.kind == DataType::BUILTIN && argument_a_type.builtin_type == Variant::INT && if (var_op == Variant::OP_DIVIDE && argument_a_type.kind == DataType::BUILTIN && argument_a_type.builtin_type == Variant::INT &&
argument_b_type.has_type && argument_b_type.kind == DataType::BUILTIN && argument_b_type.builtin_type == Variant::INT) { argument_b_type.kind == DataType::BUILTIN && argument_b_type.builtin_type == Variant::INT) {
_add_warning(GDScriptWarning::INTEGER_DIVISION, op->line); _add_warning(GDScriptWarning::INTEGER_DIVISION, op->line);
} }
#endif // DEBUG_ENABLED #endif // DEBUG_ENABLED
@ -6938,11 +6935,9 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if (current_function && !for_completion && !is_static && p_call->arguments[0]->type == Node::TYPE_SELF && current_function->_static) { if (current_function && !for_completion && !is_static && p_call->arguments[0]->type == Node::TYPE_SELF && current_function->_static) {
if (current_function && current_function->_static && p_call->arguments[0]->type == Node::TYPE_SELF) {
_set_error("Can't call non-static function from a static function.", p_call->line); _set_error("Can't call non-static function from a static function.", p_call->line);
return DataType(); return DataType();
} }
}
if (check_types && !is_static && !is_initializer && base_type.is_meta_type) { if (check_types && !is_static && !is_initializer && base_type.is_meta_type) {
_set_error("Non-static function '" + String(callee_name) + "' can only be called from an instance.", p_call->line); _set_error("Non-static function '" + String(callee_name) + "' can only be called from an instance.", p_call->line);

View File

@ -1864,7 +1864,6 @@ public:
return ERR_FILE_NOT_FOUND; return ERR_FILE_NOT_FOUND;
} }
ERR_FAIL_COND_V(!pkg, ERR_CANT_OPEN);
int ret = unzGoToFirstFile(pkg); int ret = unzGoToFirstFile(pkg);
zlib_filefunc_def io2 = io; zlib_filefunc_def io2 = io;
@ -2204,7 +2203,6 @@ public:
return ERR_FILE_NOT_FOUND; return ERR_FILE_NOT_FOUND;
} }
ERR_FAIL_COND_V(!tmp_unaligned, ERR_CANT_OPEN);
ret = unzGoToFirstFile(tmp_unaligned); ret = unzGoToFirstFile(tmp_unaligned);
io2 = io; io2 = io;

View File

@ -920,7 +920,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
EditorNode::add_io_error("Could not open export template (not a zip file?):\n" + src_pkg_name); EditorNode::add_io_error("Could not open export template (not a zip file?):\n" + src_pkg_name);
return ERR_CANT_OPEN; return ERR_CANT_OPEN;
} }
ERR_FAIL_COND_V(!src_pkg_zip, ERR_CANT_OPEN);
int ret = unzGoToFirstFile(src_pkg_zip); int ret = unzGoToFirstFile(src_pkg_zip);
Vector<uint8_t> project_file_data; Vector<uint8_t> project_file_data;
while (ret == UNZ_OK) { while (ret == UNZ_OK) {

View File

@ -441,7 +441,6 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
return ERR_FILE_NOT_FOUND; return ERR_FILE_NOT_FOUND;
} }
ERR_FAIL_COND_V(!src_pkg_zip, ERR_CANT_OPEN);
int ret = unzGoToFirstFile(src_pkg_zip); int ret = unzGoToFirstFile(src_pkg_zip);
String binary_to_use = "godot_osx_" + String(p_debug ? "debug" : "release") + ".64"; String binary_to_use = "godot_osx_" + String(p_debug ? "debug" : "release") + ".64";

View File

@ -96,13 +96,11 @@ static void handle_crash(int sig) {
String output = ""; String output = "";
// Try to get the file/line number using addr2line // Try to get the file/line number using addr2line
if (OS::get_singleton()) {
int ret; int ret;
Error err = OS::get_singleton()->execute(String("addr2line"), args, true, NULL, &output, &ret); Error err = OS::get_singleton()->execute(String("addr2line"), args, true, NULL, &output, &ret);
if (err == OK) { if (err == OK) {
output.erase(output.length() - 1, 1); output.erase(output.length() - 1, 1);
} }
}
fprintf(stderr, "[%ld] %s (%ls)\n", i, fname, output.c_str()); fprintf(stderr, "[%ld] %s (%ls)\n", i, fname, output.c_str());
} }

View File

@ -503,7 +503,6 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
current_cursor = CURSOR_ARROW; current_cursor = CURSOR_ARROW;
if (cursor_theme) {
for (int i = 0; i < CURSOR_MAX; i++) { for (int i = 0; i < CURSOR_MAX; i++) {
static const char *cursor_file[] = { static const char *cursor_file[] = {
@ -533,7 +532,6 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
print_verbose("Failed loading custom cursor: " + String(cursor_file[i])); print_verbose("Failed loading custom cursor: " + String(cursor_file[i]));
} }
} }
}
{ {
Pixmap cursormask; Pixmap cursormask;

View File

@ -115,7 +115,7 @@ bool PowerX11::make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) {
*(ptr++) = '\0'; /* terminate the key. */ *(ptr++) = '\0'; /* terminate the key. */
while ((*ptr == ' ') && (*ptr != '\0')) { while (*ptr == ' ') {
ptr++; /* skip whitespace. */ ptr++; /* skip whitespace. */
} }

View File

@ -93,7 +93,6 @@ private:
template <class T> template <class T>
struct TKey : public Key { struct TKey : public Key {
float time;
T value; T value;
}; };