ソースを参照

Fixed compiler warnings

Evgeny Grin (Karlson2k) 5 年 前
コミット
f0d4dde902
2 ファイル変更7 行追加2 行削除
  1. 4 1
      src/microhttpd/connection.c
  2. 3 1
      src/microhttpd/daemon.c

+ 4 - 1
src/microhttpd/connection.c

@@ -2958,6 +2958,8 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
     {
       const size_t wb_ready = connection->write_buffer_append_offset
                               - connection->write_buffer_send_offset;
+      mhd_assert (connection->write_buffer_append_offset > \
+                  connection->write_buffer_send_offset);
 
       /* if the response body is not available, we use MHD_send_on_connection_() */
       if (NULL != connection->response->crc)
@@ -2987,7 +2989,8 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
                                   "Connection was closed while sending response headers.\n"));
         return;
       }
-      if (ret > wb_ready)
+      /* 'ret' is not negative, it's safe to cast it to 'size_t'. */
+      if (((size_t) ret) > wb_ready)
       {
         mhd_assert (NULL == connection->response->crc);
         /* We sent not just header data but also some response data,

+ 3 - 1
src/microhttpd/daemon.c

@@ -5163,8 +5163,9 @@ parse_options_va (struct MHD_Daemon *daemon,
 #endif
         daemon->worker_pool_size = 0;
       }
+#if (0 == (UINT_MAX + 0)) || (UINT_MAX >= (SIZE_MAX / (64 * 1024)))
       /* Next comparison could be always false on some platforms and whole branch will
-       * be optimized out on those platforms. On others it will be compiled into real
+       * be optimized out on these platforms. On others it will be compiled into real
        * check. */
       else if (daemon->worker_pool_size >= (SIZE_MAX / sizeof (struct
                                                                MHD_Daemon)))            /* Compiler may warn on some platforms, ignore warning. */
@@ -5176,6 +5177,7 @@ parse_options_va (struct MHD_Daemon *daemon,
 #endif
         return MHD_NO;
       }
+#endif /* (UINT_MAX >= (SIZE_MAX/(64*1024))) */
       else
       {
         if (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD))