diff --git a/common/NetworkHandler.cc b/common/NetworkHandler.cc index a361b8d538e091f339d4681f7b9cd13c9efe8913..34aab30d332b32d6b17ad4bc5b55208d44423fe8 100644 --- a/common/NetworkHandler.cc +++ b/common/NetworkHandler.cc @@ -205,12 +205,12 @@ int IPv4Address::accept(int p_sockfd) { clean_up(); socklen_type addrlen = sizeof(m_addr); - int fd = ::accept(p_sockfd, (struct sockaddr *)&m_addr, &addrlen); + int fd = ::accept(p_sockfd, reinterpret_cast<struct sockaddr *>(&m_addr), &addrlen); if (fd >= 0) { strncpy(m_addr_str, inet_ntoa(m_addr.sin_addr), sizeof(m_addr_str)); if (m_addr.sin_addr.s_addr != htonl(INADDR_ANY)) { struct hostent *hptr = - gethostbyaddr((const char *)&m_addr.sin_addr, + gethostbyaddr(reinterpret_cast<const char *>(&m_addr.sin_addr), sizeof(m_addr.sin_addr), m_addr.sin_family); if (hptr != NULL && static_cast<size_t>(hptr->h_length) == sizeof(struct in_addr)) { strncpy(m_host_str, hptr->h_name, sizeof(m_host_str)); @@ -224,12 +224,12 @@ int IPv4Address::getsockname(int p_sockfd) { clean_up(); socklen_type addrlen = sizeof(m_addr); - int s = ::getsockname(p_sockfd, (struct sockaddr *)&m_addr, &addrlen); + int s = ::getsockname(p_sockfd, reinterpret_cast<struct sockaddr *>(&m_addr), &addrlen); if (s >= 0) { strncpy(m_addr_str, inet_ntoa(m_addr.sin_addr), sizeof(m_addr_str)); if (m_addr.sin_addr.s_addr != htonl(INADDR_ANY)) { struct hostent *hptr = - gethostbyaddr((const char *)&m_addr.sin_addr, + gethostbyaddr(reinterpret_cast<const char *>(&m_addr.sin_addr), sizeof(m_addr.sin_addr), m_addr.sin_family); if (hptr != NULL && static_cast<size_t>(hptr->h_length) == sizeof(struct in_addr)) { strncpy(m_host_str, hptr->h_name, sizeof(m_host_str)); @@ -344,13 +344,13 @@ int IPv6Address::accept(int p_sockfd) { clean_up(); socklen_type addrlen = sizeof(m_addr); - int fd = ::accept(p_sockfd, (struct sockaddr *)&m_addr, &addrlen); + int fd = ::accept(p_sockfd, reinterpret_cast<struct sockaddr *>(&m_addr), &addrlen); if (fd >= 0) { if (!inet_ntop(AF_INET6, &m_addr.sin6_addr, m_addr_str, sizeof(m_addr_str))) { fprintf(stderr, "IPv6Address::accept(): Unable to convert IPv6 address " "from binary to text form: %s\n", strerror(errno)); } - int s = getnameinfo((struct sockaddr *)&m_addr, sizeof(m_addr), + int s = getnameinfo(reinterpret_cast<struct sockaddr *>(&m_addr), sizeof(m_addr), m_host_str, sizeof(m_host_str), NULL, 0, 0); if (s != 0) { fprintf(stderr, "IPv6Address::accept(): Address to name translation " @@ -364,13 +364,13 @@ int IPv6Address::getsockname(int p_sockfd) { clean_up(); socklen_type addrlen = sizeof(m_addr); - int s1 = ::getsockname(p_sockfd, (struct sockaddr *)&m_addr, &addrlen); + int s1 = ::getsockname(p_sockfd, reinterpret_cast<struct sockaddr *>(&m_addr), &addrlen); if (s1 >= 0) { if (!inet_ntop(AF_INET6, &m_addr.sin6_addr, m_addr_str, sizeof(m_addr_str))) { fprintf(stderr, "IPv6Address::getsockname(): Unable to convert IPv6 " "address from binary to text form: %s\n", strerror(errno)); } - int s2 = getnameinfo((struct sockaddr *)&m_addr, sizeof(m_addr), + int s2 = getnameinfo(reinterpret_cast<struct sockaddr *>(&m_addr), sizeof(m_addr), m_host_str, sizeof(m_host_str), NULL, 0, 0); if (s2 != 0) { fprintf(stderr, "IPv6Address::getsockname(): Address to name " diff --git a/common/NetworkHandler.hh b/common/NetworkHandler.hh index 8862228b93e0ef775bf92cd45dc6fd9db3e6e165..81b169800998c9c9f418f4af1eaa909283255ac7 100644 --- a/common/NetworkHandler.hh +++ b/common/NetworkHandler.hh @@ -102,7 +102,7 @@ public: inline unsigned short get_port() const { return ntohs(m_addr.sin_port); } inline void set_port(unsigned short p_port) { m_addr.sin_port = htons(p_port); } bool set_addr(const char *p_addr, unsigned short p_port = 0); - inline const struct sockaddr *get_addr() const { return (const struct sockaddr *)&m_addr; } + inline const struct sockaddr *get_addr() const { return reinterpret_cast<const struct sockaddr *>(&m_addr); } inline socklen_type get_addr_len() const { return sizeof(m_addr); } inline const char *get_host_str() const { return strlen(m_host_str) > 0 ? m_host_str : m_addr_str; } inline const char *get_addr_str() const { return strlen(m_addr_str) > 0 ? m_addr_str : m_host_str; } @@ -135,7 +135,7 @@ public: inline unsigned short get_port() const { return ntohs(m_addr.sin6_port); } inline void set_port(unsigned short p_port) { m_addr.sin6_port = htons(p_port); } bool set_addr(const char *p_addr, unsigned short p_port = 0); - inline const struct sockaddr *get_addr() const { return (const struct sockaddr *)&m_addr; } + inline const struct sockaddr *get_addr() const { return reinterpret_cast<const struct sockaddr *>(&m_addr); } inline socklen_type get_addr_len() const { return sizeof(m_addr); } inline const char *get_host_str() const { return strlen(m_host_str) > 0 ? m_host_str : m_addr_str; } const char *get_addr_str() const; diff --git a/core/Textbuf.hh b/core/Textbuf.hh index 664619334d01f39f29f08e31ab605b748fe2d694..4d2197bd21b672af1b88eb33173661482068f10a 100644 --- a/core/Textbuf.hh +++ b/core/Textbuf.hh @@ -46,7 +46,7 @@ public: inline int get_pos() const { return buf_pos - buf_begin; } inline void buf_seek(int new_pos) { buf_pos = buf_begin + new_pos; } inline const char *get_data() const - { return (const char*)data_ptr + buf_begin; } + { return reinterpret_cast<const char*>(data_ptr) + buf_begin; } void push_int(const int_val_t& value); void push_int(const RInt& value);