8000 libmicrohttpd API change in 0.9.71 · Issue #3511 · collectd/collectd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

libmicrohttpd API change in 0.9.71 #3511

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

Closed
pvxe opened this issue Jul 18, 2020 · 3 comments · Fixed by #3512 or #3514
Closed

libmicrohttpd API change in 0.9.71 #3511

pvxe opened this issue Jul 18, 2020 · 3 comments · Fixed by #3512 or #3514

Comments

@pvxe
Copy link
Contributor
pvxe commented Jul 18, 2020

Hi! It's seems that a breaking change in libmicrohttpd's API is making collectd unable to compile with -Werror


  • Version of collectd: HEAD of main branch
  • Operating system / distribution: Arch Linux (or any other with libmicrohttpd 0.9.71)
  • Kernel version (if applicable): not applicable

Expected behavior

Successful compilation of collectd

Actual behavior

collectd cannot compile with -Werror and fails with

src/capabilities.c: In function ‘cap_start_daemon’:
src/capabilities.c:317:38: error: passing argument 5 of ‘MHD_start_daemon’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  317 |       flags, httpd_port, NULL, NULL, cap_http_handler, NULL,
      |                                      ^~~~~~~~~~~~~~~~
      |                                      |
      |                                      int (*)(void *, struct MHD_Connection *, const char *, const char *, const char *, const char *, size_t *, void **) {aka int (*)(void *, struct MHD_Connection *, const char *, const char *, const char *, const char *, long unsigned int *, void **)}

In file included from src/capabilities.c:35:
/usr/include/microhttpd.h:2428:45: note: expected ‘MHD_AccessHandlerCallback’ {aka ‘enum MHD_Result (*)(void *, struct MHD_Connection *, const char *, const char *, const char *, const char *, long unsigned int *, void **)’} but argument is of type ‘int (*)(void *, struct MHD_Connection *, const char *, const char *, const char *, const char *, size_t *, void **)’ {aka ‘int (*)(void *, struct MHD_Connection *, const char *, const char *, const char *, const char *, long unsigned int *, void **)’}
 2428 |                   MHD_AccessHandlerCallback dh, void *dh_cls,
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~

This is because an API breaking change in libmicrohttpd in version 0.9.71. The return value of callbacks is now enum in contrast to int for libmicrohttpd versions <0.9.71

See

Introduce enum MHD_Result for #MHD_YES/#MHD_NO to avoid using 'int' so much.
Note that this change WILL cause compiler warnings until (most) MHD callbacks
in application code change their return type from 'int' to 'enum MHD_Result'.
That said, avoiding possible confusions of different enums is going to make
the code more robust in the future. For conditional compilation, test
for "MHD_VERSION >= 0x00097002". -CG

Steps to reproduce

  • Clone collectd in a system with libmicrohttpd 0.9.71
  • build.sh && ./configure
  • make

Solution

Conditionalize the return type for callback functions inside capabilities.c and update capabilities_test.c

I'll be opening a PR soon fixing this. I would appreciate any feedback whatsoever. :)

pvxe added a commit to pvxe/collectd that referenced this issue Jul 18, 2020
libmicrohttpd introduced an API change with respect its callback
return types. Now its signature says that an enum must be returned
instead of an int. This causes collectd to not finish compilation
because of the compiler warnings this arised (in addition to -Werror)

Add conditional compiling so systems with microhttpd >=0.9.71 can
compile collectd with -Werror

Fixes collectd#3511
@bzed
Copy link
Contributor
bzed commented Jul 24, 2020

@pvxe @mrunge write_prometheus.c needs to be fixed, too!

@mrunge
Copy link
Member
mrunge commented Jul 24, 2020

@bzed good catch, yes!

@PolynomialDivision
Copy link

I have the same issue again?

src/capabilities.c: In function ‘cap_start_daemon’:
src/capabilities.c:317:38: error: passing argument 5 of ‘MHD_start_daemon’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  317 |       flags, httpd_port, NULL, NULL, cap_http_handler, NULL,
      |                                      ^~~~~~~~~~~~~~~~
      |                                      |
      |                                      int (*)(void *, struct MHD_Connection *, const char *, const char *, const char *, const char *, size_t *, void **) {aka int (*)(void *, struct MHD_Connection *, const char *, const char *, const char *, const char *, long unsigned int *, void **)}
In file included from src/capabilities.c:35:
/usr/include/microhttpd.h:2428:45: note: expected ‘MHD_AccessHandlerCallback’ {aka ‘enum MHD_Result (*)(void *, struct MHD_Connection *, const char *, const char *, const char *, const char *, long unsigned int *, void **)’} but argument is of type ‘int (*)(void *, struct MHD_Connection *, const char *, const char *, const char *, const char *, size_t *, void **)’ {aka ‘int (*)(void *, struct MHD_Connection *, const char *, const char *, const char *, const char *, long unsigned int *, void **)’}
 2428 |                   MHD_AccessHandlerCallback dh, void *dh_cls,
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7695: src/capabilities_la-capabilities.lo] Error 1
make[1]: Leaving directory '/home/nick/Desktop/collectd'
make: *** [Makefile:5387: all] Error 2

frankbielig pushed a commit to frankbielig/collectd that referenced this issue Dec 9, 2020
libmicrohttpd introduced an API change with respect its callback
return types. Now its signature says that an enum must be returned
instead of an int. This causes collectd to not finish compilation
because of the compiler warnings this arised (in addition to -Werror)

Add conditional compiling so systems with microhttpd >=0.9.71 can
compile collectd with -Werror

Fixes collectd#3511
frankbielig pushed a commit to frankbielig/collectd that referenced this issue Dec 9, 2020
carlospeon pushed a commit to carlospeon/collectd that referenced this issue Oct 17, 2022
libmicrohttpd introduced an API change with respect its callback
return types. Now its signature says that an enum must be returned
instead of an int. This causes collectd to not finish compilation
because of the compiler warnings this arised (in addition to -Werror)

Add conditional compiling so systems with microhttpd >=0.9.71 can
compile collectd with -Werror

Fixes collectd#3511
carlospeon pushed a commit to carlospeon/collectd that referenced this issue Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants
0