Skip to content
Snippets Groups Projects
Commit 2f0c4642 authored by Kristof Szabados's avatar Kristof Szabados
Browse files

some re-interpret casts


Signed-off-by: default avatarkristof <Kristof.Szabados@ericsson.com>
parent 360a8969
No related branches found
No related tags found
No related merge requests found
......@@ -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 "
......
......@@ -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;
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment