]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
PR26195: adapt debuginfod to API change in libmicrohttpd-0.9.71
authorFrank Ch. Eigler <fche@redhat.com>
Thu, 2 Jul 2020 14:52:48 +0000 (14:52 +0000)
committerFrank Ch. Eigler <fche@redhat.com>
Thu, 2 Jul 2020 14:54:12 +0000 (14:54 +0000)
To make our code build with -Werror as well as against older libmicrohttpd,
we must conditionalize the data type (int vs. enum) returned by callbacks
and some mhd functions.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
debuginfod/debuginfod.cxx

index 76f1fa52c510c7c0954fb31df128496d3deae821..5621030292e87740725ba450f9f94d6fe1175bdc 100644 (file)
@@ -92,6 +92,14 @@ using namespace std;
 #include <libdwelf.h>
 
 #include <microhttpd.h>
+
+#if MHD_VERSION >= 0x00097002
+// libmicrohttpd 0.9.71 broke API
+#define MHD_RESULT enum MHD_Result
+#else
+#define MHD_RESULT int
+#endif
+
 #include <curl/curl.h>
 #include <archive.h>
 #include <archive_entry.h>
@@ -519,12 +527,12 @@ struct reportable_exception
 
   void report(ostream& o) const; // defined under obatched() class below
 
-  int mhd_send_response(MHD_Connection* c) const {
+  MHD_RESULT mhd_send_response(MHD_Connection* c) const {
     MHD_Response* r = MHD_create_response_from_buffer (message.size(),
                                                        (void*) message.c_str(),
                                                        MHD_RESPMEM_MUST_COPY);
     MHD_add_response_header (r, "Content-Type", "text/plain");
-    int rc = MHD_queue_response (c, code, r);
+    MHD_RESULT rc = MHD_queue_response (c, code, r);
     MHD_destroy_response (r);
     return rc;
   }
@@ -1723,7 +1731,7 @@ handle_metrics (off_t* size)
 
 
 /* libmicrohttpd callback */
-static int
+static MHD_RESULT
 handler_cb (void * /*cls*/,
             struct MHD_Connection *connection,
             const char *url,
@@ -1736,7 +1744,11 @@ handler_cb (void * /*cls*/,
   struct MHD_Response *r = NULL;
   string url_copy = url;
 
+#if MHD_VERSION >= 0x00097002
+  enum MHD_Result rc;
+#else
   int rc = MHD_NO; // mhd
+#endif
   int http_code = 500;
   off_t http_size = -1;
   struct timeval tv_start, tv_end;