Commit 8df860e8 authored by Dominik Charousset's avatar Dominik Charousset

Fix conversion warnings

parent 54c7c6e2
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#pragma once #pragma once
#include <algorithm>
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
...@@ -81,44 +82,44 @@ public: ...@@ -81,44 +82,44 @@ public:
// -- bitwise member operators ----------------------------------------------- // -- bitwise member operators -----------------------------------------------
/// Bitwise ANDs `*this` and `other`. /// Bitwise ANDs `*this` and `other`.
Derived& operator&=(const Derived& other) { Derived& operator&=(const Derived& other) noexcept {
auto& buf = dref().bytes(); auto& buf = dref().bytes();
for (size_t index = 0; index < Derived::num_bytes; ++index) for (size_t index = 0; index < Derived::num_bytes; ++index)
buf[index] &= other[index]; buf[index] = static_cast<uint8_t>(buf[index] & other[index]);
return dref(); return dref();
} }
/// Bitwise ORs `*this` and `other`. /// Bitwise ORs `*this` and `other`.
Derived& operator|=(const Derived& other) { Derived& operator|=(const Derived& other) noexcept {
auto& buf = dref().bytes(); auto& buf = dref().bytes();
for (size_t index = 0; index < Derived::num_bytes; ++index) for (size_t index = 0; index < Derived::num_bytes; ++index)
buf[index] |= other[index]; buf[index] = static_cast<uint8_t>(buf[index] | other[index]);
return dref(); return dref();
} }
/// Bitwise XORs `*this` and `other`. /// Bitwise XORs `*this` and `other`.
Derived& operator^=(const Derived& other) { Derived& operator^=(const Derived& other) noexcept {
auto& buf = dref().bytes(); auto& buf = dref().bytes();
for (size_t index = 0; index < Derived::num_bytes; ++index) for (size_t index = 0; index < Derived::num_bytes; ++index)
buf[index] ^= other[index]; buf[index] = static_cast<uint8_t>(buf[index] ^ other[index]);
return dref(); return dref();
} }
// -- bitwise free operators ------------------------------------------------- // -- bitwise free operators -------------------------------------------------
friend Derived operator&(const Derived& x, const Derived& y) { friend Derived operator&(const Derived& x, const Derived& y) noexcept {
Derived result{x}; Derived result{x};
result &= y; result &= y;
return result; return result;
} }
friend Derived operator|(const Derived& x, const Derived& y) { friend Derived operator|(const Derived& x, const Derived& y) noexcept {
Derived result{x}; Derived result{x};
result |= y; result |= y;
return result; return result;
} }
friend Derived operator^(const Derived& x, const Derived& y) { friend Derived operator^(const Derived& x, const Derived& y) noexcept {
Derived result{x}; Derived result{x};
result ^= y; result ^= y;
return result; return result;
......
...@@ -238,7 +238,7 @@ public: ...@@ -238,7 +238,7 @@ public:
size_t cpt = 0; size_t cpt = 0;
for (auto v: rhs) { for (auto v: rhs) {
for (int k = 0; k < 8; ++k) { for (int k = 0; k < 8; ++k) {
lhs[cpt] = ((v & (1 << k)) != 0); lhs[cpt] = (v & (1 << k)) != 0;
if (++cpt >= len) if (++cpt >= len)
return; return;
} }
...@@ -249,7 +249,7 @@ public: ...@@ -249,7 +249,7 @@ public:
lhs.resize((rhs.size() - 1) / 8 + 1, 0); lhs.resize((rhs.size() - 1) / 8 + 1, 0);
for (bool b: rhs) { for (bool b: rhs) {
if (b) if (b)
lhs[k / 8] |= (1 << (k % 8)); lhs[k / 8] = static_cast<uint8_t>(lhs[k / 8] | (1 << (k % 8)));
++k; ++k;
} }
} }
......
...@@ -36,12 +36,12 @@ bool add_ascii(T& x, char c, enable_if_tt<std::is_integral<T>, int> u = 0) { ...@@ -36,12 +36,12 @@ bool add_ascii(T& x, char c, enable_if_tt<std::is_integral<T>, int> u = 0) {
CAF_IGNORE_UNUSED(u); CAF_IGNORE_UNUSED(u);
if (x > (std::numeric_limits<T>::max() / Base)) if (x > (std::numeric_limits<T>::max() / Base))
return false; return false;
x *= Base; x = static_cast<T>(x * Base);
ascii_to_int<Base, T> f; ascii_to_int<Base, T> f;
auto y = f(c); auto y = f(c);
if (x > (std::numeric_limits<T>::max() - y)) if (x > (std::numeric_limits<T>::max() - y))
return false; return false;
x += y; x = static_cast<T>(x + y);
return true; return true;
} }
...@@ -50,11 +50,10 @@ bool add_ascii(T& x, char c, ...@@ -50,11 +50,10 @@ bool add_ascii(T& x, char c,
enable_if_tt<std::is_floating_point<T>, int> u = 0) { enable_if_tt<std::is_floating_point<T>, int> u = 0) {
CAF_IGNORE_UNUSED(u); CAF_IGNORE_UNUSED(u);
ascii_to_int<Base, T> f; ascii_to_int<Base, T> f;
x = (x * Base) + f(c); x = static_cast<T>((x * Base) + f(c));
return true; return true;
} }
} // namespace parser } // namespace parser
} // namespace detail } // namespace detail
} // namespace caf } // namespace caf
...@@ -36,12 +36,12 @@ bool sub_ascii(T& x, char c, enable_if_tt<std::is_integral<T>, int> u = 0) { ...@@ -36,12 +36,12 @@ bool sub_ascii(T& x, char c, enable_if_tt<std::is_integral<T>, int> u = 0) {
CAF_IGNORE_UNUSED(u); CAF_IGNORE_UNUSED(u);
if (x < (std::numeric_limits<T>::min() / Base)) if (x < (std::numeric_limits<T>::min() / Base))
return false; return false;
x *= Base; x = static_cast<T>(x * Base);
ascii_to_int<Base, T> f; ascii_to_int<Base, T> f;
auto y = f(c); auto y = f(c);
if (x < (std::numeric_limits<T>::min() + y)) if (x < (std::numeric_limits<T>::min() + y))
return false; return false;
x -= y; x = static_cast<T>(x - y);
return true; return true;
} }
...@@ -50,12 +50,10 @@ bool sub_ascii(T& x, char c, ...@@ -50,12 +50,10 @@ bool sub_ascii(T& x, char c,
enable_if_tt<std::is_floating_point<T>, int> u = 0) { enable_if_tt<std::is_floating_point<T>, int> u = 0) {
CAF_IGNORE_UNUSED(u); CAF_IGNORE_UNUSED(u);
ascii_to_int<Base, T> f; ascii_to_int<Base, T> f;
x = (x * Base) - f(c); x = static_cast<T>((x * Base) - f(c));
return true; return true;
} }
} // namespace parser } // namespace parser
} // namespace detail } // namespace detail
} // namespace caf } // namespace caf
...@@ -33,8 +33,8 @@ public: ...@@ -33,8 +33,8 @@ public:
// -- constants -------------------------------------------------------------- // -- constants --------------------------------------------------------------
/// Stores the offset of an embedded IPv4 subnet in bits. /// Stores the offset of an embedded IPv4 subnet in bits.
static constexpr uint8_t v4_offset = static constexpr size_t v4_offset =
static_cast<uint8_t>(ipv6_address::num_bytes - ipv4_address::num_bytes) * 8; (ipv6_address::num_bytes - ipv4_address::num_bytes) * 8;
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
......
...@@ -29,13 +29,14 @@ ...@@ -29,13 +29,14 @@
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
#include <cmath>
#include <mutex>
#include <chrono> #include <chrono>
#include <vector> #include <cmath>
#include <cstdint>
#include <fstream> #include <fstream>
#include <iomanip> #include <iomanip>
#include <mutex>
#include <unordered_map> #include <unordered_map>
#include <vector>
#include "caf/actor_system_config.hpp" #include "caf/actor_system_config.hpp"
#include "caf/defaults.hpp" #include "caf/defaults.hpp"
...@@ -262,7 +263,7 @@ public: ...@@ -262,7 +263,7 @@ public:
} }
template <class Time, class Label> template <class Time, class Label>
void record(Time t, Label label, size_t rec_id, const measurement& m) { void record(Time t, Label label, uint64_t rec_id, const measurement& m) {
using std::setw; using std::setw;
file_ << setw(21) << t.time_since_epoch().count() file_ << setw(21) << t.time_since_epoch().count()
<< setw(10) << label << setw(10) << label
......
...@@ -114,10 +114,10 @@ protected: ...@@ -114,10 +114,10 @@ protected:
uint8_t buf[16]; uint8_t buf[16];
auto i = buf; auto i = buf;
while (x > 0x7f) { while (x > 0x7f) {
*i++ = (static_cast<uint8_t>(x) & 0x7f) | 0x80; *i++ = static_cast<uint8_t>((x & 0x7f) | 0x80);
x >>= 7; x >>= 7;
} }
*i++ = static_cast<uint8_t>(x) & 0x7f; *i++ = static_cast<uint8_t>(x & 0x7f);
auto res = streambuf_.sputn(reinterpret_cast<char_type*>(buf), auto res = streambuf_.sputn(reinterpret_cast<char_type*>(buf),
static_cast<std::streamsize>(i - buf)); static_cast<std::streamsize>(i - buf));
if (res != (i - buf)) if (res != (i - buf))
......
...@@ -79,7 +79,7 @@ protected: ...@@ -79,7 +79,7 @@ protected:
pos_type default_seekoff(off_type off, std::ios_base::seekdir dir, pos_type default_seekoff(off_type off, std::ios_base::seekdir dir,
std::ios_base::openmode which) { std::ios_base::openmode which) {
auto new_off = pos_type(off_type(-1)); auto new_off = off_type{-1};
auto get = (which & std::ios_base::in) == std::ios_base::in; auto get = (which & std::ios_base::in) == std::ios_base::in;
auto put = (which & std::ios_base::out) == std::ios_base::out; auto put = (which & std::ios_base::out) == std::ios_base::out;
if (!(get || put)) if (!(get || put))
...@@ -220,7 +220,7 @@ protected: ...@@ -220,7 +220,7 @@ protected:
auto available = this->epptr() - this->pptr(); auto available = this->epptr() - this->pptr();
auto actual = std::min(n, static_cast<std::streamsize>(available)); auto actual = std::min(n, static_cast<std::streamsize>(available));
std::memcpy(this->pptr(), s, std::memcpy(this->pptr(), s,
static_cast<size_t>(actual * sizeof(char_type))); static_cast<size_t>(actual) * sizeof(char_type));
this->safe_pbump(actual); this->safe_pbump(actual);
return actual; return actual;
} }
...@@ -231,7 +231,7 @@ protected: ...@@ -231,7 +231,7 @@ protected:
auto available = this->egptr() - this->gptr(); auto available = this->egptr() - this->gptr();
auto actual = std::min(n, static_cast<std::streamsize>(available)); auto actual = std::min(n, static_cast<std::streamsize>(available));
std::memcpy(s, this->gptr(), std::memcpy(s, this->gptr(),
static_cast<size_t>(actual * sizeof(char_type))); static_cast<size_t>(actual) * sizeof(char_type));
this->safe_gbump(actual); this->safe_gbump(actual);
return actual; return actual;
} }
...@@ -349,7 +349,7 @@ protected: ...@@ -349,7 +349,7 @@ protected:
auto available = this->egptr() - this->gptr(); auto available = this->egptr() - this->gptr();
auto actual = std::min(n, static_cast<std::streamsize>(available)); auto actual = std::min(n, static_cast<std::streamsize>(available));
std::memcpy(s, this->gptr(), std::memcpy(s, this->gptr(),
static_cast<size_t>(actual * sizeof(char_type))); static_cast<size_t>(actual) * sizeof(char_type));
this->safe_gbump(actual); this->safe_gbump(actual);
return actual; return actual;
} }
......
...@@ -179,8 +179,9 @@ public: ...@@ -179,8 +179,9 @@ public:
using other_signatures = detail::type_list<Ts...>; using other_signatures = detail::type_list<Ts...>;
using m = interface_mismatch_t<other_signatures, signatures>; using m = interface_mismatch_t<other_signatures, signatures>;
// trigger static assert on mismatch // trigger static assert on mismatch
detail::static_error_printer<sizeof...(Ts), m::value, detail::static_error_printer<static_cast<int>(sizeof...(Ts)), m::value,
typename m::xs, typename m::ys> guard; typename m::xs, typename m::ys>
guard;
CAF_IGNORE_UNUSED(guard); CAF_IGNORE_UNUSED(guard);
} }
...@@ -200,7 +201,7 @@ public: ...@@ -200,7 +201,7 @@ public:
// -- modifiers -------------------------------------------------------------- // -- modifiers --------------------------------------------------------------
/// Exchanges the contents of this and other. /// Exchanges the contents of this and other.
inline void swap(typed_behavior& other) { void swap(typed_behavior& other) {
bhvr_.swap(other.bhvr_); bhvr_.swap(other.bhvr_);
} }
...@@ -242,8 +243,9 @@ private: ...@@ -242,8 +243,9 @@ private:
using found_signatures = detail::type_list<deduce_mpi_t<Ts>...>; using found_signatures = detail::type_list<deduce_mpi_t<Ts>...>;
using m = interface_mismatch_t<found_signatures, signatures>; using m = interface_mismatch_t<found_signatures, signatures>;
// trigger static assert on mismatch // trigger static assert on mismatch
detail::static_error_printer<sizeof...(Ts), m::value, detail::static_error_printer<static_cast<int>(sizeof...(Ts)), m::value,
typename m::xs, typename m::ys> guard; typename m::xs, typename m::ys>
guard;
CAF_IGNORE_UNUSED(guard); CAF_IGNORE_UNUSED(guard);
// final (type-erasure) step // final (type-erasure) step
intrusive_ptr<detail::behavior_impl> ptr = std::move(bp); intrusive_ptr<detail::behavior_impl> ptr = std::move(bp);
...@@ -260,4 +262,3 @@ template <class... Sigs> ...@@ -260,4 +262,3 @@ template <class... Sigs>
struct is_typed_behavior<typed_behavior<Sigs...>> : std::true_type { }; struct is_typed_behavior<typed_behavior<Sigs...>> : std::true_type { };
} // namespace caf } // namespace caf
...@@ -29,14 +29,14 @@ ipv6_subnet::ipv6_subnet() : prefix_length_(0) { ...@@ -29,14 +29,14 @@ ipv6_subnet::ipv6_subnet() : prefix_length_(0) {
} }
ipv6_subnet::ipv6_subnet(ipv4_subnet subnet) ipv6_subnet::ipv6_subnet(ipv4_subnet subnet)
: address_(ipv6_address{subnet.network_address()}), : address_(ipv6_address{subnet.network_address()}) {
prefix_length_(v4_offset + subnet.prefix_length()){ prefix_length_ = static_cast<uint8_t>(v4_offset + subnet.prefix_length());
detail::mask_bits(address_.bytes(), prefix_length_); detail::mask_bits(address_.bytes(), prefix_length_);
} }
ipv6_subnet::ipv6_subnet(ipv4_address network_address, uint8_t prefix_length) ipv6_subnet::ipv6_subnet(ipv4_address network_address, uint8_t prefix_length)
: address_(network_address), : address_(network_address) {
prefix_length_(prefix_length + v4_offset) { prefix_length_ = static_cast<uint8_t>(prefix_length + v4_offset);
detail::mask_bits(address_.bytes(), prefix_length_); detail::mask_bits(address_.bytes(), prefix_length_);
} }
......
...@@ -386,9 +386,9 @@ void logger::init(actor_system_config& cfg) { ...@@ -386,9 +386,9 @@ void logger::init(actor_system_config& cfg) {
file_verbosity = get_or(cfg, "logger.file-verbosity", file_verbosity); file_verbosity = get_or(cfg, "logger.file-verbosity", file_verbosity);
console_verbosity = console_verbosity =
get_or(cfg, "logger.console-verbosity", console_verbosity); get_or(cfg, "logger.console-verbosity", console_verbosity);
cfg_.file_verbosity = to_level_int(file_verbosity); cfg_.file_verbosity = to_level_int(file_verbosity) & 0xFu;
cfg_.console_verbosity = to_level_int(console_verbosity); cfg_.console_verbosity = to_level_int(console_verbosity) & 0xFu;
cfg_.verbosity = std::max(cfg_.file_verbosity, cfg_.console_verbosity); cfg_.verbosity = std::max(cfg_.file_verbosity, cfg_.console_verbosity) & 0xFu;
// Parse the format string. // Parse the format string.
file_format_ = file_format_ =
parse_format(get_or(cfg, "logger.file-format", lg::file_format)); parse_format(get_or(cfg, "logger.file-format", lg::file_format));
......
...@@ -975,8 +975,8 @@ uint64_t scheduled_actor::set_timeout(atom_value type, ...@@ -975,8 +975,8 @@ uint64_t scheduled_actor::set_timeout(atom_value type,
stream_slot scheduled_actor::next_slot() { stream_slot scheduled_actor::next_slot() {
stream_slot result = 1; stream_slot result = 1;
auto nslot = [](const stream_manager_map& x) -> stream_slot { auto nslot = [](const stream_manager_map& x) {
return x.rbegin()->first + 1; return static_cast<stream_slot>(x.rbegin()->first + 1);
}; };
if (!stream_managers_.empty()) if (!stream_managers_.empty())
result = std::max(nslot(stream_managers_), result); result = std::max(nslot(stream_managers_), result);
......
...@@ -83,7 +83,7 @@ CAF_TEST(depth3) { ...@@ -83,7 +83,7 @@ CAF_TEST(depth3) {
CAF_TEST(depth2_type_mismatch) { CAF_TEST(depth2_type_mismatch) {
auto stage1 = sys.spawn(multiplier, 4); auto stage1 = sys.spawn(multiplier, 4);
auto stage2 = sys.spawn(float_adder, 10); auto stage2 = sys.spawn(float_adder, 10.f);
auto testee = stage2 * stage1; auto testee = stage2 * stage1;
self->send(testee, 1); self->send(testee, 1);
expect((int), from(self).to(stage1).with(1)); expect((int), from(self).to(stage1).with(1));
......
...@@ -556,7 +556,7 @@ bool basp_broker_state::deliver_pending(execution_unit* ctx, ...@@ -556,7 +556,7 @@ bool basp_broker_state::deliver_pending(execution_unit* ctx,
ep.hdr, payload, false, ep, none)) ep.hdr, payload, false, ep, none))
return false; return false;
i = ep.pending.erase(i); i = ep.pending.erase(i);
ep.seq_incoming += 1; ++ep.seq_incoming;
} }
// Set a timeout if there are still pending messages. // Set a timeout if there are still pending messages.
if (!ep.pending.empty() && !ep.did_set_timeout) if (!ep.pending.empty() && !ep.did_set_timeout)
......
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
#include "caf/io/network/default_multiplexer.hpp" #include "caf/io/network/default_multiplexer.hpp"
#ifdef CAF_WINDOWS #ifdef CAF_WINDOWS
# include <winsock2.h> #include <winsock2.h>
#else #else
# include <sys/socket.h> #include <sys/socket.h>
#endif #endif
namespace caf { namespace caf {
...@@ -33,11 +33,11 @@ namespace io { ...@@ -33,11 +33,11 @@ namespace io {
namespace network { namespace network {
event_handler::event_handler(default_multiplexer& dm, native_socket sockfd) event_handler::event_handler(default_multiplexer& dm, native_socket sockfd)
: fd_(sockfd), : fd_(sockfd),
state_{true, false, false, false, state_{true, false, false, false,
to_integer(receive_policy_flag::at_least)}, to_integer(receive_policy_flag::at_least) & 0x2u},
eventbf_(0), eventbf_(0),
backend_(dm) { backend_(dm) {
set_fd_flags(); set_fd_flags();
} }
......
...@@ -174,7 +174,7 @@ bool instance::handle(execution_unit* ctx, new_datagram_msg& dm, ...@@ -174,7 +174,7 @@ bool instance::handle(execution_unit* ctx, new_datagram_msg& dm,
return true; return true;
} }
// This is the expected message. // This is the expected message.
ep.seq_incoming += 1; ++ep.seq_incoming;
// TODO: add optional reliability here // TODO: add optional reliability here
if (!is_handshake(ep.hdr) && !is_heartbeat(ep.hdr) if (!is_handshake(ep.hdr) && !is_heartbeat(ep.hdr)
&& ep.hdr.dest_node != this_node_) { && ep.hdr.dest_node != this_node_) {
......
...@@ -55,7 +55,7 @@ void stream::activate(stream_manager* mgr) { ...@@ -55,7 +55,7 @@ void stream::activate(stream_manager* mgr) {
} }
void stream::configure_read(receive_policy::config config) { void stream::configure_read(receive_policy::config config) {
state_.rd_flag = to_integer(config.first); state_.rd_flag = to_integer(config.first) & 0x2;
max_ = config.second; max_ = config.second;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment