Просмотр исходного кода

size_t vs. int fixes by Evgeny Grin, plus some additional fixes by CG

Christian Grothoff 12 лет назад
Родитель
Сommit
5ae9cc7f06
4 измененных файлов с 21 добавлено и 18 удалено
  1. 3 0
      ChangeLog
  2. 7 7
      src/microhttpd/connection.c
  3. 8 8
      src/microhttpd/digestauth.c
  4. 3 3
      src/microhttpd/internal.h

+ 3 - 0
ChangeLog

@@ -1,3 +1,6 @@
+Sat Feb  8 15:08:35 CET 2014
+	Corrected some uses of 'int' vs. 'size_t'. -EG/CG
+
 Wed Jan 22 09:44:33 CET 2014
 	MHD_USE_DUAL_STACK in libmicrohttpd currently just *inhibits
 	setting* the IPV6_V6ONLY socket option, but per Microsoft's

+ 7 - 7
src/microhttpd/connection.c

@@ -396,7 +396,7 @@ try_ready_chunked_body (struct MHD_Connection *connection)
   struct MHD_Response *response;
   size_t size;
   char cbuf[10];                /* 10: max strlen of "%x\r\n" */
-  int cblen;
+  size_t cblen;
 
   response = connection->response;
   if (0 == connection->write_buffer_size)
@@ -1491,7 +1491,7 @@ process_request_body (struct MHD_Connection *connection)
 
               if (available > 0)
                 instant_retry = MHD_YES;
-              if (connection->current_chunk_size == 0)
+              if (0 == connection->current_chunk_size)
                 {
                   connection->remaining_upload_size = 0;
                   break;
@@ -1625,7 +1625,7 @@ do_read (struct MHD_Connection *connection)
 static int
 do_write (struct MHD_Connection *connection)
 {
-  int ret;
+  ssize_t ret;
   size_t max;
 
   max = connection->write_buffer_append_offset - connection->write_buffer_send_offset;
@@ -1643,7 +1643,7 @@ do_write (struct MHD_Connection *connection)
       if (0 != (connection->daemon->options & MHD_USE_SSL))
 	MHD_DLOG (connection->daemon,
 		  "Failed to send data: %s\n",
-		  gnutls_strerror (ret));
+		  gnutls_strerror ((int) ret));
       else
 #endif
 	MHD_DLOG (connection->daemon,
@@ -1994,7 +1994,7 @@ int
 MHD_connection_handle_write (struct MHD_Connection *connection)
 {
   struct MHD_Response *response;
-  int ret;
+  ssize_t ret;
 
   update_last_activity (connection);
   while (1)
@@ -2035,7 +2035,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
 #if DEBUG_SEND_DATA
           FPRINTF (stderr,
                    "Sent 100 continue response: `%.*s'\n",
-                   ret,
+                   (int) ret,
                    &HTTP_100_CONTINUE[connection->continue_message_write_offset]);
 #endif
           connection->continue_message_write_offset += ret;
@@ -2072,7 +2072,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
           if (ret > 0)
             FPRINTF (stderr,
                      "Sent DATA response: `%.*s'\n",
-                     ret,
+                     (int) ret,
                      &response->data[connection->response_write_position -
                                      response->data_start]);
 #endif

+ 8 - 8
src/microhttpd/digestauth.c

@@ -201,7 +201,7 @@ digest_calc_response (const char *ha1,
  * @param key key to look up in data
  * @return size of the located value, 0 if otherwise
  */
-static int
+static size_t
 lookup_sub_value (char *dest,
 		  size_t size,
 		  const char *data,
@@ -381,7 +381,7 @@ MHD_digest_auth_get_username(struct MHD_Connection *connection)
  * @param nonce_time The amount of time in seconds for a nonce to be invalid
  * @param method HTTP method
  * @param rnd A pointer to a character array for the random seed
- * @param rnd_size The size of the random seed array
+ * @param rnd_size The size of the random seed array @a rnd
  * @param uri HTTP URI (in MHD, without the arguments ("?k=v")
  * @param realm A string of characters that describes the realm of auth.
  * @param nonce A pointer to a character array for the nonce to put in
@@ -390,7 +390,7 @@ static void
 calculate_nonce (uint32_t nonce_time,
 		 const char *method,
 		 const char *rnd,
-		 unsigned int rnd_size,
+		 size_t rnd_size,
 		 const char *uri,
 		 const char *realm,
 		 char *nonce)
@@ -407,14 +407,14 @@ calculate_nonce (uint32_t nonce_time,
   timestamp[3] = (nonce_time & 0x000000ff);
   MD5Update (&md5, timestamp, 4);
   MD5Update (&md5, ":", 1);
-  MD5Update (&md5, method, strlen(method));
+  MD5Update (&md5, method, strlen (method));
   MD5Update (&md5, ":", 1);
   if (rnd_size > 0)
     MD5Update (&md5, rnd, rnd_size);
   MD5Update (&md5, ":", 1);
-  MD5Update (&md5, uri, strlen(uri));
+  MD5Update (&md5, uri, strlen (uri));
   MD5Update (&md5, ":", 1);
-  MD5Update (&md5, realm, strlen(realm));
+  MD5Update (&md5, realm, strlen (realm));
   MD5Final (tmpnonce, &md5);
   cvthex (tmpnonce, sizeof (tmpnonce), nonce);
   cvthex (timestamp, 4, timestamphex);
@@ -429,8 +429,8 @@ calculate_nonce (uint32_t nonce_time,
  * @param connection the connection
  * @param key the key
  * @param value the value, can be NULL
- * @return MHD_YES if the key-value pair is in the headers,
- *         MHD_NO if not
+ * @return #MHD_YES if the key-value pair is in the headers,
+ *         #MHD_NO if not
  */
 static int
 test_header (struct MHD_Connection *connection,

+ 3 - 3
src/microhttpd/internal.h

@@ -782,13 +782,13 @@ struct MHD_Connection
    * otherwise, this is the size of the current chunk.  A value of
    * zero is also used when we're at the end of the chunks.
    */
-  unsigned int current_chunk_size;
+  size_t current_chunk_size;
 
   /**
    * If we are receiving with chunked encoding, where are we currently
    * with respect to the current chunk (at what offset / position)?
    */
-  unsigned int current_chunk_offset;
+  size_t current_chunk_offset;
 
   /**
    * Handler used for processing read connection operations
@@ -1217,7 +1217,7 @@ struct MHD_Daemon
   /**
    * Size of `digest_auth_random.
    */
-  unsigned int digest_auth_rand_size;
+  size_t digest_auth_rand_size;
 
   /**
    * Size of the nonce-nc array.