1From bd9b5060bc3b9581090d44f15b4e236566ea86a6 Mon Sep 17 00:00:00 2001 2From: Khem Raj <raj.khem@gmail.com> 3Date: Fri, 4 Jun 2021 12:57:57 -0700 4Subject: [PATCH] Silence clang warnings 5 6Fixes 7glm/gtc/random.inl:25:17: error: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Werror,-Wimplicit-int-conversion] 8| std::rand() % std::numeric_limits<uint8>::max()); 9| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10 11glm/gtc/../ext/quaternion_common.inl:76:87: error: unused parameter 'k' [-Werror,-Wunused-parameter] 12 GLM_FUNC_QUALIFIER qua<T, Q> slerp(qua<T, Q> const& x, qua<T, Q> const& y, T a, S k) 13 ^ 14 15and 16 17test/gtx/gtx_fast_trigonometry.cpp:135:9: error: variable 'result' set but not used [-Werror,-Wunused-but-set-variable] 18| float result = 0.f; 19| ^ 20 21Upstream-Status: Submitted [https://github.com/g-truc/glm/pull/1055] 22Signed-off-by: Khem Raj <raj.khem@gmail.com> 23--- 24 glm/ext/quaternion_common.inl | 2 +- 25 glm/gtc/random.inl | 2 +- 26 test/gtx/gtx_fast_trigonometry.cpp | 30 ++++++++++++------------------ 27 3 files changed, 14 insertions(+), 20 deletions(-) 28 29--- a/glm/ext/quaternion_common.inl 30+++ b/glm/ext/quaternion_common.inl 31@@ -104,7 +104,7 @@ namespace glm 32 { 33 // Graphics Gems III, page 96 34 T angle = acos(cosTheta); 35- T phi = angle + k * glm::pi<T>(); 36+ T phi = angle + static_cast<T>(k) * glm::pi<T>(); 37 return (sin(angle - a * phi)* x + sin(a * phi) * z) / sin(angle); 38 } 39 } 40--- a/test/gtx/gtx_fast_trigonometry.cpp 41+++ b/test/gtx/gtx_fast_trigonometry.cpp 42@@ -19,15 +19,14 @@ namespace fastCos 43 { 44 const float begin = -glm::pi<float>(); 45 const float end = glm::pi<float>(); 46- float result = 0.f; 47 48 const std::clock_t timestamp1 = std::clock(); 49 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 50- result = glm::fastCos(i); 51+ glm::fastCos(i); 52 53 const std::clock_t timestamp2 = std::clock(); 54 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 55- result = glm::cos(i); 56+ glm::cos(i); 57 58 const std::clock_t timestamp3 = std::clock(); 59 const std::clock_t time_fast = timestamp2 - timestamp1; 60@@ -53,15 +52,14 @@ namespace fastSin 61 { 62 const float begin = -glm::pi<float>(); 63 const float end = glm::pi<float>(); 64- float result = 0.f; 65 66 const std::clock_t timestamp1 = std::clock(); 67 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 68- result = glm::fastSin(i); 69+ glm::fastSin(i); 70 71 const std::clock_t timestamp2 = std::clock(); 72 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 73- result = glm::sin(i); 74+ glm::sin(i); 75 76 const std::clock_t timestamp3 = std::clock(); 77 const std::clock_t time_fast = timestamp2 - timestamp1; 78@@ -79,15 +77,14 @@ namespace fastTan 79 { 80 const float begin = -glm::pi<float>(); 81 const float end = glm::pi<float>(); 82- float result = 0.f; 83 84 const std::clock_t timestamp1 = std::clock(); 85 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 86- result = glm::fastTan(i); 87+ glm::fastTan(i); 88 89 const std::clock_t timestamp2 = std::clock(); 90 for (float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 91- result = glm::tan(i); 92+ glm::tan(i); 93 94 const std::clock_t timestamp3 = std::clock(); 95 const std::clock_t time_fast = timestamp2 - timestamp1; 96@@ -105,15 +102,14 @@ namespace fastAcos 97 { 98 const float begin = -glm::pi<float>(); 99 const float end = glm::pi<float>(); 100- float result = 0.f; 101 102 const std::clock_t timestamp1 = std::clock(); 103 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 104- result = glm::fastAcos(i); 105+ glm::fastAcos(i); 106 107 const std::clock_t timestamp2 = std::clock(); 108 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 109- result = glm::acos(i); 110+ glm::acos(i); 111 112 const std::clock_t timestamp3 = std::clock(); 113 const std::clock_t time_fast = timestamp2 - timestamp1; 114@@ -132,13 +128,12 @@ namespace fastAsin 115 { 116 const float begin = -glm::pi<float>(); 117 const float end = glm::pi<float>(); 118- float result = 0.f; 119 const std::clock_t timestamp1 = std::clock(); 120 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 121- result = glm::fastAsin(i); 122+ glm::fastAsin(i); 123 const std::clock_t timestamp2 = std::clock(); 124 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 125- result = glm::asin(i); 126+ glm::asin(i); 127 const std::clock_t timestamp3 = std::clock(); 128 const std::clock_t time_fast = timestamp2 - timestamp1; 129 const std::clock_t time_default = timestamp3 - timestamp2; 130@@ -155,13 +150,12 @@ namespace fastAtan 131 { 132 const float begin = -glm::pi<float>(); 133 const float end = glm::pi<float>(); 134- float result = 0.f; 135 const std::clock_t timestamp1 = std::clock(); 136 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 137- result = glm::fastAtan(i); 138+ glm::fastAtan(i); 139 const std::clock_t timestamp2 = std::clock(); 140 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 141- result = glm::atan(i); 142+ glm::atan(i); 143 const std::clock_t timestamp3 = std::clock(); 144 const std::clock_t time_fast = timestamp2 - timestamp1; 145 const std::clock_t time_default = timestamp3 - timestamp2; 146