gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] 02/03: Use 'mhd_assert()'


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 02/03: Use 'mhd_assert()'
Date: Mon, 12 Jun 2017 23:03:53 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit b10f4140c68bd41ed600abf08b4990d79be598b4
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Mon Jun 12 23:40:51 2017 +0300

    Use 'mhd_assert()'
---
 src/microhttpd/connection.c | 56 ++++++++++++++++++++++-----------------------
 src/microhttpd/daemon.c     | 12 +++++-----
 src/microhttpd/internal.h   | 25 ++++++++------------
 src/microhttpd/response.c   |  4 ++--
 4 files changed, 46 insertions(+), 51 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index e8dd0752..3eb3cc3b 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -234,7 +234,7 @@ sendfile_adapter (struct MHD_Connection *connection)
 #else  /* HAVE_SENDFILE64 */
   off64_t offset;
 #endif /* HAVE_SENDFILE64 */
-  EXTRA_CHECK (MHD_resp_sender_sendfile == connection->resp_sender);
+  mhd_assert (MHD_resp_sender_sendfile == connection->resp_sender);
 
   offsetu64 = connection->response_write_position + 
connection->response->fd_off;
   left = connection->response->total_size - 
connection->response_write_position;
@@ -1065,8 +1065,8 @@ try_ready_chunked_body (struct MHD_Connection *connection)
                         sizeof (cbuf),
                         "%X\r\n",
                         (unsigned int) ret);
-  EXTRA_CHECK(cblen > 0);
-  EXTRA_CHECK(cblen < sizeof(cbuf));
+  mhd_assert(cblen > 0);
+  mhd_assert(cblen < sizeof(cbuf));
   memcpy (&connection->write_buffer[sizeof (cbuf) - cblen],
           cbuf,
           cblen);
@@ -1264,7 +1264,7 @@ build_header_response (struct MHD_Connection *connection)
   int must_add_keep_alive;
   int must_add_content_length;
 
-  EXTRA_CHECK (NULL != connection->version);
+  mhd_assert (NULL != connection->version);
   if (0 == connection->version[0])
     {
       data = MHD_pool_allocate (connection->pool,
@@ -1452,7 +1452,7 @@ build_header_response (struct MHD_Connection *connection)
       response_has_keepalive = false;
       break;
     default:
-      EXTRA_CHECK (0);
+      mhd_assert (0);
     }
 
   if (MHD_CONN_MUST_CLOSE != connection->keepalive)
@@ -1471,8 +1471,8 @@ build_header_response (struct MHD_Connection *connection)
     size += MHD_STATICSTR_LEN_ ("Transfer-Encoding: chunked\r\n");
   if (must_add_content_length)
     size += content_length_len;
-  EXTRA_CHECK (! (must_add_close && must_add_keep_alive) );
-  EXTRA_CHECK (! (must_add_chunked_encoding && must_add_content_length) );
+  mhd_assert (! (must_add_close && must_add_keep_alive) );
+  mhd_assert (! (must_add_chunked_encoding && must_add_content_length) );
 
   for (pos = connection->response->first_header; NULL != pos; pos = pos->next)
     {
@@ -1617,7 +1617,7 @@ transmit_error_response (struct MHD_Connection 
*connection,
   MHD_queue_response (connection,
                       status_code,
                       response);
-  EXTRA_CHECK (NULL != connection->response);
+  mhd_assert (NULL != connection->response);
   MHD_destroy_response (response);
   /* Do not reuse this connection. */
   connection->keepalive = MHD_CONN_MUST_CLOSE;
@@ -1698,10 +1698,10 @@ MHD_connection_update_event_loop_info (struct 
MHD_Connection *connection)
            connection->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK;
           break;
         case MHD_CONNECTION_HEADERS_RECEIVED:
-          EXTRA_CHECK (0);
+          mhd_assert (0);
           break;
         case MHD_CONNECTION_HEADERS_PROCESSED:
-          EXTRA_CHECK (0);
+          mhd_assert (0);
           break;
         case MHD_CONNECTION_CONTINUE_SENDING:
           connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE;
@@ -1758,7 +1758,7 @@ MHD_connection_update_event_loop_info (struct 
MHD_Connection *connection)
          connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE;
           break;
         case MHD_CONNECTION_HEADERS_SENT:
-          EXTRA_CHECK (0);
+          mhd_assert (0);
           break;
         case MHD_CONNECTION_NORMAL_BODY_READY:
          connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE;
@@ -1773,27 +1773,27 @@ MHD_connection_update_event_loop_info (struct 
MHD_Connection *connection)
          connection->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK;
           break;
         case MHD_CONNECTION_BODY_SENT:
-          EXTRA_CHECK (0);
+          mhd_assert (0);
           break;
         case MHD_CONNECTION_FOOTERS_SENDING:
          connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE;
           break;
         case MHD_CONNECTION_FOOTERS_SENT:
-          EXTRA_CHECK (0);
+          mhd_assert (0);
           break;
         case MHD_CONNECTION_CLOSED:
          connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP;
           return;       /* do nothing, not even reading */
         case MHD_CONNECTION_IN_CLEANUP:
-          EXTRA_CHECK (0);
+          mhd_assert (0);
           break;
 #ifdef UPGRADE_SUPPORT
         case MHD_CONNECTION_UPGRADE:
-          EXTRA_CHECK (0);
+          mhd_assert (0);
           break;
 #endif /* UPGRADE_SUPPORT */
         default:
-          EXTRA_CHECK (0);
+          mhd_assert (0);
         }
       break;
     }
@@ -2505,7 +2505,7 @@ process_broken_line (struct MHD_Connection *connection,
       connection->last = last;
       return MHD_YES;           /* possibly more than 2 lines... */
     }
-  EXTRA_CHECK ( (NULL != last) &&
+  mhd_assert ( (NULL != last) &&
                 (NULL != connection->colon) );
   if ((MHD_NO == connection_add_header (connection,
                                         last,
@@ -2565,7 +2565,7 @@ parse_connection_headers (struct MHD_Connection 
*connection)
       MHD_DLOG (connection->daemon,
                 _("Received HTTP 1.1 request without `Host' header.\n"));
 #endif
-      EXTRA_CHECK (NULL == connection->response);
+      mhd_assert (NULL == connection->response);
       response =
         MHD_create_response_from_buffer (MHD_STATICSTR_LEN_ 
(REQUEST_LACKS_HOST),
                                         REQUEST_LACKS_HOST,
@@ -2745,7 +2745,7 @@ MHD_connection_handle_read (struct MHD_Connection 
*connection)
       return;
 #ifdef UPGRADE_SUPPORT
     case MHD_CONNECTION_UPGRADE:
-      EXTRA_CHECK (0);
+      mhd_assert (0);
       return;
 #endif /* UPGRADE_SUPPORT */
     default:
@@ -2797,7 +2797,7 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
     case MHD_CONNECTION_URL_RECEIVED:
     case MHD_CONNECTION_HEADER_PART_RECEIVED:
     case MHD_CONNECTION_HEADERS_RECEIVED:
-      EXTRA_CHECK (0);
+      mhd_assert (0);
       return;
     case MHD_CONNECTION_HEADERS_PROCESSED:
       return;
@@ -2833,7 +2833,7 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
     case MHD_CONNECTION_BODY_RECEIVED:
     case MHD_CONNECTION_FOOTER_PART_RECEIVED:
     case MHD_CONNECTION_FOOTERS_RECEIVED:
-      EXTRA_CHECK (0);
+      mhd_assert (0);
       return;
     case MHD_CONNECTION_HEADERS_SENDING:
       ret = connection->send_cls (connection,
@@ -2924,7 +2924,7 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
         connection->state = MHD_CONNECTION_FOOTERS_SENT; /* have no footers */
       return;
     case MHD_CONNECTION_NORMAL_BODY_UNREADY:
-      EXTRA_CHECK (0);
+      mhd_assert (0);
       return;
     case MHD_CONNECTION_CHUNKED_BODY_READY:
       ret = connection->send_cls (connection,
@@ -2952,7 +2952,7 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
       return;
     case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
     case MHD_CONNECTION_BODY_SENT:
-      EXTRA_CHECK (0);
+      mhd_assert (0);
       return;
     case MHD_CONNECTION_FOOTERS_SENDING:
       ret = connection->send_cls (connection,
@@ -2976,20 +2976,20 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
                         MHD_CONNECTION_FOOTERS_SENT);
       return;
     case MHD_CONNECTION_FOOTERS_SENT:
-      EXTRA_CHECK (0);
+      mhd_assert (0);
       return;
     case MHD_CONNECTION_CLOSED:
       return;
     case MHD_CONNECTION_IN_CLEANUP:
-      EXTRA_CHECK (0);
+      mhd_assert (0);
       return;
 #ifdef UPGRADE_SUPPORT
     case MHD_CONNECTION_UPGRADE:
-      EXTRA_CHECK (0);
+      mhd_assert (0);
       return;
 #endif /* UPGRADE_SUPPORT */
     default:
-      EXTRA_CHECK (0);
+      mhd_assert (0);
       CONNECTION_CLOSE_ERROR (connection,
                               _("Internal error\n"));
       break;
@@ -3544,7 +3544,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
           return MHD_YES; /* keep open */
 #endif /* UPGRADE_SUPPORT */
        default:
-          EXTRA_CHECK (0);
+          mhd_assert (0);
           break;
         }
       break;
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index cb7064a4..f2d4f73b 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2081,7 +2081,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
   int eno = 0;
 
   /* Direct add to master daemon could happen only with "external" add mode. */
-  EXTRA_CHECK ((NULL == daemon->worker_pool) || (external_add));
+  mhd_assert ((NULL == daemon->worker_pool) || (external_add));
   if ((external_add) && (NULL != daemon->worker_pool))
     {
       /* have a pool, try to find a pool with capacity; we use the
@@ -2475,7 +2475,7 @@ internal_suspend_connection_ (struct MHD_Connection 
*connection)
   DLL_remove (daemon->connections_head,
               daemon->connections_tail,
               connection);
-  EXTRA_CHECK (! connection->suspended);
+  mhd_assert (! connection->suspended);
   DLL_insert (daemon->suspended_connections_head,
               daemon->suspended_connections_tail,
               connection);
@@ -2612,7 +2612,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
   if (daemon->resuming)
     prev = daemon->suspended_connections_tail;
 
-  EXTRA_CHECK(NULL != next);
+  mhd_assert(NULL != prev);
   daemon->resuming = false;
 
   while (NULL != (pos = prev))
@@ -2632,7 +2632,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
          )
         continue;
       ret = MHD_YES;
-      EXTRA_CHECK (pos->suspended);
+      mhd_assert (pos->suspended);
       DLL_remove (daemon->suspended_connections_head,
                   daemon->suspended_connections_tail,
                   pos);
@@ -4266,8 +4266,8 @@ close_connection (struct MHD_Connection *pos)
 
   MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
 
-  EXTRA_CHECK (! pos->suspended);
-  EXTRA_CHECK (! pos->resuming);
+  mhd_assert (! pos->suspended);
+  mhd_assert (! pos->resuming);
   if (pos->connection_timeout == pos->daemon->connection_timeout)
     XDLL_remove (daemon->normal_timeout_head,
                 daemon->normal_timeout_tail,
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 7a47651e..85fe2487 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -30,6 +30,8 @@
 #include "mhd_options.h"
 #include "platform.h"
 #include "microhttpd.h"
+#include "mhd_assert.h"
+
 #ifdef HTTPS_SUPPORT
 #include <gnutls/gnutls.h>
 #if GNUTLS_VERSION_MAJOR >= 3
@@ -1697,13 +1699,6 @@ struct MHD_Daemon
 };
 
 
-#if EXTRA_CHECKS
-#define EXTRA_CHECK(a) do { if (!(a)) abort(); } while (0)
-#else
-#define EXTRA_CHECK(a)
-#endif
-
-
 /**
  * Insert an element at the head of a DLL. Assumes that head, tail and
  * element are structs with prev and next fields.
@@ -1713,8 +1708,8 @@ struct MHD_Daemon
  * @param element element to insert
  */
 #define DLL_insert(head,tail,element) do { \
-  EXTRA_CHECK (NULL == (element)->next); \
-  EXTRA_CHECK (NULL == (element)->prev); \
+  mhd_assert (NULL == (element)->next); \
+  mhd_assert (NULL == (element)->prev); \
   (element)->next = (head); \
   (element)->prev = NULL; \
   if ((tail) == NULL) \
@@ -1734,8 +1729,8 @@ struct MHD_Daemon
  * @param element element to remove
  */
 #define DLL_remove(head,tail,element) do { \
-  EXTRA_CHECK ( (NULL != (element)->next) || ((element) == (tail)));  \
-  EXTRA_CHECK ( (NULL != (element)->prev) || ((element) == (head)));  \
+  mhd_assert ( (NULL != (element)->next) || ((element) == (tail)));  \
+  mhd_assert ( (NULL != (element)->prev) || ((element) == (head)));  \
   if ((element)->prev == NULL) \
     (head) = (element)->next;  \
   else \
@@ -1758,8 +1753,8 @@ struct MHD_Daemon
  * @param element element to insert
  */
 #define XDLL_insert(head,tail,element) do { \
-  EXTRA_CHECK (NULL == (element)->nextX); \
-  EXTRA_CHECK (NULL == (element)->prevX); \
+  mhd_assert (NULL == (element)->nextX); \
+  mhd_assert (NULL == (element)->prevX); \
   (element)->nextX = (head); \
   (element)->prevX = NULL; \
   if (NULL == (tail)) \
@@ -1779,8 +1774,8 @@ struct MHD_Daemon
  * @param element element to remove
  */
 #define XDLL_remove(head,tail,element) do { \
-  EXTRA_CHECK ( (NULL != (element)->nextX) || ((element) == (tail)));  \
-  EXTRA_CHECK ( (NULL != (element)->prevX) || ((element) == (head)));  \
+  mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail)));  \
+  mhd_assert ( (NULL != (element)->prevX) || ((element) == (head)));  \
   if (NULL == (element)->prevX) \
     (head) = (element)->nextX;  \
   else \
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 7b2b4eb7..a0ecf3ea 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -714,7 +714,7 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh,
                   SHUT_RDWR);
       }
 #endif /* HTTPS_SUPPORT */
-    EXTRA_CHECK (MHD_CONNECTION_UPGRADE == connection->state);
+    mhd_assert (MHD_CONNECTION_UPGRADE == connection->state);
     urh->was_closed = true;
     /* As soon as connection will be marked with BOTH
      * 'urh->was_closed' AND 'urh->clean_ready', it will
@@ -885,7 +885,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response 
*response,
            to the event set of the daemon's `epoll_upgrade_fd` */
         struct epoll_event event;
 
-        EXTRA_CHECK (-1 != daemon->epoll_upgrade_fd);
+        mhd_assert (-1 != daemon->epoll_upgrade_fd);
         /* First, add network socket */
         event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET;
         event.data.ptr = &urh->app;

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]