From 053d7f37650cc03261dabf09b860c530daed4fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 16 Jan 2019 10:59:45 +0100 Subject: Fix some errors found by static analysis Fixes items 10, 16 and 19 from PVS-Studio blog post in #24014. --- main/tests/test_math.cpp | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'main') diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp index c833bac4ab..a082abcaba 100644 --- a/main/tests/test_math.cpp +++ b/main/tests/test_math.cpp @@ -444,14 +444,11 @@ MainLoop *test() { float bb = (rgbe >> 18) & 0x1ff; float eb = (rgbe >> 27); float mb = Math::pow(2, eb - 15.0 - 9.0); - ; float rd = rb * mb; float gd = gb * mb; float bd = bb * mb; print_line("RGBE: " + Color(rd, gd, bd)); - - return NULL; } print_line("Dvectors: " + itos(MemoryPool::allocs_used)); @@ -482,8 +479,6 @@ MainLoop *test() { print_line("later Mem used: " + itos(MemoryPool::total_memory)); print_line("Mlater Ax mem used: " + itos(MemoryPool::max_memory)); - return NULL; - List cmdlargs = OS::get_singleton()->get_cmdline_args(); if (cmdlargs.empty()) { @@ -492,6 +487,11 @@ MainLoop *test() { } String test = cmdlargs.back()->get(); + if (test == "math") { + // Not a file name but the test name, abort. + // FIXME: This test is ugly as heck, needs fixing :) + return NULL; + } FileAccess *fa = FileAccess::open(test, FileAccess::READ); @@ -516,8 +516,6 @@ MainLoop *test() { print_line("Found class: " + getclass.get_class()); } - return NULL; - { Vector hashes; @@ -557,13 +555,10 @@ MainLoop *test() { } print_line("DONE"); - - return NULL; } - { + { print_line("NUM: " + itos(-128)); - return NULL; } { @@ -593,7 +588,6 @@ MainLoop *test() { print_line("after v: " + v + " a: " + rtos(a)); } - return NULL; String ret; List args; @@ -602,7 +596,6 @@ MainLoop *test() { print_line("error: " + itos(err)); print_line(ret); - return NULL; Basis m3; m3.rotate(Vector3(1, 0, 0), 0.2); m3.rotate(Vector3(0, 1, 0), 1.77); @@ -611,17 +604,13 @@ MainLoop *test() { m32.set_euler(m3.get_euler()); print_line("ELEULEEEEEEEEEEEEEEEEEER: " + m3.get_euler() + " vs " + m32.get_euler()); - return NULL; - { - Dictionary d; d["momo"] = 1; Dictionary b = d; b["44"] = 4; } - return NULL; print_line("inters: " + rtos(Geometry::segment_intersects_circle(Vector2(-5, 0), Vector2(-2, 0), Vector2(), 1.0))); print_line("cross: " + Vector3(1, 2, 3).cross(Vector3(4, 5, 7))); -- cgit v1.2.3