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 29diff --git a/glm/ext/quaternion_common.inl b/glm/ext/quaternion_common.inl 30index 0e4a3bb2..6f99f52d 100644 31--- a/glm/ext/quaternion_common.inl 32+++ b/glm/ext/quaternion_common.inl 33@@ -104,7 +104,7 @@ namespace glm 34 { 35 // Graphics Gems III, page 96 36 T angle = acos(cosTheta); 37- T phi = angle + k * glm::pi<T>(); 38+ T phi = angle + static_cast<T>(k) * glm::pi<T>(); 39 return (sin(angle - a * phi)* x + sin(a * phi) * z) / sin(angle); 40 } 41 } 42diff --git a/glm/gtc/random.inl b/glm/gtc/random.inl 43index 70485098..a4af2a06 100644 44--- a/glm/gtc/random.inl 45+++ b/glm/gtc/random.inl 46@@ -22,7 +22,7 @@ namespace detail 47 GLM_FUNC_QUALIFIER static vec<1, uint8, P> call() 48 { 49 return vec<1, uint8, P>( 50- std::rand() % std::numeric_limits<uint8>::max()); 51+ static_cast<uint8>(std::rand()) % std::numeric_limits<uint8>::max()); 52 } 53 }; 54 55diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp 56index 8bf86ba0..ddaa708b 100644 57--- a/test/gtx/gtx_fast_trigonometry.cpp 58+++ b/test/gtx/gtx_fast_trigonometry.cpp 59@@ -19,15 +19,14 @@ namespace fastCos 60 { 61 const float begin = -glm::pi<float>(); 62 const float end = glm::pi<float>(); 63- float result = 0.f; 64 65 const std::clock_t timestamp1 = std::clock(); 66 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 67- result = glm::fastCos(i); 68+ glm::fastCos(i); 69 70 const std::clock_t timestamp2 = std::clock(); 71 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 72- result = glm::cos(i); 73+ glm::cos(i); 74 75 const std::clock_t timestamp3 = std::clock(); 76 const std::clock_t time_fast = timestamp2 - timestamp1; 77@@ -53,15 +52,14 @@ namespace fastSin 78 { 79 const float begin = -glm::pi<float>(); 80 const float end = glm::pi<float>(); 81- float result = 0.f; 82 83 const std::clock_t timestamp1 = std::clock(); 84 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 85- result = glm::fastSin(i); 86+ glm::fastSin(i); 87 88 const std::clock_t timestamp2 = std::clock(); 89 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 90- result = glm::sin(i); 91+ glm::sin(i); 92 93 const std::clock_t timestamp3 = std::clock(); 94 const std::clock_t time_fast = timestamp2 - timestamp1; 95@@ -79,15 +77,14 @@ namespace fastTan 96 { 97 const float begin = -glm::pi<float>(); 98 const float end = glm::pi<float>(); 99- float result = 0.f; 100 101 const std::clock_t timestamp1 = std::clock(); 102 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 103- result = glm::fastTan(i); 104+ glm::fastTan(i); 105 106 const std::clock_t timestamp2 = std::clock(); 107 for (float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 108- result = glm::tan(i); 109+ glm::tan(i); 110 111 const std::clock_t timestamp3 = std::clock(); 112 const std::clock_t time_fast = timestamp2 - timestamp1; 113@@ -105,15 +102,14 @@ namespace fastAcos 114 { 115 const float begin = -glm::pi<float>(); 116 const float end = glm::pi<float>(); 117- float result = 0.f; 118 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::fastAcos(i); 122+ glm::fastAcos(i); 123 124 const std::clock_t timestamp2 = std::clock(); 125 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 126- result = glm::acos(i); 127+ glm::acos(i); 128 129 const std::clock_t timestamp3 = std::clock(); 130 const std::clock_t time_fast = timestamp2 - timestamp1; 131@@ -132,13 +128,12 @@ namespace fastAsin 132 { 133 const float begin = -glm::pi<float>(); 134 const float end = glm::pi<float>(); 135- float result = 0.f; 136 const std::clock_t timestamp1 = std::clock(); 137 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 138- result = glm::fastAsin(i); 139+ glm::fastAsin(i); 140 const std::clock_t timestamp2 = std::clock(); 141 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 142- result = glm::asin(i); 143+ glm::asin(i); 144 const std::clock_t timestamp3 = std::clock(); 145 const std::clock_t time_fast = timestamp2 - timestamp1; 146 const std::clock_t time_default = timestamp3 - timestamp2; 147@@ -155,13 +150,12 @@ namespace fastAtan 148 { 149 const float begin = -glm::pi<float>(); 150 const float end = glm::pi<float>(); 151- float result = 0.f; 152 const std::clock_t timestamp1 = std::clock(); 153 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 154- result = glm::fastAtan(i); 155+ glm::fastAtan(i); 156 const std::clock_t timestamp2 = std::clock(); 157 for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f) 158- result = glm::atan(i); 159+ glm::atan(i); 160 const std::clock_t timestamp3 = std::clock(); 161 const std::clock_t time_fast = timestamp2 - timestamp1; 162 const std::clock_t time_default = timestamp3 - timestamp2; 163-- 1642.31.1 165 166