Commit 9396dc2d authored by Dominik Charousset's avatar Dominik Charousset

Fix warnings on Clang/Linux

parent 6e4fb0a7
...@@ -66,7 +66,8 @@ behavior pong() { ...@@ -66,7 +66,8 @@ behavior pong() {
// utility function for sending an integer type // utility function for sending an integer type
template <class T> template <class T>
void write_int(broker* self, connection_handle hdl, T value) { void write_int(broker* self, connection_handle hdl, T value) {
auto cpy = static_cast<T>(htonl(value)); using unsigned_type = typename std::make_signed<T>::type;
auto cpy = static_cast<T>(htonl(static_cast<unsigned_type>(value)));
self->write(hdl, sizeof(T), &cpy); self->write(hdl, sizeof(T), &cpy);
self->flush(hdl); self->flush(hdl);
} }
...@@ -80,8 +81,9 @@ void write_int(broker* self, connection_handle hdl, uint64_t value) { ...@@ -80,8 +81,9 @@ void write_int(broker* self, connection_handle hdl, uint64_t value) {
// utility function for reading an ingeger from incoming data // utility function for reading an ingeger from incoming data
template <class T> template <class T>
void read_int(const void* data, T& storage) { void read_int(const void* data, T& storage) {
using unsigned_type = typename std::make_signed<T>::type;
memcpy(&storage, data, sizeof(T)); memcpy(&storage, data, sizeof(T));
storage = static_cast<T>(ntohl(storage)); storage = static_cast<T>(ntohl(static_cast<unsigned_type>(storage)));
} }
void read_int(const void* data, uint64_t& storage) { void read_int(const void* data, uint64_t& storage) {
......
...@@ -122,7 +122,7 @@ std::vector<iface_info> get_mac_addresses() { ...@@ -122,7 +122,7 @@ std::vector<iface_info> get_mac_addresses() {
}; };
// iterate through interfaces // iterate through interfaces
auto ifr = ifc.ifc_req; auto ifr = ifc.ifc_req;
auto num_ifaces = ifc.ifc_len / sizeof(struct ifreq); auto num_ifaces = static_cast<size_t>(ifc.ifc_len) / sizeof(ifreq);
for (size_t i = 0; i < num_ifaces; ++i) { for (size_t i = 0; i < num_ifaces; ++i) {
auto item = &ifr[i]; auto item = &ifr[i];
// get mac address // get mac address
......
...@@ -299,7 +299,7 @@ namespace network { ...@@ -299,7 +299,7 @@ namespace network {
for (; iter != last; ++iter) { for (; iter != last; ++iter) {
auto ptr = reinterpret_cast<event_handler*>(iter->data.ptr); auto ptr = reinterpret_cast<event_handler*>(iter->data.ptr);
auto fd = ptr ? ptr->fd() : m_pipe.first; auto fd = ptr ? ptr->fd() : m_pipe.first;
handle_socket_event(fd, iter->events, ptr); handle_socket_event(fd, static_cast<int>(iter->events), ptr);
} }
for (auto& me : m_events) { for (auto& me : m_events) {
handle(me); handle(me);
...@@ -322,7 +322,7 @@ namespace network { ...@@ -322,7 +322,7 @@ namespace network {
e.ptr->eventbf(e.mask); e.ptr->eventbf(e.mask);
} }
epoll_event ee; epoll_event ee;
ee.events = e.mask; ee.events = static_cast<uint32_t>(e.mask);
ee.data.ptr = e.ptr; ee.data.ptr = e.ptr;
int op; int op;
if (e.mask == 0) { if (e.mask == 0) {
......
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