On (14/03/17 09:34), jhrozek wrote:
URL:
https://github.com/SSSD/sssd/pull/152
Title: #152: Add a tevent wrapper around libcurl's asynchronous interface
jhrozek commented:
"""
I squashed one last trivial change that just checks the return value of the option set:
```
diff --git a/src/util/tev_curl.c b/src/util/tev_curl.c
index b966a78..233ad2c 100644
--- a/src/util/tev_curl.c
+++ b/src/util/tev_curl.c
@@ -832,6 +832,12 @@ static errno_t tcurl_set_options(struct tcurl_http_state *state,
crv = curl_easy_setopt(state->http_handle,
CURLOPT_INFILESIZE_LARGE,
sss_iobuf_get_size(state->inbuf));
gcc on my
machine complains that last argument has wrong type
```
In function ‘tcurl_set_options’,
inlined from ‘tcurl_http_send’ at src/util/tev_curl.c:625:9:
src/util/tev_curl.c:835:15: error: call to ‘_curl_easy_setopt_err_curl_off_t’ declared
with attribute warning: curl_easy_setopt expects a curl_off_t argument for this option
[-Werror]
crv = curl_easy_setopt(state->http_handle,
^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
```
I am not sure whether you have `/usr/include/curl/typecheck-gcc.h` on your
machine. I have curl-7.53.1-3.fc26.
+ if (crv != CURLE_OK) {
+ DEBUG(SSSDBG_OP_FAILURE,
+ "Failed to set CURLOPT_INFILESIZE_LARGE [%d]: %s\n",
+ crv, curl_easy_strerror(crv));
+ return EIO;
+ }
But there are few more warnings
In function ‘handle_curlmsg_done’,
inlined from ‘process_curl_activity.isra.0’ at src/util/tev_curl.c:252:13:
src/util/tev_curl.c:208:11: error: call to ‘_curl_easy_getinfo_err_string’ declared with
attribute warning: curl_easy_getinfo expects a pointer to 'char *' for this info
[-Werror]
crv = curl_easy_getinfo(easy_handle, CURLINFO_PRIVATE, &req);
^~~~~~~~~~~~~~~~~
src/util/tev_curl.c:234:11: error: call to ‘_curl_easy_getinfo_err_long’ declared with
attribute warning: curl_easy_getinfo expects a pointer to long for this info [-Werror]
crv = curl_easy_getinfo(easy_handle, CURLINFO_RESPONSE_CODE,
&state->http_code);
^~~~~~~~~~~~~~~~~
and here is a diff which suppress warnings for me. Not sure whether it is
the best solution.
```
diff --git a/src/util/tev_curl.c b/src/util/tev_curl.c
index 233ad2c49..ea9987e68 100644
--- a/src/util/tev_curl.c
+++ b/src/util/tev_curl.c
@@ -94,7 +94,7 @@ struct tcurl_http_state {
/* Output data */
struct sss_iobuf *outbuf;
- int http_code;
+ long http_code;
};
static errno_t curl_code2errno(CURLcode crv)
@@ -205,7 +205,7 @@ static void handle_curlmsg_done(CURLMsg *message)
}
}
- crv = curl_easy_getinfo(easy_handle, CURLINFO_PRIVATE, &req);
+ crv = curl_easy_getinfo(easy_handle, CURLINFO_PRIVATE, (void *)&req);
if (crv != CURLE_OK) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Cannot get CURLINFO_PRIVATE [%d]: %s\n",
@@ -831,7 +831,7 @@ static errno_t tcurl_set_options(struct tcurl_http_state *state,
/* Causes libcurl to add a sane Content-Length header */
crv = curl_easy_setopt(state->http_handle,
CURLOPT_INFILESIZE_LARGE,
- sss_iobuf_get_size(state->inbuf));
+ (curl_off_t)sss_iobuf_get_size(state->inbuf));
if (crv != CURLE_OK) {
DEBUG(SSSDBG_OP_FAILURE,
"Failed to set CURLOPT_INFILESIZE_LARGE [%d]: %s\n",
```