aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2020-09-20 14:38:31 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2020-09-20 14:38:31 +0300
commit669ddcc0a2bb288f800bc27313dc568d369c3b2d (patch)
tree80397b14478762a306b2cceef78ee0e0d1f85b5e
parente861c61d4a7e36f6819b6a428a1636bf4150317e (diff)
downloadlibmicrohttpd-669ddcc0a2bb288f800bc27313dc568d369c3b2d.tar.gz
libmicrohttpd-669ddcc0a2bb288f800bc27313dc568d369c3b2d.zip
Minor optimisation for MHD_YES/MHD_NO comparison
Comparing against MHD_NO (binary zero) is more efficient
-rw-r--r--src/microhttpd/basicauth.c2
-rw-r--r--src/microhttpd/connection.c20
-rw-r--r--src/microhttpd/digestauth.c12
-rw-r--r--src/microhttpd/internal.c8
-rw-r--r--src/microhttpd/response.c2
5 files changed, 22 insertions, 22 deletions
diff --git a/src/microhttpd/basicauth.c b/src/microhttpd/basicauth.c
index d9532d4a..d39019f5 100644
--- a/src/microhttpd/basicauth.c
+++ b/src/microhttpd/basicauth.c
@@ -151,7 +151,7 @@ MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection,
151 ret = MHD_NO; 151 ret = MHD_NO;
152 152
153 free (header); 153 free (header);
154 if (MHD_YES == ret) 154 if (MHD_NO != ret)
155 { 155 {
156 ret = MHD_queue_response (connection, 156 ret = MHD_queue_response (connection,
157 MHD_HTTP_UNAUTHORIZED, 157 MHD_HTTP_UNAUTHORIZED,
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 02497cc6..f9f15cec 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -259,7 +259,7 @@ MHD_get_connection_values (struct MHD_Connection *connection,
259 { 259 {
260 ret++; 260 ret++;
261 if ( (NULL != iterator) && 261 if ( (NULL != iterator) &&
262 (MHD_YES != iterator (iterator_cls, 262 (MHD_NO == iterator (iterator_cls,
263 pos->kind, 263 pos->kind,
264 pos->header, 264 pos->header,
265 pos->value)) ) 265 pos->value)) )
@@ -1333,7 +1333,7 @@ build_header_response (struct MHD_Connection *connection)
1333 close the connection */ 1333 close the connection */
1334 /* 'close' header doesn't exist yet, see if we need to add one; 1334 /* 'close' header doesn't exist yet, see if we need to add one;
1335 if the client asked for a close, no need to start chunk'ing */ 1335 if the client asked for a close, no need to start chunk'ing */
1336 if ( (MHD_YES == keepalive_possible (connection)) && 1336 if ( (MHD_NO != keepalive_possible (connection)) &&
1337 (MHD_str_equal_caseless_ (MHD_HTTP_VERSION_1_1, 1337 (MHD_str_equal_caseless_ (MHD_HTTP_VERSION_1_1,
1338 connection->version) ) ) 1338 connection->version) ) )
1339 { 1339 {
@@ -1430,7 +1430,7 @@ build_header_response (struct MHD_Connection *connection)
1430#ifdef UPGRADE_SUPPORT 1430#ifdef UPGRADE_SUPPORT
1431 (NULL == response->upgrade_handler) && 1431 (NULL == response->upgrade_handler) &&
1432#endif /* UPGRADE_SUPPORT */ 1432#endif /* UPGRADE_SUPPORT */
1433 (MHD_YES == keepalive_possible (connection)) ) 1433 (MHD_NO != keepalive_possible (connection)) )
1434 must_add_keep_alive = true; 1434 must_add_keep_alive = true;
1435 break; 1435 break;
1436 case MHD_CONNECTION_BODY_SENT: 1436 case MHD_CONNECTION_BODY_SENT:
@@ -1631,7 +1631,7 @@ transmit_error_response (struct MHD_Connection *connection,
1631 status_code, 1631 status_code,
1632 response); 1632 response);
1633 MHD_destroy_response (response); 1633 MHD_destroy_response (response);
1634 if (MHD_YES != iret) 1634 if (MHD_NO == iret)
1635 { 1635 {
1636 /* can't even send a reply, at least close the connection */ 1636 /* can't even send a reply, at least close the connection */
1637 CONNECTION_CLOSE_ERROR (connection, 1637 CONNECTION_CLOSE_ERROR (connection,
@@ -2426,7 +2426,7 @@ process_request_body (struct MHD_Connection *connection)
2426 if (MHD_SIZE_UNKNOWN != connection->remaining_upload_size) 2426 if (MHD_SIZE_UNKNOWN != connection->remaining_upload_size)
2427 connection->remaining_upload_size -= processed_size; 2427 connection->remaining_upload_size -= processed_size;
2428 } 2428 }
2429 while (MHD_YES == instant_retry); 2429 while (MHD_NO != instant_retry);
2430 if ( (available > 0) && 2430 if ( (available > 0) &&
2431 (buffer_head != connection->read_buffer) ) 2431 (buffer_head != connection->read_buffer) )
2432 memmove (connection->read_buffer, 2432 memmove (connection->read_buffer,
@@ -2666,7 +2666,7 @@ parse_connection_headers (struct MHD_Connection *connection)
2666 MHD_HTTP_BAD_REQUEST, 2666 MHD_HTTP_BAD_REQUEST,
2667 response); 2667 response);
2668 MHD_destroy_response (response); 2668 MHD_destroy_response (response);
2669 if (MHD_YES != iret) 2669 if (MHD_NO == iret)
2670 { 2670 {
2671 /* can't even send a reply, at least close the connection */ 2671 /* can't even send a reply, at least close the connection */
2672 CONNECTION_CLOSE_ERROR (connection, 2672 CONNECTION_CLOSE_ERROR (connection,
@@ -3012,7 +3012,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
3012 if (NULL != response->crc) 3012 if (NULL != response->crc)
3013 MHD_mutex_lock_chk_ (&response->mutex); 3013 MHD_mutex_lock_chk_ (&response->mutex);
3014#endif 3014#endif
3015 if (MHD_YES != try_ready_normal_body (connection)) 3015 if (MHD_NO == try_ready_normal_body (connection))
3016 { 3016 {
3017 /* mutex was already unlocked by try_ready_normal_body */ 3017 /* mutex was already unlocked by try_ready_normal_body */
3018 return; 3018 return;
@@ -3494,7 +3494,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
3494 { 3494 {
3495 connection->state = MHD_CONNECTION_UPGRADE; 3495 connection->state = MHD_CONNECTION_UPGRADE;
3496 /* This connection is "upgraded". Pass socket to application. */ 3496 /* This connection is "upgraded". Pass socket to application. */
3497 if (MHD_YES != 3497 if (MHD_NO ==
3498 MHD_response_execute_upgrade_ (connection->response, 3498 MHD_response_execute_upgrade_ (connection->response,
3499 connection)) 3499 connection))
3500 { 3500 {
@@ -3536,7 +3536,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
3536 connection->state = MHD_CONNECTION_BODY_SENT; 3536 connection->state = MHD_CONNECTION_BODY_SENT;
3537 continue; 3537 continue;
3538 } 3538 }
3539 if (MHD_YES == try_ready_normal_body (connection)) 3539 if (MHD_NO != try_ready_normal_body (connection))
3540 { 3540 {
3541#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3541#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3542 if (NULL != connection->response->crc) 3542 if (NULL != connection->response->crc)
@@ -3569,7 +3569,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
3569 connection->state = MHD_CONNECTION_BODY_SENT; 3569 connection->state = MHD_CONNECTION_BODY_SENT;
3570 continue; 3570 continue;
3571 } 3571 }
3572 if (MHD_YES == try_ready_chunked_body (connection)) 3572 if (MHD_NO != try_ready_chunked_body (connection))
3573 { 3573 {
3574#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3574#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3575 if (NULL != connection->response->crc) 3575 if (NULL != connection->response->crc)
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index d8d3b4ea..c3260d1b 100644
--- a/src/microhttpd/digestauth.c
+++ b/src/microhttpd/digestauth.c
@@ -814,7 +814,7 @@ check_argument_match (struct MHD_Connection *connection,
814 &test_header, 814 &test_header,
815 &num_headers); 815 &num_headers);
816 free (argb); 816 free (argb);
817 if (MHD_YES != ret) 817 if (MHD_NO == ret)
818 { 818 {
819 return MHD_NO; 819 return MHD_NO;
820 } 820 }
@@ -1025,7 +1025,7 @@ digest_auth_check_all (struct MHD_Connection *connection,
1025 * Checking if that combination of nonce and nc is sound 1025 * Checking if that combination of nonce and nc is sound
1026 * and not a replay attack attempt. Also adds the nonce 1026 * and not a replay attack attempt. Also adds the nonce
1027 * to the nonce-nc map if it does not exist there. 1027 * to the nonce-nc map if it does not exist there.
1028 */if (MHD_YES != 1028 */if (MHD_NO ==
1029 check_nonce_nc (connection, 1029 check_nonce_nc (connection,
1030 nonce, 1030 nonce,
1031 nci)) 1031 nci))
@@ -1114,7 +1114,7 @@ digest_auth_check_all (struct MHD_Connection *connection,
1114 args = ""; 1114 args = "";
1115 else 1115 else
1116 args++; 1116 args++;
1117 if (MHD_YES != 1117 if (MHD_NO ==
1118 check_argument_match (connection, 1118 check_argument_match (connection,
1119 args) ) 1119 args) )
1120 { 1120 {
@@ -1363,7 +1363,7 @@ MHD_queue_auth_fail_response2 (struct MHD_Connection *connection,
1363 realm, 1363 realm,
1364 &da, 1364 &da,
1365 nonce); 1365 nonce);
1366 if (MHD_YES != 1366 if (MHD_NO ==
1367 check_nonce_nc (connection, 1367 check_nonce_nc (connection,
1368 nonce, 1368 nonce,
1369 0)) 1369 0))
@@ -1417,7 +1417,7 @@ MHD_queue_auth_fail_response2 (struct MHD_Connection *connection,
1417 else 1417 else
1418 ret = MHD_NO; 1418 ret = MHD_NO;
1419#if 0 1419#if 0
1420 if ( (MHD_YES == ret) && (AND in state : 100 continue aborting ...)) 1420 if ( (MHD_NO != ret) && (AND in state : 100 continue aborting ...))
1421 ret = MHD_add_response_header (response, 1421 ret = MHD_add_response_header (response,
1422 MHD_HTTP_HEADER_CONNECTION, 1422 MHD_HTTP_HEADER_CONNECTION,
1423 "close"); 1423 "close");
@@ -1428,7 +1428,7 @@ MHD_queue_auth_fail_response2 (struct MHD_Connection *connection,
1428 ret = MHD_NO; 1428 ret = MHD_NO;
1429 } 1429 }
1430 1430
1431 if (MHD_YES == ret) 1431 if (MHD_NO != ret)
1432 { 1432 {
1433 ret = MHD_queue_response (connection, 1433 ret = MHD_queue_response (connection,
1434 MHD_HTTP_UNAUTHORIZED, 1434 MHD_HTTP_UNAUTHORIZED,
diff --git a/src/microhttpd/internal.c b/src/microhttpd/internal.c
index ba601fa0..33542c4a 100644
--- a/src/microhttpd/internal.c
+++ b/src/microhttpd/internal.c
@@ -213,7 +213,7 @@ MHD_parse_arguments_ (struct MHD_Connection *connection,
213 key_len = daemon->unescape_callback (daemon->unescape_callback_cls, 213 key_len = daemon->unescape_callback (daemon->unescape_callback_cls,
214 connection, 214 connection,
215 args); 215 args);
216 if (MHD_YES != cb (connection, 216 if (MHD_NO == cb (connection,
217 args, 217 args,
218 key_len, 218 key_len,
219 NULL, 219 NULL,
@@ -234,7 +234,7 @@ MHD_parse_arguments_ (struct MHD_Connection *connection,
234 value_len = daemon->unescape_callback (daemon->unescape_callback_cls, 234 value_len = daemon->unescape_callback (daemon->unescape_callback_cls,
235 connection, 235 connection,
236 equals); 236 equals);
237 if (MHD_YES != cb (connection, 237 if (MHD_NO == cb (connection,
238 args, 238 args,
239 key_len, 239 key_len,
240 equals, 240 equals,
@@ -255,7 +255,7 @@ MHD_parse_arguments_ (struct MHD_Connection *connection,
255 key_len = daemon->unescape_callback (daemon->unescape_callback_cls, 255 key_len = daemon->unescape_callback (daemon->unescape_callback_cls,
256 connection, 256 connection,
257 args); 257 args);
258 if (MHD_YES != cb (connection, 258 if (MHD_NO == cb (connection,
259 args, 259 args,
260 key_len, 260 key_len,
261 NULL, 261 NULL,
@@ -279,7 +279,7 @@ MHD_parse_arguments_ (struct MHD_Connection *connection,
279 value_len = daemon->unescape_callback (daemon->unescape_callback_cls, 279 value_len = daemon->unescape_callback (daemon->unescape_callback_cls,
280 connection, 280 connection,
281 equals); 281 equals);
282 if (MHD_YES != cb (connection, 282 if (MHD_NO == cb (connection,
283 args, 283 args,
284 key_len, 284 key_len,
285 equals, 285 equals,
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 27b3ee3f..141372b9 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -262,7 +262,7 @@ MHD_get_response_headers (struct MHD_Response *response,
262 { 262 {
263 numHeaders++; 263 numHeaders++;
264 if ((NULL != iterator) && 264 if ((NULL != iterator) &&
265 (MHD_YES != iterator (iterator_cls, 265 (MHD_NO == iterator (iterator_cls,
266 pos->kind, 266 pos->kind,
267 pos->header, 267 pos->header,
268 pos->value))) 268 pos->value)))