Skip to content

Commit

Permalink
fix all the warnings!
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitalita committed Dec 11, 2023
1 parent 5b09c4d commit 3420d70
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 49 deletions.
1 change: 0 additions & 1 deletion bytecode/bytecode_1ca61a3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bytecode/bytecode_7124599.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ GDScriptDecomp::BYTECODE_TEST_RESULT GDScriptDecomp_7124599::test_bytecode(Vecto
Vector<StringName> identifiers;
Vector<Variant> constants;
Vector<uint32_t> 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++) {
Expand Down
3 changes: 2 additions & 1 deletion bytecode/bytecode_85585c7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@ GDScriptDecomp::BYTECODE_TEST_RESULT GDScriptDecomp_85585c7::test_bytecode(Vecto
Vector<StringName> identifiers;
Vector<Variant> constants;
Vector<uint32_t> 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++) {
Expand Down
5 changes: 2 additions & 3 deletions bytecode/bytecode_ed80f45.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "bytecode_ed80f45.h"

static constexpr char *func_names[] = {
static const char *func_names[] = {

"sin",
"cos",
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions compat/input_event_parser_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 4 additions & 8 deletions compat/resource_loader_compat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -923,12 +925,10 @@ Error ResourceLoaderCompat::load() {
return error;
}

int stage = 0;
Vector<String> 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.
Expand Down Expand Up @@ -1045,8 +1045,6 @@ Error ResourceLoaderCompat::load() {
resource = res;
}

stage++;

if (progress) {
*progress = (i + 1) / float(internal_resources.size());
}
Expand Down Expand Up @@ -2727,7 +2725,6 @@ Error ResourceLoaderCompat::open_text(Ref<FileAccess> p_f, bool p_skip_first_tag
f = p_f;

stream.f = f;
bool ignore_resource_parsing = false;
resource_current = 0;

VariantParser::Tag tag;
Expand Down Expand Up @@ -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<int, int> ext_id_remap;
while (next_tag.name == "ext_resource") {
if (!next_tag.fields.has("path")) {
Expand Down Expand Up @@ -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) {
Expand Down
15 changes: 11 additions & 4 deletions compat/sample_loader_compat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Ref<AudioStreamWAV> SampleLoaderCompat::convert_adpcm_to_16bit(const Ref<AudioSt
new_sample->set_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();
Expand Down Expand Up @@ -154,7 +154,7 @@ Ref<AudioStreamWAV> 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<ResourceProperty> lrp = loader->internal_index_cached_properties[loader->res_path];
for (List<ResourceProperty>::Element *PE = lrp.front(); PE; PE = PE->next()) {
ResourceProperty pe = PE->get();
Expand All @@ -178,6 +178,9 @@ Ref<AudioStreamWAV> 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") {
Expand All @@ -188,10 +191,14 @@ Ref<AudioStreamWAV> 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<AudioStreamWAV> sample = memnew(AudioStreamWAV);
sample->set_name(name);
Expand Down
2 changes: 1 addition & 1 deletion compat/texture_loader_compat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions editor/gdre_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> lines = p_text.split("\n");
if (lines.size() > 1) {
Expand Down Expand Up @@ -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) {
Expand Down
13 changes: 6 additions & 7 deletions utility/axml_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Error AXMLParser::parse_manifest(Vector<uint8_t> &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<uint8_t> stable_extra;

while (ofs < (uint32_t)p_manifest.size()) {
Expand All @@ -37,13 +37,13 @@ Error AXMLParser::parse_manifest(Vector<uint8_t> &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]);
Expand All @@ -70,7 +70,7 @@ Error AXMLParser::parse_manifest(Vector<uint8_t> &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: {
Expand All @@ -84,7 +84,6 @@ Error AXMLParser::parse_manifest(Vector<uint8_t> &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]);
Expand Down
20 changes: 10 additions & 10 deletions utility/axml_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions utility/file_access_apk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ bool APKArchive::try_open_pack(const String &p_path, bool p_replace_files, uint6
Ref<GodotVer> 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];

Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion utility/gdre_packed_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ uint64_t get_offset_windows(const String &p_path) {
}

bool seek_offset_from_exe(Ref<FileAccess> 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.
Expand Down
1 change: 1 addition & 0 deletions utility/gdre_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t> key) {
Expand Down
1 change: 1 addition & 0 deletions utility/glob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "core/templates/hash_map.h"
#include "modules/regex/regex.h"

#include <functional>
namespace {

// SPECIAL_CHARS
Expand Down
5 changes: 0 additions & 5 deletions utility/import_exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> code_files = get_settings()->get_code_files();
if (code_files.is_empty()) {
return OK;
Expand Down Expand Up @@ -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<String> 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) {
Expand Down
5 changes: 4 additions & 1 deletion utility/import_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Ref<ConfigFile> copy_config_file(Ref<ConfigFile> p_cf) {
String section = E->get();
List<String> *section_keys = memnew(List<String>);
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));
}
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion utility/pcfg_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ Error ProjectConfigLoader::set_setting(String p_var, Variant value) {
Error ProjectConfigLoader::_load_settings_binary(Ref<FileAccess> 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).");
Expand Down
1 change: 0 additions & 1 deletion utility/util_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ static Error save_image_as_jpeg(const String &p_path, const Ref<Image> &p_img) {
}

const Vector<uint8_t> 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);
Expand Down

0 comments on commit 3420d70

Please sign in to comment.