Skip to content

Commit

Permalink
Removed unnecessary assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubonnek committed Aug 21, 2017
1 parent 4717d37 commit 738d2ab
Show file tree
Hide file tree
Showing 37 changed files with 65 additions and 128 deletions.
3 changes: 1 addition & 2 deletions core/bind/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,11 +1406,10 @@ Error _File::open_encrypted_pass(const String &p_path, int p_mode_flags, const S
Error _File::open_compressed(const String &p_path, int p_mode_flags, int p_compress_mode) {

FileAccessCompressed *fac = memnew(FileAccessCompressed);
Error err = OK;

fac->configure("GCPF", (Compression::Mode)p_compress_mode);

err = fac->_open(p_path, p_mode_flags);
Error err = fac->_open(p_path, p_mode_flags);

if (err) {
memdelete(fac);
Expand Down
1 change: 0 additions & 1 deletion core/io/file_access_compressed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ FileAccessCompressed::FileAccessCompressed() {

f = NULL;
magic = "GCMP";
block_size = 16384;
cmode = Compression::MODE_ZSTD;
writing = false;
write_ptr = 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/gles2/rasterizer_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,6 @@ Ref<Image> RasterizerGLES2::_get_gl_image_and_format(const Ref<Image> &p_image,

} else {

r_gl_internal_format = _EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
r_gl_internal_format = (srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT : _EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
r_gl_components = 1; //doesn't matter much
r_compressed = true;
Expand Down
1 change: 0 additions & 1 deletion editor/code_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ void FindReplaceBar::_get_search_from(int &r_line, int &r_col) {
int selection_from_col = text_edit->get_selection_from_column();

if (r_col >= selection_from_col && r_col <= text_edit->get_selection_to_column()) {
r_col = selection_line;
r_col = selection_from_col;
}
}
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_asset_installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
//get filename
unz_file_info info;
char fname[16384];
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);

String name = fname;
files_sorted.insert(name);
Expand Down
8 changes: 4 additions & 4 deletions editor/export_template_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void ExportTemplateManager::_install_from_file(const String &p_file) {
data.resize(info.uncompressed_size);

//read
ret = unzOpenCurrentFile(pkg);
unzOpenCurrentFile(pkg);
ret = unzReadCurrentFile(pkg, data.ptr(), data.size());
unzCloseCurrentFile(pkg);

Expand Down Expand Up @@ -257,16 +257,16 @@ void ExportTemplateManager::_install_from_file(const String &p_file) {
//get filename
unz_file_info info;
char fname[16384];
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);

String file = fname;

Vector<uint8_t> data;
data.resize(info.uncompressed_size);

//read
ret = unzOpenCurrentFile(pkg);
ret = unzReadCurrentFile(pkg, data.ptr(), data.size());
unzOpenCurrentFile(pkg);
unzReadCurrentFile(pkg, data.ptr(), data.size());
unzCloseCurrentFile(pkg);

print_line(fname);
Expand Down
3 changes: 1 addition & 2 deletions editor/filesystem_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1465,10 +1465,9 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) {
return;
}

EditorFileSystemDirectory *efsd = NULL;
int pos;

efsd = EditorFileSystem::get_singleton()->find_file(path, &pos);
EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->find_file(path, &pos);

if (efsd) {

Expand Down
5 changes: 1 addition & 4 deletions editor/import/editor_import_collada.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1584,14 +1584,12 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
apply_xform = Transform();
}

Collada::SkinControllerData::Source *joint_src = NULL;

ERR_FAIL_COND_V(!skin->weights.sources.has("JOINT"), ERR_INVALID_DATA);

String joint_id = skin->weights.sources["JOINT"].source;
ERR_FAIL_COND_V(!skin->sources.has(joint_id), ERR_INVALID_DATA);

joint_src = &skin->sources[joint_id];
Collada::SkinControllerData::Source *joint_src = &skin->sources[joint_id];

bone_remap.resize(joint_src->sarray.size());

Expand Down Expand Up @@ -2317,7 +2315,6 @@ Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path
if (state.animations.size() == 0)
return Ref<Animation>();
Ref<Animation> anim = state.animations[0];
anim = state.animations[0];
print_line("Anim Load OK");
String base = p_path.get_basename().to_lower();
if (p_flags & IMPORT_ANIMATION_DETECT_LOOP) {
Expand Down
4 changes: 1 addition & 3 deletions editor/plugins/particles_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ void ParticlesEditor::_generate_emission_points() {

Vector3 dir;
dir[Math::rand() % 3] = 1.0;
Vector3 ofs = Vector3(1, 1, 1) - dir;
ofs = (Vector3(1, 1, 1) - dir) * Vector3(Math::randf(), Math::randf(), Math::randf()) * aabb.size;
ofs += aabb.position;
Vector3 ofs = (Vector3(1, 1, 1) - dir) * Vector3(Math::randf(), Math::randf(), Math::randf()) * aabb.size + aabb.position;

Vector3 ofsv = ofs + aabb.size * dir;

Expand Down
25 changes: 8 additions & 17 deletions editor/script_create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,28 +531,19 @@ void ScriptCreateDialog::_bind_methods() {

ScriptCreateDialog::ScriptCreateDialog() {

GridContainer *gc = memnew(GridContainer);
VBoxContainer *vb = memnew(VBoxContainer);
HBoxContainer *hb = memnew(HBoxContainer);
Label *l = memnew(Label);
Control *empty = memnew(Control);
Control *empty_h = memnew(Control);
Control *empty_v = memnew(Control);
PanelContainer *pc = memnew(PanelContainer);

/* DIALOG */

/* Main Controls */

gc = memnew(GridContainer);
GridContainer *gc = memnew(GridContainer);
gc->set_columns(2);

/* Error Messages Field */

vb = memnew(VBoxContainer);
VBoxContainer *vb = memnew(VBoxContainer);

hb = memnew(HBoxContainer);
l = memnew(Label);
HBoxContainer *hb = memnew(HBoxContainer);
Label *l = memnew(Label);
l->set_text(" - ");
hb->add_child(l);
error_label = memnew(Label);
Expand All @@ -571,19 +562,19 @@ ScriptCreateDialog::ScriptCreateDialog() {
hb->add_child(path_error_label);
vb->add_child(hb);

pc = memnew(PanelContainer);
PanelContainer *pc = memnew(PanelContainer);
pc->set_h_size_flags(Control::SIZE_FILL);
pc->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("bg", "Tree"));
pc->add_child(vb);

/* Margins */

empty_h = memnew(Control);
Control *empty_h = memnew(Control);
empty_h->set_name("empty_h"); //duplicate() doesn't like nodes without a name
empty_h->set_h_size_flags(Control::SIZE_EXPAND_FILL);
empty_h->set_v_size_flags(Control::SIZE_EXPAND_FILL);
empty_h->set_custom_minimum_size(Size2(0, 10 * EDSCALE));
empty_v = memnew(Control);
Control *empty_v = memnew(Control);
empty_v->set_name("empty_v");
empty_v->set_h_size_flags(Control::SIZE_EXPAND_FILL);
empty_v->set_v_size_flags(Control::SIZE_EXPAND_FILL);
Expand Down Expand Up @@ -684,7 +675,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
internal = memnew(CheckButton);
internal->connect("pressed", this, "_built_in_pressed");
hb = memnew(HBoxContainer);
empty = memnew(Control);
Control *empty = memnew(Control);
hb->add_child(internal);
hb->add_child(empty);
l = memnew(Label);
Expand Down
5 changes: 3 additions & 2 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,10 @@ Error Main::setup2() {

MAIN_PRINT("Main: Setup Logo");

bool show_logo = true;
#ifdef JAVASCRIPT_ENABLED
show_logo = false;
bool show_logo = false;
#else
bool show_logo = true;
#endif

if (init_screen != -1) {
Expand Down
3 changes: 1 addition & 2 deletions main/tests/test_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,6 @@ bool test_28() {
bool test_29() {

bool state = true;
bool success = false;

IP_Address ip0("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
OS::get_singleton()->print("ip0 is %ls\n", String(ip0).c_str());
Expand All @@ -817,7 +816,7 @@ bool test_29() {
OS::get_singleton()->print("ip6 is %ls\n", String(ip3).c_str());

String ip4 = "192.168.0.1";
success = ip4.is_valid_ip_address();
bool success = ip4.is_valid_ip_address();
OS::get_singleton()->print("Is valid ipv4: %ls, %s\n", ip4.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;

Expand Down
3 changes: 1 addition & 2 deletions modules/gdnative/gdnative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,8 @@ bool GDNative::terminate() {
return false;
}

Error error = OK;
void *library_terminate;
error = OS::get_singleton()->get_dynamic_library_symbol_handle(
Error error = OS::get_singleton()->get_dynamic_library_symbol_handle(
native_handle,
terminate_symbol,
library_terminate);
Expand Down
4 changes: 1 addition & 3 deletions modules/gdscript/gd_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,15 +1451,13 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode

codegen.opcodes.push_back(GDFunction::OPCODE_END);

GDFunction *gdfunc = NULL;

/*
if (String(p_func->name)=="") { //initializer func
gdfunc = &p_script->initializer;
*/
//} else { //regular func
p_script->member_functions[func_name] = memnew(GDFunction);
gdfunc = p_script->member_functions[func_name];
GDFunction *gdfunc = p_script->member_functions[func_name];
//}

if (p_func) {
Expand Down
20 changes: 5 additions & 15 deletions modules/gdscript/gd_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2381,9 +2381,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {

tokenizer->advance();
Node *subexpr = NULL;

subexpr = _parse_and_reduce_expression(p_block, p_static);
Node *subexpr = _parse_and_reduce_expression(p_block, p_static);
if (!subexpr) {
if (_recover_from_completion()) {
break;
Expand Down Expand Up @@ -3135,9 +3133,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
defaulting = true;
tokenizer->advance(1);
Node *defval = NULL;

defval = _parse_and_reduce_expression(p_class, _static);
Node *defval = _parse_and_reduce_expression(p_class, _static);
if (!defval || error_set)
return;

Expand Down Expand Up @@ -3875,9 +3871,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
#endif
tokenizer->advance();

Node *subexpr = NULL;

subexpr = _parse_and_reduce_expression(p_class, false, autoexport);
Node *subexpr = _parse_and_reduce_expression(p_class, false, autoexport);
if (!subexpr) {
if (_recover_from_completion()) {
break;
Expand Down Expand Up @@ -4035,9 +4029,7 @@ void GDParser::_parse_class(ClassNode *p_class) {

tokenizer->advance();

Node *subexpr = NULL;

subexpr = _parse_and_reduce_expression(p_class, true, true);
Node *subexpr = _parse_and_reduce_expression(p_class, true, true);
if (!subexpr) {
if (_recover_from_completion()) {
break;
Expand Down Expand Up @@ -4103,9 +4095,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
tokenizer->advance();

Node *subexpr = NULL;

subexpr = _parse_and_reduce_expression(p_class, true, true);
Node *subexpr = _parse_and_reduce_expression(p_class, true, true);
if (!subexpr) {
if (_recover_from_completion()) {
break;
Expand Down
4 changes: 1 addition & 3 deletions modules/gdscript/gd_tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1187,9 +1187,7 @@ Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) {
int line_count = decode_uint32(&buf[16]);
int token_count = decode_uint32(&buf[20]);

const uint8_t *b = buf;

b = &buf[24];
const uint8_t *b = &buf[24];
total_len -= 24;

identifiers.resize(identifier_count);
Expand Down
3 changes: 1 addition & 2 deletions modules/nativescript/api_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ List<ClassAPI> generate_c_api_classes() {
class_api.is_instanciable = !class_api.is_singleton && ClassDB::can_instance(class_name);

{
bool is_reference = false;
List<StringName> inheriters;
ClassDB::get_inheriters_from_class("Reference", &inheriters);
is_reference = !!inheriters.find(class_name);
bool is_reference = !!inheriters.find(class_name);
// @Unclear
class_api.is_reference = !class_api.is_singleton && is_reference;
}
Expand Down
13 changes: 4 additions & 9 deletions modules/openssl/stream_peer_openssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,22 @@ bool StreamPeerOpenSSL::_match_host_name(const char *name, const char *hostname)

Error StreamPeerOpenSSL::_match_common_name(const char *hostname, const X509 *server_cert) {

int common_name_loc = -1;
X509_NAME_ENTRY *common_name_entry = NULL;
ASN1_STRING *common_name_asn1 = NULL;
char *common_name_str = NULL;

// Find the position of the CN field in the Subject field of the certificate
common_name_loc = X509_NAME_get_index_by_NID(X509_get_subject_name((X509 *)server_cert), NID_commonName, -1);
int common_name_loc = X509_NAME_get_index_by_NID(X509_get_subject_name((X509 *)server_cert), NID_commonName, -1);

ERR_FAIL_COND_V(common_name_loc < 0, ERR_INVALID_PARAMETER);

// Extract the CN field
common_name_entry = X509_NAME_get_entry(X509_get_subject_name((X509 *)server_cert), common_name_loc);
X509_NAME_ENTRY *common_name_entry = X509_NAME_get_entry(X509_get_subject_name((X509 *)server_cert), common_name_loc);

ERR_FAIL_COND_V(common_name_entry == NULL, ERR_INVALID_PARAMETER);

// Convert the CN field to a C string
common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry);
ASN1_STRING *common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry);

ERR_FAIL_COND_V(common_name_asn1 == NULL, ERR_INVALID_PARAMETER);

common_name_str = (char *)ASN1_STRING_data(common_name_asn1);
char *common_name_str = (char *)ASN1_STRING_data(common_name_asn1);

// Make sure there isn't an embedded NUL character in the CN
bool malformed_certificate = (size_t)ASN1_STRING_length(common_name_asn1) != strlen(common_name_str);
Expand Down
3 changes: 3 additions & 0 deletions modules/pbm/bitmap_loader_pbm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ static bool _get_token(FileAccessRef &f, uint8_t &saved, PoolVector<uint8_t> &r_
resized = true;
}
if (resized) {
// Note: Certain C++ static analyzers might point out that the following assigment is unnecessary.
// This is wrong since PoolVector<class T>::Write has an operator= method where the lhs gets updated under certain conditions.
// See core/dvector.h.
w = PoolVector<uint8_t>::Write();
r_token.resize(token_max);
w = r_token.write();
Expand Down
1 change: 0 additions & 1 deletion modules/theora/video_stream_theora.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
ti.frame_width, ti.frame_height, ti.pic_x, ti.pic_y);
th_decode_ctl(td, TH_DECCTL_GET_PPLEVEL_MAX, &pp_level_max,
sizeof(pp_level_max));
pp_level = pp_level_max;
pp_level = 0;
th_decode_ctl(td, TH_DECCTL_SET_PPLEVEL, &pp_level, sizeof(pp_level));
pp_inc = 0;
Expand Down
1 change: 0 additions & 1 deletion platform/android/audio_driver_jandroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ Error AudioDriverAndroid::init() {
int mix_rate = GLOBAL_DEF("audio/mix_rate", 44100);

int latency = GLOBAL_DEF("audio/output_latency", 25);
latency = 50;
unsigned int buffer_size = next_power_of_2(latency * mix_rate / 1000);
if (OS::get_singleton()->is_stdout_verbose()) {
print_line("audio buffer size: " + itos(buffer_size));
Expand Down
4 changes: 2 additions & 2 deletions platform/android/export/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3024,7 +3024,7 @@ class EditorExportAndroid : public EditorExportPlatform {
args.push_back(devices[p_device].id);
args.push_back("reverse");
args.push_back("--remove-all");
err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);

int dbg_port = EditorSettings::get_singleton()->get("network/debug/remote_port");
args.clear();
Expand All @@ -3034,7 +3034,7 @@ class EditorExportAndroid : public EditorExportPlatform {
args.push_back("tcp:" + itos(dbg_port));
args.push_back("tcp:" + itos(dbg_port));

err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
print_line("Reverse result: " + itos(rv));

int fs_port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
Expand Down
Loading

0 comments on commit 738d2ab

Please sign in to comment.