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

examples: fix/silence -Wsign-conversion #13501

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/examples/address-scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main(void)
long my_scope_id;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");

my_scope_id = if_nametoindex("eth0");
my_scope_id = (long)if_nametoindex("eth0");
curl_easy_setopt(curl, CURLOPT_ADDRESS_SCOPE, my_scope_id);

/* Perform the request, res gets the return code */
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/ftp-wildcard.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ int main(int argc, char **argv)
struct callback_data data = { 0 };

/* global initialization */
int rc = curl_global_init(CURL_GLOBAL_ALL);
CURLcode rc = curl_global_init(CURL_GLOBAL_ALL);
if(rc)
return rc;
return (int)rc;

/* initialization of easy handle */
handle = curl_easy_init();
Expand Down Expand Up @@ -90,7 +90,7 @@ int main(int argc, char **argv)

curl_easy_cleanup(handle);
curl_global_cleanup();
return rc;
return (int)rc;
}

static long file_is_coming(struct curl_fileinfo *finfo,
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
* warning: conversion to 'long unsigned int' from 'curl_socket_t' {aka 'int'}
* may change the sign of the result [-Wsign-conversion]
*/
#if defined(__GNUC__) && defined(__CYGWIN__)
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
Expand All @@ -60,7 +60,7 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
else {
FD_SET(sockfd, &outfd);
}
#if defined(__GNUC__) && defined(__CYGWIN__)
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

Expand Down
7 changes: 2 additions & 5 deletions docs/examples/websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,13 @@ static int recv_pong(CURL *curl, const char *expected_payload)
return (int)result;
}

static int recv_any(CURL *curl)
static CURLcode recv_any(CURL *curl)
{
size_t rlen;
const struct curl_ws_frame *meta;
char buffer[256];
CURLcode result = curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta);
if(result)
return result;

return 0;
return curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta);
}

/* close the connection */
Expand Down