build: silence various type conversion warnings

This commit is contained in:
Danny Robson 2018-01-18 11:56:42 +11:00
parent d037e71bba
commit 82a8446e10
6 changed files with 17 additions and 15 deletions

View File

@ -96,7 +96,9 @@ stack::deallocate (void *_ptr, size_t bytes, size_t alignment)
{ {
(void)bytes; (void)bytes;
alignment = util::max (MIN_ALIGNMENT, alignment); // TODO: use alignment
(void)alignment;
//alignment = util::max (MIN_ALIGNMENT, alignment);
auto ptr = reinterpret_cast<char*> (_ptr); auto ptr = reinterpret_cast<char*> (_ptr);

View File

@ -26,8 +26,8 @@ namespace util {
point2f point2f
bezier<1>::eval (float t) const bezier<1>::eval (float t) const
{ {
CHECK_GE (t, 0); CHECK_GE (t, 0.f);
CHECK_LE (t, 1); CHECK_LE (t, 1.f);
auto v0 = (1 - t) * m_points[0]; auto v0 = (1 - t) * m_points[0];
auto v1 = t * m_points[1]; auto v1 = t * m_points[1];
@ -72,7 +72,7 @@ namespace util {
bezier<1>::distance (util::point2f q) const noexcept bezier<1>::distance (util::point2f q) const noexcept
{ {
const auto ab = m_points[1] - m_points[0]; const auto ab = m_points[1] - m_points[0];
const auto t = limit (closest (q), 0, 1); const auto t = limit (closest (q), 0.f, 1.f);
const auto p = m_points[0] + t * ab; const auto p = m_points[0] + t * ab;
return util::distance (q, p); return util::distance (q, p);

View File

@ -26,7 +26,7 @@ namespace util {
point2f point2f
bezier<2>::eval (float t) const bezier<2>::eval (float t) const
{ {
CHECK_LIMIT (t, 0, 1); CHECK_LIMIT (t, 0.f, 1.f);
const auto &P0 = m_coeffs[0]; const auto &P0 = m_coeffs[0];
const auto &P1 = m_coeffs[1]; const auto &P1 = m_coeffs[1];
@ -64,7 +64,7 @@ namespace util {
util::vector2f util::vector2f
bezier<2>::d1 (const float t) const noexcept bezier<2>::d1 (const float t) const noexcept
{ {
CHECK_LIMIT (t, 0, 1); CHECK_LIMIT (t, 0.f, 1.f);
const auto &P0 = m_coeffs[0]; const auto &P0 = m_coeffs[0];
const auto &P1 = m_coeffs[1]; const auto &P1 = m_coeffs[1];

View File

@ -27,8 +27,8 @@ namespace util {
point2f point2f
bezier<3>::eval (float t) const bezier<3>::eval (float t) const
{ {
CHECK_GE (t, 0); CHECK_GE (t, 0.f);
CHECK_LE (t, 1); CHECK_LE (t, 1.f);
auto v0 = pow (1 - t, 3u) * m_points[0]; auto v0 = pow (1 - t, 3u) * m_points[0];
auto v1 = 3 * pow2 (1 - t) * t * m_points[1]; auto v1 = 3 * pow2 (1 - t) * t * m_points[1];
@ -96,11 +96,11 @@ namespace util {
float float
bezier<3>::distance (util::point2f target) const noexcept bezier<3>::distance (util::point2f target) const noexcept
{ {
static constexpr size_t SUBDIV = 32; static constexpr int SUBDIV = 32;
std::array<util::point2f, SUBDIV> lookup; std::array<util::point2f, SUBDIV> lookup;
for (size_t i = 0; i < SUBDIV; ++i) for (int i = 0; i < SUBDIV; ++i)
lookup[i] = eval (i / float (SUBDIV - 1)); lookup[i] = eval (i / (SUBDIV - 1.f));
size_t best = 0; size_t best = 0;
for (size_t i = 1; i < lookup.size (); ++i) { for (size_t i = 1; i < lookup.size (); ++i) {
@ -126,7 +126,7 @@ namespace util {
util::vector2f util::vector2f
bezier<3>::tangent (const float t) const bezier<3>::tangent (const float t) const
{ {
CHECK_LIMIT (t, 0, 1); CHECK_LIMIT (t, 0.f, 1.f);
return mix ( return mix (
mix (m_coeffs[1] - m_coeffs[0], m_coeffs[2] - m_coeffs[1], t), mix (m_coeffs[1] - m_coeffs[0], m_coeffs[2] - m_coeffs[1], t),

View File

@ -201,10 +201,10 @@ namespace util::encode {
throw std::invalid_argument ("base-encoded strings must be a proper multiple of symbols"); throw std::invalid_argument ("base-encoded strings must be a proper multiple of symbols");
auto cursor = std::cbegin (src); auto cursor = std::cbegin (src);
const int groups = std::size (src) / group_symbols; const auto groups = std::size (src) / group_symbols;
const bool padded = std::cend (src)[-1] == '='; const bool padded = std::cend (src)[-1] == '=';
for (int i = 0; i < groups - (padded?1:0); ++i) { for (size_t i = 0; i < groups - (padded?1:0); ++i) {
uint64_t accum = 0; uint64_t accum = 0;
for (int j = 0; j < group_symbols; ++j) { for (int j = 0; j < group_symbols; ++j) {

View File

@ -17,7 +17,7 @@ main (int, char**)
char c_char[] = { 'a', 'b', 'c' }; char c_char[] = { 'a', 'b', 'c' };
bool success = true; bool success = true;
for (auto [i, v, a, c]: util::izip (v_int, a_float, c_char)) { for (const auto &[i, v, a, c]: util::izip (v_int, a_float, c_char)) {
success = success && success = success &&
v_int[i] == v && v_int[i] == v &&
util::exactly_equal (a_float[i], a) && util::exactly_equal (a_float[i], a) &&