Fix integer warnings in 64-bit Windows build

This commit is contained in:
Vinnie Falco
2016-08-26 07:54:20 -04:00
parent 2c4bdf933e
commit e75fb7a4d4
3 changed files with 14 additions and 11 deletions

View File

@@ -15,6 +15,7 @@
#include <beast/core/placeholders.hpp> #include <beast/core/placeholders.hpp>
#include <beast/core/streambuf.hpp> #include <beast/core/streambuf.hpp>
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <cstddef>
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <memory> #include <memory>
@@ -44,7 +45,7 @@ class http_async_server
public: public:
http_async_server(endpoint_type const& ep, http_async_server(endpoint_type const& ep,
int threads, std::string const& root) std::size_t threads, std::string const& root)
: acceptor_(ios_) : acceptor_(ios_)
, sock_(ios_) , sock_(ios_)
, root_(root) , root_(root)
@@ -57,7 +58,7 @@ public:
std::bind(&http_async_server::on_accept, this, std::bind(&http_async_server::on_accept, this,
beast::asio::placeholders::error)); beast::asio::placeholders::error));
thread_.reserve(threads); thread_.reserve(threads);
for(int i = 0; i < threads; ++i) for(std::size_t i = 0; i < threads; ++i)
thread_.emplace_back( thread_.emplace_back(
[&] { ios_.run(); }); [&] { ios_.run(); });
} }

View File

@@ -124,7 +124,7 @@ template <class = void>
std::string std::string
base64_decode(std::string const& data) base64_decode(std::string const& data)
{ {
int in_len = data.size(); auto in_len = data.size();
unsigned char c3[3], c4[4]; unsigned char c3[3], c4[4];
int i = 0; int i = 0;
int j = 0; int j = 0;

View File

@@ -113,7 +113,7 @@ mask_inplace_general(
{ {
using boost::asio::buffer_cast; using boost::asio::buffer_cast;
using boost::asio::buffer_size; using boost::asio::buffer_size;
auto n = buffer_size(b); auto const n = buffer_size(b);
auto p = buffer_cast<std::uint8_t*>(b); auto p = buffer_cast<std::uint8_t*>(b);
for(auto i = n / sizeof(key); i; --i) for(auto i = n / sizeof(key); i; --i)
{ {
@@ -122,13 +122,14 @@ mask_inplace_general(
*p ^= (key >>16); ++p; *p ^= (key >>16); ++p;
*p ^= (key >>24); ++p; *p ^= (key >>24); ++p;
} }
n %= sizeof(key); auto const m =
switch(n) static_cast<std::uint8_t>(n % sizeof(key));
switch(m)
{ {
case 3: p[2] ^= (key >>16); case 3: p[2] ^= (key >>16);
case 2: p[1] ^= (key >> 8); case 2: p[1] ^= (key >> 8);
case 1: p[0] ^= key; case 1: p[0] ^= key;
key = ror(key, n*8); key = ror(key, m*8);
default: default:
break; break;
} }
@@ -144,7 +145,7 @@ mask_inplace_general(
{ {
using boost::asio::buffer_cast; using boost::asio::buffer_cast;
using boost::asio::buffer_size; using boost::asio::buffer_size;
auto n = buffer_size(b); auto const n = buffer_size(b);
auto p = buffer_cast<std::uint8_t*>(b); auto p = buffer_cast<std::uint8_t*>(b);
for(auto i = n / sizeof(key); i; --i) for(auto i = n / sizeof(key); i; --i)
{ {
@@ -157,8 +158,9 @@ mask_inplace_general(
*p ^= (key >>48); ++p; *p ^= (key >>48); ++p;
*p ^= (key >>56); ++p; *p ^= (key >>56); ++p;
} }
n %= sizeof(key); auto const m =
switch(n) static_cast<std::uint8_t>(n % sizeof(key));
switch(m)
{ {
case 7: p[6] ^= (key >>16); case 7: p[6] ^= (key >>16);
case 6: p[5] ^= (key >> 8); case 6: p[5] ^= (key >> 8);
@@ -167,7 +169,7 @@ mask_inplace_general(
case 3: p[2] ^= (key >>16); case 3: p[2] ^= (key >>16);
case 2: p[1] ^= (key >> 8); case 2: p[1] ^= (key >> 8);
case 1: p[0] ^= key; case 1: p[0] ^= key;
key = ror(key, n*8); key = ror(key, m*8);
default: default:
break; break;
} }