Skip to content

tool_operate: typecheck-gcc warning #1403

@MarcelRaad

Description

@MarcelRaad

I did this

Compiled with --disable-libcurl-option --enable-werror.

With MinGW / GCC 6.3.0, I got:

In file included from tool_operate.c:70:0:
tool_operate.c: In function 'operate_do':
../include/curl/typecheck-gcc.h:83:9: error: call to '_curl_easy_setopt_err_seek_cb' declared with attribute warning: curl_easy_setopt expects a curl_seek_callback argument for this option [-Werror]
         _curl_easy_setopt_err_seek_cb();                                      \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tool_setopt.h:31:13: note: in definition of macro 'SETOPT_CHECK'
   result = (v); \
             ^
tool_setopt.h:126:16: note: in expansion of macro 'curl_easy_setopt'
   SETOPT_CHECK(curl_easy_setopt(x, y, z))
                ^~~~~~~~~~~~~~~~
tool_operate.c:889:9: note: in expansion of macro 'my_setopt'
         my_setopt(curl, CURLOPT_SEEKFUNCTION, tool_seek_cb);
         ^~~~~~~~~

Passing a function pointer to my_setopt fixes the issue (but all the other my_setopt calls, which compile successfully, don't do that either):
my_setopt(curl, CURLOPT_SEEKFUNCTION, &tool_seek_cb);

I also noticed that _curl_conv_callback* and _curl_seek_callback* are defined as pointers in typecheck-gcc.h, but all other function types aren't. Removing the * from them works around the issue too (and should be done because of _curl_callback_compatible checking for a pointer to the argument in addition to the argument itself), but choosing one of the alternatives returning CURLcode is probably not what is intended when the function declaration exactly matches the return type and parameters of curl_seek_callback, also returning an int.

Probably every __builtin_types_compatible_p(__typeof__(expr), curl_*_callback) in _curl_is_*_cb should also have a __builtin_types_compatible_p(__typeof__(expr) *, curl_*_callback)?

(I'll also prepare a pull request.)

I expected the following

Successful compilation without warnings.

curl/libcurl version

git master f9d1e9a

operating system

Windows / MSYS2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions