block/curl.c: Use explicit long constants in curl_easy_setopt calls
PATCH 1/1 block/curl.c: Use explicit long constants in curl_easy_setopt calls
curl_easy_setopt takes a variable argument that depends on what CURLOPT you are setting. Some require a long constant. Passing a plain int constant is potentially wrong on some platforms.
With warnings enabled, multiple warnings like this were printed:
../block/curl.c: In function ‘curl_init_state’:../block/curl.c:474:13: warning: call to ‘_curl_easy_setopt_err_long’ declared with attribute warning: curl_easy_setopt expects a long argument [-Wattribute-warning]
474 | curl_easy_setopt(state->curl, CURLOPT_AUTOREFERER, 1) ||
| ^--- block/curl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
block/curl.c +5 -5
@@ -471,11 +471,11 @@ static int curl_init_state(BDRVCURLState *s, CURLState *state) (void *)curl_read_cb) ||curl_easy_setopt (state->curl,CURLOPT_WRITEDATA , (void *)state) ||curl_easy_setopt (state->curl,CURLOPT_PRIVATE , (void *)state) || -curl_easy_setopt (state->curl,CURLOPT_AUTOREFERER ,1 ) || -curl_easy_setopt (state->curl,CURLOPT_FOLLOWLOCATION ,1 ) || -curl_easy_setopt (state->curl,CURLOPT_NOSIGNAL ,1 ) || +curl_easy_setopt (state->curl,CURLOPT_AUTOREFERER ,1L ) || +curl_easy_setopt (state->curl,CURLOPT_FOLLOWLOCATION ,1L ) || +curl_easy_setopt (state->curl,CURLOPT_NOSIGNAL ,1L ) ||curl_easy_setopt (state->curl,CURLOPT_ERRORBUFFER , state->errmsg) || - curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1)) { + curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1L)) { goto err; }if (s->username) {
@@ -800,7 +800,7 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, } s->accept_range = false; -if (curl_easy_setopt (state->curl,CURLOPT_NOBODY ,1 ) || +if (curl_easy_setopt (state->curl,CURLOPT_NOBODY ,1L ) ||curl_easy_setopt (state->curl,CURLOPT_HEADERFUNCTION , curl_header_cb) ||curl_easy_setopt (state->curl,CURLOPT_HEADERDATA , s)) { pstrcpy(state->errmsg, CURL_ERROR_SIZE,
Signature · 1 line
2.50.1
Quoted 3 lines · Richard W.M. Jones
curl_easy_setopttakes a variable argument that depends on what CURLOPT you are setting. Some require a long constant. Passing a plain int constant is potentially wrong on some platforms.
In practice for QEMU I think this is all harmless, since we only target GCC + CLang on a selection of modern platforms, so integer promotion should work fine for int -> long. None the less, we need to squash the warnings and don't want to turn off -Wattribute-warning entirely, so this makes sense.
Quoted 5 lines
With warnings enabled, multiple warnings like this were printed:
../block/curl.c: In function ‘curl_init_state’:../block/curl.c:474:13: warning: call to ‘_curl_easy_setopt_err_long’ declared with attribute warning:curl_easy_setoptexpects a long argument [-Wattribute-warning]
Quoted 7 lines
474 | curl_easy_setopt(state->curl, CURLOPT_AUTOREFERER, 1) || | ^Signed-off-by Richard W.M. Jones <[email protected]>--- block/curl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|