From 6f05fec335e810884097912afc28a79f248e2a47 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Mon, 30 Jan 2017 23:24:04 -0500 Subject: [PATCH] clang-tidy performance-unnecessary-copy-initialization --- .clang-tidy | 2 +- src/modules/unit_test/unit_test.h | 4 ++-- src/systemcmds/tests/test_mathlib.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index c4408fc30e..bfd412bc75 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -165,7 +165,7 @@ Checks: 'clang-diagnostic-*,clang-analyzer-*,-*, performance-implicit-cast-in-loop, ## TODO: fix code and enable # performance-inefficient-string-concatenation, ## TODO: fix code and enable # performance-type-promotion-in-math-fn, - ## TODO: fix code and enable # performance-unnecessary-copy-initialization, + performance-unnecessary-copy-initialization, performance-unnecessary-value-param, ## TODO: fix code and enable # readability-avoid-const-params-in-decls, readability-braces-around-statements, diff --git a/src/modules/unit_test/unit_test.h b/src/modules/unit_test/unit_test.h index 748ef18383..561597ea14 100644 --- a/src/modules/unit_test/unit_test.h +++ b/src/modules/unit_test/unit_test.h @@ -110,7 +110,7 @@ protected: /// @brief To assert specifically to true. #define ut_assert_true(test) \ do { \ - if (test != true) { \ + if ((test) != true) { \ _print_assert("result not true", #test, __FILE__, __LINE__); \ return false; \ } else { \ @@ -121,7 +121,7 @@ protected: /// @brief To assert specifically to true. #define ut_assert_false(test) \ do { \ - if (test != false) { \ + if ((test) != false) { \ _print_assert("result not false", #test, __FILE__, __LINE__); \ return false; \ } else { \ diff --git a/src/systemcmds/tests/test_mathlib.cpp b/src/systemcmds/tests/test_mathlib.cpp index 5523e5252b..422369c743 100644 --- a/src/systemcmds/tests/test_mathlib.cpp +++ b/src/systemcmds/tests/test_mathlib.cpp @@ -87,7 +87,7 @@ bool MathlibTest::testVector2() Vector<2> v2(1.0f, -1.0f); float data[2] = {1.0f, 2.0f}; TEST_OP("Constructor Vector<2>()", Vector<2> v3); - TEST_OP("Constructor Vector<2>(Vector<2>)", Vector<2> v3(v1)); + TEST_OP("Constructor Vector<2>(Vector<2>)", Vector<2> v3(v1); ut_assert_true(v3 == v1); v3.zero()); TEST_OP("Constructor Vector<2>(float[])", Vector<2> v3(data)); TEST_OP("Constructor Vector<2>(float, float)", Vector<2> v3(1.0f, 2.0f)); TEST_OP("Vector<2> = Vector<2>", v = v1); @@ -110,7 +110,7 @@ bool MathlibTest::testVector3() Vector<3> v2(1.0f, -1.0f, 2.0f); float data[3] = {1.0f, 2.0f, 3.0f}; TEST_OP("Constructor Vector<3>()", Vector<3> v3); - TEST_OP("Constructor Vector<3>(Vector<3>)", Vector<3> v3(v1)); + TEST_OP("Constructor Vector<3>(Vector<3>)", Vector<3> v3(v1); ut_assert_true(v3 == v1); v3.zero()); TEST_OP("Constructor Vector<3>(float[])", Vector<3> v3(data)); TEST_OP("Constructor Vector<3>(float, float, float)", Vector<3> v3(1.0f, 2.0f, 3.0f)); TEST_OP("Vector<3> = Vector<3>", v = v1); @@ -147,7 +147,7 @@ bool MathlibTest::testVector4() Vector<4> v2(1.0f, -1.0f, 2.0f, 0.0f); float data[4] = {1.0f, 2.0f, 3.0f, 4.0f}; TEST_OP("Constructor Vector<4>()", Vector<4> v3); - TEST_OP("Constructor Vector<4>(Vector<4>)", Vector<4> v3(v1)); + TEST_OP("Constructor Vector<4>(Vector<4>)", Vector<4> v3(v1); ut_assert_true(v3 == v1); v3.zero()); TEST_OP("Constructor Vector<4>(float[])", Vector<4> v3(data)); TEST_OP("Constructor Vector<4>(float, float, float, float)", Vector<4> v3(1.0f, 2.0f, 3.0f, 4.0f)); TEST_OP("Vector<4> = Vector<4>", v = v1); @@ -167,7 +167,7 @@ bool MathlibTest::testVector10() v1.zero(); float data[10]; TEST_OP("Constructor Vector<10>()", Vector<10> v3); - TEST_OP("Constructor Vector<10>(Vector<10>)", Vector<10> v3(v1)); + TEST_OP("Constructor Vector<10>(Vector<10>)", Vector<10> v3(v1); ut_assert_true(v3 == v1); v3.zero()); TEST_OP("Constructor Vector<10>(float[])", Vector<10> v3(data)); } return true;