Skip to content

Commit

Permalink
Changed some code found by Clang Tidy and Coverity
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Sep 22, 2019
1 parent 2e065d8 commit 50be65b
Show file tree
Hide file tree
Showing 25 changed files with 153 additions and 166 deletions.
2 changes: 1 addition & 1 deletion core/crypto/hashing_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void HashingContext::_create_ctx(HashType p_type) {
}

void HashingContext::_delete_ctx() {
return;

switch (type) {
case HASH_MD5:
memdelete((CryptoCore::MD5Context *)ctx);
Expand Down
2 changes: 1 addition & 1 deletion core/io/file_access_zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ bool ZipArchive::try_open_pack(const String &p_path) {
packages.push_back(pkg);
int pkg_num = packages.size() - 1;

for (unsigned int i = 0; i < gi.number_entry; i++) {
for (uint64_t i = 0; i < gi.number_entry; i++) {

char filename_inzip[256];

Expand Down
2 changes: 1 addition & 1 deletion core/math/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ Vector<Vector<Vector2> > Geometry::decompose_polygon_in_convex(Vector<Point2> po

decomp.write[idx].resize(tp.GetNumPoints());

for (int i = 0; i < tp.GetNumPoints(); i++) {
for (int64_t i = 0; i < tp.GetNumPoints(); i++) {
decomp.write[idx].write[i] = tp.GetPoint(i);
}

Expand Down
4 changes: 2 additions & 2 deletions core/ustring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2147,13 +2147,13 @@ int64_t String::to_int(const CharType *p_str, int p_len) {

if (c >= '0' && c <= '9') {

if (integer > INT32_MAX / 10) {
if (integer > INT64_MAX / 10) {
String number("");
str = p_str;
while (*str && str != limit) {
number += *(str++);
}
ERR_FAIL_V_MSG(sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + number + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
ERR_FAIL_V_MSG(sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + number + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
}
integer *= 10;
integer += c - '0';
Expand Down
2 changes: 1 addition & 1 deletion core/variant_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
return err;
if (tk.type != TK_STRING) {
r_err_str = "Error reading quoted string";
return err;
return ERR_INVALID_DATA;
}

what = tk.value;
Expand Down
4 changes: 2 additions & 2 deletions drivers/alsa/audio_driver_alsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ void AudioDriverALSA::thread_func(void *p_udata) {
ad->start_counting_ticks();

if (!ad->active) {
for (unsigned int i = 0; i < ad->period_size * ad->channels; i++) {
for (uint64_t i = 0; i < ad->period_size * ad->channels; i++) {
ad->samples_out.write[i] = 0;
}

} else {
ad->audio_server_process(ad->period_size, ad->samples_in.ptrw());

for (unsigned int i = 0; i < ad->period_size * ad->channels; i++) {
for (uint64_t i = 0; i < ad->period_size * ad->channels; i++) {
ad->samples_out.write[i] = ad->samples_in[i] >> 16;
}
}
Expand Down
4 changes: 2 additions & 2 deletions editor/editor_audio_buses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ Size2 EditorAudioMeterNotches::get_minimum_size() const {
float width = 0;
float height = top_padding + btm_padding;

for (uint8_t i = 0; i < notches.size(); i++) {
for (int i = 0; i < notches.size(); i++) {
if (notches[i].render_db_value) {
width = MAX(width, font->get_string_size(String::num(Math::abs(notches[i].db_value)) + "dB").x);
height += font_height;
Expand Down Expand Up @@ -1473,7 +1473,7 @@ void EditorAudioMeterNotches::_draw_audio_notches() {
Ref<Font> font = get_font("font", "Label");
float font_height = font->get_height();

for (uint8_t i = 0; i < notches.size(); i++) {
for (int i = 0; i < notches.size(); i++) {
AudioNotch n = notches[i];
draw_line(Vector2(0, (1.0f - n.relative_position) * (get_size().y - btm_padding - top_padding) + top_padding),
Vector2(line_length, (1.0f - n.relative_position) * (get_size().y - btm_padding - top_padding) + top_padding),
Expand Down
9 changes: 0 additions & 9 deletions editor/editor_vcs_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,12 @@ Dictionary EditorVCSInterface::_get_modified_files_data() {
}

void EditorVCSInterface::_stage_file(String p_file_path) {

return;
}

void EditorVCSInterface::_unstage_file(String p_file_path) {

return;
}

void EditorVCSInterface::_commit(String p_msg) {

return;
}

Array EditorVCSInterface::_get_file_diff(String p_file_path) {
Expand Down Expand Up @@ -134,7 +128,6 @@ void EditorVCSInterface::stage_file(String p_file_path) {

call("_stage_file", p_file_path);
}
return;
}

void EditorVCSInterface::unstage_file(String p_file_path) {
Expand All @@ -143,7 +136,6 @@ void EditorVCSInterface::unstage_file(String p_file_path) {

call("_unstage_file", p_file_path);
}
return;
}

bool EditorVCSInterface::is_addon_ready() {
Expand All @@ -157,7 +149,6 @@ void EditorVCSInterface::commit(String p_msg) {

call("_commit", p_msg);
}
return;
}

Array EditorVCSInterface::get_file_diff(String p_file_path) {
Expand Down
2 changes: 1 addition & 1 deletion editor/import/resource_importer_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 15));
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "animation/filter_script", PROPERTY_HINT_MULTILINE_TEXT), ""));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "animation/storage", PROPERTY_HINT_ENUM, "Built-In,Files (.anim),Files (.tres)"), animations_out ? true : false));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "animation/storage", PROPERTY_HINT_ENUM, "Built-In,Files (.anim),Files (.tres)"), animations_out));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/keep_custom_tracks"), animations_out));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/optimizer/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/optimizer/max_linear_error"), 0.05));
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/sprite_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float

int lasti = p2->Contour.size() - 1;
Vector2 prev = Vector2(p2->Contour[lasti].X / PRECISION, p2->Contour[lasti].Y / PRECISION);
for (unsigned int i = 0; i < p2->Contour.size(); i++) {
for (uint64_t i = 0; i < p2->Contour.size(); i++) {

Vector2 cur = Vector2(p2->Contour[i].X / PRECISION, p2->Contour[i].Y / PRECISION);
if (cur.distance_to(prev) > 0.5) {
Expand Down
1 change: 0 additions & 1 deletion modules/assimp/editor_scene_importer_assimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,6 @@ void EditorSceneImporterAssimp::create_bone(ImportState &state, RecursiveState &
// this transform is a bone
recursive_state.skeleton->add_bone(recursive_state.node_name);

ERR_FAIL_COND(recursive_state.skeleton == NULL); // serious bug we must now exit.
//ERR_FAIL_COND(recursive_state.skeleton->get_name() == "");
print_verbose("Bone added to lookup: " + AssimpUtils::get_assimp_string(recursive_state.bone->mName));
print_verbose("Skeleton attached to: " + recursive_state.skeleton->get_name());
Expand Down
Loading

0 comments on commit 50be65b

Please sign in to comment.