Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added explicit casting to avoid warnings #676

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/dpp/stringops.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ template <uint64_t> uint64_t from_string(const std::string &s)
*/
template <uint32_t> uint32_t from_string(const std::string &s)
{
return std::stoul(s, 0, 10);
return (uint32_t) std::stoul(s, 0, 10);
}

/**
Expand Down Expand Up @@ -205,7 +205,7 @@ template <typename T> std::string to_hex(T i)
template <typename T> std::string leading_zeroes(T i, size_t width)
{
std::stringstream stream;
stream << std::setfill('0') << std::setw(width) << std::dec << i;
stream << std::setfill('0') << std::setw((int)width) << std::dec << i;
return stream.str();
}

Expand Down
4 changes: 2 additions & 2 deletions src/dpp/discordvoiceclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,12 @@ int discord_voice_client::udp_send(const char* data, size_t length)
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(this->port);
servaddr.sin_addr.s_addr = inet_addr(this->ip.c_str());
return sendto(this->fd, data, (int)length, 0, (const sockaddr*)&servaddr, (int)sizeof(sockaddr_in));
return (int) sendto(this->fd, data, (int)length, 0, (const sockaddr*)&servaddr, (int)sizeof(sockaddr_in));
}

int discord_voice_client::udp_recv(char* data, size_t max_length)
{
return recv(this->fd, data, (int)max_length, 0);
return (int) recv(this->fd, data, (int)max_length, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need this?
The correct return type for recv is int already according to the standards? same with sendto

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In MacOS the return type is not int it is ssize_t which is indeed a long. Therefore it is a mapping from long to int which is causing the warning. Its not critical from my point of view but the build would be cleaner.

ssize_t recv(int, void *, size_t, int) __DARWIN_ALIAS_C(recv);

}

bool discord_voice_client::handle_frame(const std::string &data)
Expand Down
4 changes: 2 additions & 2 deletions src/dpp/sslclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ void ssl_client::read_loop()
if (plaintext) {
read_blocked_on_write = false;
read_blocked = false;
r = ::recv(sfd, server_to_client_buffer, DPP_BUFSIZE, 0);
r = (int) ::recv(sfd, server_to_client_buffer, DPP_BUFSIZE, 0);
if (r <= 0) {
/* error or EOF */
return;
Expand Down Expand Up @@ -551,7 +551,7 @@ void ssl_client::read_loop()
/* Try to write */

if (plaintext) {
r = ::send(sfd, client_to_server_buffer + client_to_server_offset, (int)client_to_server_length, 0);
r = (int) ::send(sfd, client_to_server_buffer + client_to_server_offset, (int)client_to_server_length, 0);

if (r < 0) {
/* Write error */
Expand Down