Commit 19713b96 authored by Dominik Charousset's avatar Dominik Charousset

Fix "too small to hold all values of enum" warning

parent e35d7273
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
bool shutting_down : 1; bool shutting_down : 1;
/// Stores what receive policy is currently active. /// Stores what receive policy is currently active.
receive_policy_flag rd_flag : 2; unsigned rd_flag : 2;
}; };
event_handler(default_multiplexer& dm, native_socket sockfd); event_handler(default_multiplexer& dm, native_socket sockfd);
......
...@@ -33,6 +33,10 @@ enum class receive_policy_flag : unsigned { ...@@ -33,6 +33,10 @@ enum class receive_policy_flag : unsigned {
exactly exactly
}; };
constexpr unsigned to_integer(receive_policy_flag x) {
return static_cast<unsigned>(x);
}
inline std::string to_string(receive_policy_flag x) { inline std::string to_string(receive_policy_flag x) {
return x == receive_policy_flag::at_least return x == receive_policy_flag::at_least
? "at_least" ? "at_least"
...@@ -45,17 +49,17 @@ public: ...@@ -45,17 +49,17 @@ public:
using config = std::pair<receive_policy_flag, size_t>; using config = std::pair<receive_policy_flag, size_t>;
static inline config at_least(size_t num_bytes) { static config at_least(size_t num_bytes) {
CAF_ASSERT(num_bytes > 0); CAF_ASSERT(num_bytes > 0);
return {receive_policy_flag::at_least, num_bytes}; return {receive_policy_flag::at_least, num_bytes};
} }
static inline config at_most(size_t num_bytes) { static config at_most(size_t num_bytes) {
CAF_ASSERT(num_bytes > 0); CAF_ASSERT(num_bytes > 0);
return {receive_policy_flag::at_most, num_bytes}; return {receive_policy_flag::at_most, num_bytes};
} }
static inline config exactly(size_t num_bytes) { static config exactly(size_t num_bytes) {
CAF_ASSERT(num_bytes > 0); CAF_ASSERT(num_bytes > 0);
return {receive_policy_flag::exactly, num_bytes}; return {receive_policy_flag::exactly, num_bytes};
} }
......
...@@ -34,7 +34,8 @@ namespace network { ...@@ -34,7 +34,8 @@ 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, receive_policy_flag::at_least}, state_{true, false, false, false,
to_integer(receive_policy_flag::at_least)},
eventbf_(0), eventbf_(0),
backend_(dm) { backend_(dm) {
set_fd_flags(); set_fd_flags();
......
...@@ -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 = config.first; state_.rd_flag = to_integer(config.first);
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