From 3420d70603d51bcddf9ad28fde745711584a00ac Mon Sep 17 00:00:00 2001 From: nikitalita <69168929+nikitalita@users.noreply.github.com> Date: Sun, 10 Dec 2023 17:44:27 -0800 Subject: [PATCH] fix all the warnings! --- bytecode/bytecode_1ca61a3.cpp | 1 - bytecode/bytecode_7124599.cpp | 2 +- bytecode/bytecode_85585c7.cpp | 3 ++- bytecode/bytecode_ed80f45.cpp | 5 ++--- compat/input_event_parser_v2.cpp | 5 +++++ compat/resource_loader_compat.cpp | 12 ++++-------- compat/sample_loader_compat.cpp | 15 +++++++++++---- compat/texture_loader_compat.cpp | 2 +- editor/gdre_editor.cpp | 4 ++-- utility/axml_parser.cpp | 13 ++++++------- utility/axml_parser.h | 20 ++++++++++---------- utility/file_access_apk.cpp | 4 ++-- utility/gdre_packed_source.cpp | 1 - utility/gdre_settings.cpp | 1 + utility/glob.cpp | 1 + utility/import_exporter.cpp | 5 ----- utility/import_info.cpp | 5 ++++- utility/pcfg_loader.cpp | 1 - utility/util_functions.h | 1 - 19 files changed, 52 insertions(+), 49 deletions(-) diff --git a/bytecode/bytecode_1ca61a3.cpp b/bytecode/bytecode_1ca61a3.cpp index 5e9aa51d..9e720222 100644 --- a/bytecode/bytecode_1ca61a3.cpp +++ b/bytecode/bytecode_1ca61a3.cpp @@ -755,7 +755,6 @@ GDScriptDecomp::BYTECODE_TEST_RESULT GDScriptDecomp_1ca61a3::test_bytecode(Vecto ERR_FAIL_COND_V_MSG(err != OK, BYTECODE_TEST_RESULT::BYTECODE_TEST_CORRUPT, "Failed to get identifiers, constants, and tokens from bytecode."); // pass case: built-in function shift caused by smoothstep is tested - bool tested_smoothstep_shift = false; int token_count = tokens.size(); for (int i = 0; i < token_count; i++) { if ((tokens[i] & TOKEN_MASK) == TK_BUILT_IN_FUNC) { // ignore all tokens until we find TK_BUILT_IN_FUNC diff --git a/bytecode/bytecode_7124599.cpp b/bytecode/bytecode_7124599.cpp index 9d4604db..4bbd44c7 100644 --- a/bytecode/bytecode_7124599.cpp +++ b/bytecode/bytecode_7124599.cpp @@ -650,7 +650,7 @@ GDScriptDecomp::BYTECODE_TEST_RESULT GDScriptDecomp_7124599::test_bytecode(Vecto Vector identifiers; Vector constants; Vector tokens; - Error err = get_ids_consts_tokens(buffer, bytecode_version, identifiers, constants, tokens); + ERR_FAIL_COND_V_MSG(get_ids_consts_tokens(buffer, bytecode_version, identifiers, constants, tokens) != OK, BYTECODE_TEST_RESULT::BYTECODE_TEST_CORRUPT, "Failed to get identifiers, constants, and tokens from bytecode."); int token_count = tokens.size(); for (int i = 0; i < token_count; i++) { diff --git a/bytecode/bytecode_85585c7.cpp b/bytecode/bytecode_85585c7.cpp index 3983c836..99dc4c7d 100644 --- a/bytecode/bytecode_85585c7.cpp +++ b/bytecode/bytecode_85585c7.cpp @@ -654,7 +654,8 @@ GDScriptDecomp::BYTECODE_TEST_RESULT GDScriptDecomp_85585c7::test_bytecode(Vecto Vector identifiers; Vector constants; Vector tokens; - Error err = get_ids_consts_tokens(buffer, bytecode_version, identifiers, constants, tokens); + ERR_FAIL_COND_V_MSG(get_ids_consts_tokens(buffer, bytecode_version, identifiers, constants, tokens) != OK, BYTECODE_TEST_RESULT::BYTECODE_TEST_CORRUPT, "Failed to get identifiers, constants, and tokens from bytecode."); + bool tested_colorN_shift = false; int token_count = tokens.size(); for (int i = 0; i < token_count; i++) { diff --git a/bytecode/bytecode_ed80f45.cpp b/bytecode/bytecode_ed80f45.cpp index b3d15509..e65b7054 100644 --- a/bytecode/bytecode_ed80f45.cpp +++ b/bytecode/bytecode_ed80f45.cpp @@ -8,7 +8,7 @@ #include "bytecode_ed80f45.h" -static constexpr char *func_names[] = { +static const char *func_names[] = { "sin", "cos", @@ -660,12 +660,11 @@ GDScriptDecomp::BYTECODE_TEST_RESULT GDScriptDecomp_ed80f45::test_bytecode(Vecto Error err = get_ids_consts_tokens(buffer, bytecode_version, identifiers, constants, tokens); ERR_FAIL_COND_V_MSG(err != OK, BYTECODE_TEST_RESULT::BYTECODE_TEST_CORRUPT, "Failed to get identifiers, constants, and tokens from bytecode."); int token_count = tokens.size(); - bool tested_enum_case = false; + for (int i = 0; i < token_count; i++) { // Test for the existence of the TK_PR_ENUM token // the next token after TK_PR_ENUM should be TK_IDENTIFIER OR TK_CURLY_BRACKET_OPEN if ((tokens[i] & TOKEN_MASK) == TK_PR_ENUM) { // ignore all tokens until we find TK_PR_ENUM - tested_enum_case = true; if (i + 1 >= token_count) { // if we're at the end of the token list, then we don't have a valid enum token OR a valud TK_PR_PRELOAD token return BYTECODE_TEST_RESULT::BYTECODE_TEST_FAIL; } diff --git a/compat/input_event_parser_v2.cpp b/compat/input_event_parser_v2.cpp index 70e8da02..5e828d62 100644 --- a/compat/input_event_parser_v2.cpp +++ b/compat/input_event_parser_v2.cpp @@ -311,6 +311,8 @@ V2JoyButton convert_v4_joy_button_to_v2_joy_button(JoyButton jb) { return V2InputEvent::JOY_DPAD_LEFT; case JoyButton::DPAD_RIGHT: return V2InputEvent::JOY_DPAD_RIGHT; + default: + return V2JoyButton(jb); } return V2JoyButton(jb); } @@ -337,6 +339,8 @@ JoyButton convert_v2_joy_button_to_v4_joy_button(V2JoyButton jb) { return JoyButton::DPAD_LEFT; case V2InputEvent::JOY_DPAD_RIGHT: return JoyButton::DPAD_RIGHT; + default: + return JoyButton(jb); } return JoyButton(jb); } @@ -542,6 +546,7 @@ Error InputEventParserV2::decode_input_event(Variant &r_variant, const uint8_t * } } break; } + ie->set_device(ie_device); r_variant = ie; return OK; } diff --git a/compat/resource_loader_compat.cpp b/compat/resource_loader_compat.cpp index c08667d5..6bfada8a 100644 --- a/compat/resource_loader_compat.cpp +++ b/compat/resource_loader_compat.cpp @@ -284,7 +284,9 @@ ResourceFormatLoaderCompat::FormatType ResourceFormatLoaderCompat::recognize(con VariantParser::Tag tag; int lines = 1; String error_test; - Error err = VariantParserCompat::parse_tag(&stream, lines, error_test, tag); + if (VariantParserCompat::parse_tag(&stream, lines, error_test, tag) != OK) { + return ResourceFormatLoaderCompat::FormatType::UNKNOWN; + } if (tag.name == "gd_scene" || tag.name == "gd_resource") { return ResourceFormatLoaderCompat::FormatType::TEXT; } else { @@ -923,12 +925,10 @@ Error ResourceLoaderCompat::load() { return error; } - int stage = 0; Vector lines; for (int i = 0; i < external_resources.size(); i++) { error = load_ext_resource(i); ERR_FAIL_COND_V_MSG(error != OK, error, "Can't load external resource " + external_resources[i].path); - stage++; } // On a fake load, we don't instance the internal resources here. @@ -1045,8 +1045,6 @@ Error ResourceLoaderCompat::load() { resource = res; } - stage++; - if (progress) { *progress = (i + 1) / float(internal_resources.size()); } @@ -2727,7 +2725,6 @@ Error ResourceLoaderCompat::open_text(Ref p_f, bool p_skip_first_tag f = p_f; stream.f = f; - bool ignore_resource_parsing = false; resource_current = 0; VariantParser::Tag tag; @@ -3101,7 +3098,7 @@ Error ResourceLoaderCompat::fake_load_text() { rp.ext_func = _parse_ext_resource_dummys; rp.sub_func = _parse_sub_resource_dummys; rp.userdata = this; - int lexndex = 0; + HashMap ext_id_remap; while (next_tag.name == "ext_resource") { if (!next_tag.fields.has("path")) { @@ -3139,7 +3136,6 @@ Error ResourceLoaderCompat::fake_load_text() { return error; } - lexndex++; error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp); if (error) { diff --git a/compat/sample_loader_compat.cpp b/compat/sample_loader_compat.cpp index a750f261..5b21dc5c 100644 --- a/compat/sample_loader_compat.cpp +++ b/compat/sample_loader_compat.cpp @@ -22,7 +22,7 @@ Ref SampleLoaderCompat::convert_adpcm_to_16bit(const Refset_stereo(p_sample->is_stereo()); IMA_ADPCM_State p_ima_adpcm[2]; - int32_t final, final_r, next, next_r; + int32_t final, final_r; int64_t p_offset = 0; int64_t p_increment = 1; auto data = p_sample->get_data(); @@ -154,7 +154,7 @@ Ref SampleLoaderCompat::load_wav(const String &p_path, Error *r_ AudioStreamWAV::Format format; AudioStreamWAV::LoopMode loop_mode; bool stereo = false; - int loop_begin, loop_end, mix_rate, data_bytes; + int loop_begin, loop_end, mix_rate, data_bytes = 0; List lrp = loader->internal_index_cached_properties[loader->res_path]; for (List::Element *PE = lrp.front(); PE; PE = PE->next()) { ResourceProperty pe = PE->get(); @@ -178,6 +178,9 @@ Ref SampleLoaderCompat::load_wav(const String &p_path, Error *r_ if (dat.has("stereo")) { stereo = dat["stereo"]; } + if (dat.has("length")) { + data_bytes = dat["length"]; + } } else if (pe.name == "loop_format") { loop_mode = (AudioStreamWAV::LoopMode)(int)pe.value; } else if (pe.name == "stereo") { @@ -188,10 +191,14 @@ Ref SampleLoaderCompat::load_wav(const String &p_path, Error *r_ loop_end = pe.value; } else if (pe.name == "mix_rate") { mix_rate = pe.value; - } else if (pe.name == "length") { - data_bytes = pe.value; } } + if (data_bytes == 0) { + data_bytes = data.size(); + } else if (data_bytes != data.size()) { + // TODO: something? + // WARN_PRINT("Data size mismatch: " + itos(data_bytes) + " vs " + itos(data.size())); + } // create a new sample Ref sample = memnew(AudioStreamWAV); sample->set_name(name); diff --git a/compat/texture_loader_compat.cpp b/compat/texture_loader_compat.cpp index bfe17ab0..aff560d8 100644 --- a/compat/texture_loader_compat.cpp +++ b/compat/texture_loader_compat.cpp @@ -436,7 +436,7 @@ Error TextureLoaderCompat::_load_data_ctex2d_v4(const String &p_path, int &tw, i uint32_t df = f->get_32(); //data format //skip reserved - int mipmap_limit = int(f->get_32()); + f->get_32(); // mipmap_limit, unused //reserved f->get_32(); f->get_32(); diff --git a/editor/gdre_editor.cpp b/editor/gdre_editor.cpp index 9cc40a5a..8cda601e 100644 --- a/editor/gdre_editor.cpp +++ b/editor/gdre_editor.cpp @@ -515,7 +515,7 @@ void GodotREEditor::print_log(const String &p_text) { void GodotREEditor::print_warning(const String &p_text, const String &p_title, const String &p_sub_text) { char timestamp[21]; OS::DateTime date = OS::get_singleton()->get_datetime(); - sprintf(timestamp, "-%04d-%02d-%02d-%02d-%02d-%02d", (uint16_t)date.year, date.month, date.day, date.hour, date.minute, date.second); + snprintf(timestamp, sizeof(timestamp), "-%04d-%02d-%02d-%02d-%02d-%02d", (uint16_t)date.year, date.month, date.day, date.hour, date.minute, date.second); Vector lines = p_text.split("\n"); if (lines.size() > 1) { @@ -783,7 +783,7 @@ void GodotREEditor::_pck_select_request(const String &p_path) { if (p_check_md5 && md5_error) { icon = icons["REFileBroken"]; error_string += "MD5 mismatch"; - } else if (file->is_malformed()) { + } else if (is_malformed) { icon = icons["REFileBroken"]; error_string += String(error_string.length() > 0 ? ", " : "") + "Malformed_path"; } else if (!p_check_md5) { diff --git a/utility/axml_parser.cpp b/utility/axml_parser.cpp index 89ba0925..395f7453 100644 --- a/utility/axml_parser.cpp +++ b/utility/axml_parser.cpp @@ -21,10 +21,10 @@ Error AXMLParser::parse_manifest(Vector &p_manifest) { uint32_t string_count = 0; uint32_t string_flags = 0; - uint32_t string_data_offset = 0; + // uint32_t string_data_offset = 0; - uint32_t string_table_begins = 0; - uint32_t string_table_ends = 0; + // uint32_t string_table_begins = 0; + // uint32_t string_table_ends = 0; Vector stable_extra; while (ofs < (uint32_t)p_manifest.size()) { @@ -37,13 +37,13 @@ Error AXMLParser::parse_manifest(Vector &p_manifest) { string_count = decode_uint32(&p_manifest[iofs]); string_flags = decode_uint32(&p_manifest[iofs + 8]); - string_data_offset = decode_uint32(&p_manifest[iofs + 12]); + /*string_data_offset = */ decode_uint32(&p_manifest[iofs + 12]); uint32_t st_offset = iofs + 20; string_table.resize(string_count); uint32_t string_end = 0; - string_table_begins = st_offset; + /*string_table_begins = st_offset;*/ for (uint32_t i = 0; i < string_count; i++) { uint32_t string_at = decode_uint32(&p_manifest[st_offset + i * 4]); @@ -70,7 +70,7 @@ Error AXMLParser::parse_manifest(Vector &p_manifest) { stable_extra.push_back(p_manifest[i]); } - string_table_ends = ofs + size; + // string_table_ends = ofs + size; } break; case CHUNK_XML_START_TAG: { @@ -84,7 +84,6 @@ Error AXMLParser::parse_manifest(Vector &p_manifest) { String previous_value = ""; for (uint32_t i = 0; i < attrcount; i++) { - bool get_version_num = false; uint32_t attr_nspace = decode_uint32(&p_manifest[iofs]); uint32_t attr_name = decode_uint32(&p_manifest[iofs + 4]); uint32_t attr_value = decode_uint32(&p_manifest[iofs + 8]); diff --git a/utility/axml_parser.h b/utility/axml_parser.h index a677a604..f69864da 100644 --- a/utility/axml_parser.h +++ b/utility/axml_parser.h @@ -18,16 +18,16 @@ class AXMLParser { bool screen_support_large; bool screen_support_xlarge; - int xr_mode_index; - int hand_tracking_index; - int hand_tracking_frequency_index; - - bool backup_allowed; - bool classify_as_game; - bool retain_data_on_uninstall; - bool exclude_from_recents; - bool is_resizeable; - bool has_read_write_storage_permission; + // int xr_mode_index; + // int hand_tracking_index; + // int hand_tracking_frequency_index; + + // bool backup_allowed; + // bool classify_as_game; + // bool retain_data_on_uninstall; + // bool exclude_from_recents; + // bool is_resizeable; + // bool has_read_write_storage_permission; String xr_hand_tracking_metadata_name; String xr_hand_tracking_metadata_value; diff --git a/utility/file_access_apk.cpp b/utility/file_access_apk.cpp index b34b3677..73aed0a6 100644 --- a/utility/file_access_apk.cpp +++ b/utility/file_access_apk.cpp @@ -204,7 +204,6 @@ bool APKArchive::try_open_pack(const String &p_path, bool p_replace_files, uint6 Ref godot_ver; godot_ver.instantiate(); String ver_string = "unknown"; - bool need_version_from_bin_resource = false; for (uint64_t i = 0; i < gi.number_entry; i++) { char filename_inzip[256]; @@ -214,7 +213,8 @@ bool APKArchive::try_open_pack(const String &p_path, bool p_replace_files, uint6 File f; f.package = pkg_num; - int pos = unzGetFilePos(zfile, &f.file_pos); + + unzGetFilePos(zfile, &f.file_pos); String original_fname = String::utf8(filename_inzip); String fname; if (is_apk) { diff --git a/utility/gdre_packed_source.cpp b/utility/gdre_packed_source.cpp index fc5bc6e1..62db17da 100644 --- a/utility/gdre_packed_source.cpp +++ b/utility/gdre_packed_source.cpp @@ -139,7 +139,6 @@ uint64_t get_offset_windows(const String &p_path) { } bool seek_offset_from_exe(Ref f, const String &p_path, uint64_t p_offset) { - uint64_t off = 0; bool pck_header_found = false; uint32_t magic = 0; // Loading with offset feature not supported for self contained exe files. diff --git a/utility/gdre_settings.cpp b/utility/gdre_settings.cpp index 2854cccf..93892156 100644 --- a/utility/gdre_settings.cpp +++ b/utility/gdre_settings.cpp @@ -589,6 +589,7 @@ Error GDRESettings::set_encryption_key_string(const String &key_str) { key.write[i] = v; } set_encryption_key(key); + return OK; } Error GDRESettings::set_encryption_key(Vector key) { diff --git a/utility/glob.cpp b/utility/glob.cpp index c6cbc701..a801d43f 100644 --- a/utility/glob.cpp +++ b/utility/glob.cpp @@ -29,6 +29,7 @@ #include "core/templates/hash_map.h" #include "modules/regex/regex.h" +#include namespace { // SPECIAL_CHARS diff --git a/utility/import_exporter.cpp b/utility/import_exporter.cpp index 000755f8..6591cbba 100644 --- a/utility/import_exporter.cpp +++ b/utility/import_exporter.cpp @@ -302,7 +302,6 @@ Error ImportExporter::decompile_scripts(const String &p_out_dir) { GDScriptDecomp *decomp; // we have to remove remaps if they exist bool has_remaps = get_settings()->has_any_remaps(); - bool config_requires_resave = false; Vector code_files = get_settings()->get_code_files(); if (code_files.is_empty()) { return OK; @@ -582,15 +581,11 @@ Error ImportExporter::recreate_plugin_config(const String &output_dir, const Str } return OK; }; - bool is_gdext = false; bool found_our_platform = false; if (get_ver_major() >= 3) { // check if this is a gdextension/gdnative plugin static const Vector gdext_wildcards = { "*.gdextension", "*.gdnlib" }; auto gdexts = gdreutil::get_recursive_dir_list(abs_plugin_path, gdext_wildcards, true); - if (gdexts.size() > 0) { - is_gdext = true; - } for (String gdext : gdexts) { err = copy_gdext_dll_func(gdext); if (!err) { diff --git a/utility/import_info.cpp b/utility/import_info.cpp index 6c55066d..faa1f7a6 100644 --- a/utility/import_info.cpp +++ b/utility/import_info.cpp @@ -110,7 +110,7 @@ Ref copy_config_file(Ref p_cf) { String section = E->get(); List *section_keys = memnew(List); p_cf->get_section_keys(section, section_keys); - for (auto F = section_keys->front(); F; F->next()) { + for (auto F = section_keys->front(); F; F = F->next()) { String key = F->get(); r_cf->set_value(section, key, p_cf->get_value(section, key)); } @@ -499,6 +499,9 @@ Error ImportInfov2::_load(const String &p_path) { _ResourceInfo res_info; preferred_import_path = p_path; err = rlc.get_import_info(p_path, GDRESettings::get_singleton()->get_project_path(), res_info); + if (err) { + ERR_FAIL_V_MSG(err, "Could not load resource info from " + p_path); + } String dest; String source_file; String importer; diff --git a/utility/pcfg_loader.cpp b/utility/pcfg_loader.cpp index 9145cdd1..0bd815cb 100644 --- a/utility/pcfg_loader.cpp +++ b/utility/pcfg_loader.cpp @@ -64,7 +64,6 @@ Error ProjectConfigLoader::set_setting(String p_var, Variant value) { Error ProjectConfigLoader::_load_settings_binary(Ref f, const String &p_path, uint32_t ver_major) { Error err; uint8_t hdr[4]; - int file_length = f->get_length(); int bytes_read = f->get_buffer(hdr, 4); if (hdr[0] != 'E' || hdr[1] != 'C' || hdr[2] != 'F' || hdr[3] != 'G') { ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Corrupted header in binary project.binary (not ECFG)."); diff --git a/utility/util_functions.h b/utility/util_functions.h index 0400c3c3..b50f0b4d 100644 --- a/utility/util_functions.h +++ b/utility/util_functions.h @@ -99,7 +99,6 @@ static Error save_image_as_jpeg(const String &p_path, const Ref &p_img) { } const Vector image_data = source_image->get_data(); - const uint8_t *reader = image_data.ptr(); // we may be passed a buffer with existing content we're expected to append to Error err; _____tmp_file = FileAccess::open(p_path, FileAccess::WRITE, &err);