From c1303660eda80c5e17fde06bb8f17715e7be049b Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Thu, 23 Mar 2023 20:16:08 +0000 Subject: Convert uint8_t struct boolean members to nxt_bool_t. Replace the usage of uint8_t in structures to represent boolean values with our nxt_bool_t type. This will result in no change in structure layout as the nxt_bool_t is now a uint8_t, same as what it's replacing. Even though it's essentially the same type, it makes it much clearer as to what its purpose is. This was largely done with the following script from Alex, with some manual conversions $ grep -rl 'uint8_t.*1 bit' src/ \ | xargs sed -i '/uint8_t.*1 bit/{s/uint8_t /nxt_bool_t /;s/; *\/\*.*/;/}' This doesn't convert the non-uint8_t booleans, they will be handled separately. Reviewed-by: Alejandro Colomar Signed-off-by: Andrew Clayton --- src/nxt_buf_pool.h | 4 ++-- src/nxt_capability.h | 4 ++-- src/nxt_conf.h | 2 +- src/nxt_conn.h | 14 +++++++------- src/nxt_event_engine.h | 8 ++++---- src/nxt_gnutls.c | 2 +- src/nxt_h1proto.h | 16 ++++++++-------- src/nxt_http.h | 20 ++++++++++---------- src/nxt_http_parse.h | 18 +++++++++--------- src/nxt_http_route.c | 8 ++++---- src/nxt_http_static.c | 4 ++-- src/nxt_job.h | 2 +- src/nxt_listen_socket.h | 4 ++-- src/nxt_openssl.c | 2 +- src/nxt_php_sapi.c | 2 +- src/nxt_port.h | 12 ++++++------ src/nxt_process.h | 2 +- src/nxt_router.c | 4 ++-- src/nxt_router.h | 4 ++-- src/nxt_sendbuf.h | 12 ++++++------ src/nxt_thread_time.h | 4 ++-- src/nxt_tls.h | 2 +- src/nxt_tstr.h | 2 +- src/nxt_unit.c | 8 ++++---- 24 files changed, 80 insertions(+), 80 deletions(-) diff --git a/src/nxt_buf_pool.h b/src/nxt_buf_pool.h index 3d22d7fa..65f02163 100644 --- a/src/nxt_buf_pool.h +++ b/src/nxt_buf_pool.h @@ -28,8 +28,8 @@ typedef struct { uint32_t size; uint8_t flags; /* 2 bits */ - uint8_t destroy; /* 1 bit */ - uint8_t mmap; /* 1 bit */ + nxt_bool_t destroy; + nxt_bool_t mmap; } nxt_buf_pool_t; diff --git a/src/nxt_capability.h b/src/nxt_capability.h index 1575d409..0fa22f26 100644 --- a/src/nxt_capability.h +++ b/src/nxt_capability.h @@ -7,8 +7,8 @@ #define _NXT_CAPABILITY_INCLUDED_ typedef struct { - uint8_t setid; /* 1 bit */ - uint8_t chroot; /* 1 bit */ + nxt_bool_t setid; + nxt_bool_t chroot; } nxt_capabilities_t; diff --git a/src/nxt_conf.h b/src/nxt_conf.h index 1b13f5ae..95b504ef 100644 --- a/src/nxt_conf.h +++ b/src/nxt_conf.h @@ -63,7 +63,7 @@ typedef struct { typedef struct { uint32_t level; - uint8_t more_space; /* 1 bit. */ + nxt_bool_t more_space; } nxt_conf_json_pretty_t; diff --git a/src/nxt_conn.h b/src/nxt_conn.h index 5717d3c9..9301c809 100644 --- a/src/nxt_conn.h +++ b/src/nxt_conn.h @@ -157,17 +157,17 @@ struct nxt_conn_s { nxt_sockaddr_t *local; const char *action; - uint8_t block_read; /* 1 bit */ - uint8_t block_write; /* 1 bit */ - uint8_t delayed; /* 1 bit */ - uint8_t idle; /* 1 bit */ + nxt_bool_t block_read; + nxt_bool_t block_write; + nxt_bool_t delayed; + nxt_bool_t idle; #define NXT_CONN_SENDFILE_OFF 0 #define NXT_CONN_SENDFILE_ON 1 #define NXT_CONN_SENDFILE_UNSET 3 uint8_t sendfile; /* 2 bits */ - uint8_t tcp_nodelay; /* 1 bit */ + nxt_bool_t tcp_nodelay; nxt_queue_link_t link; }; @@ -339,8 +339,8 @@ typedef struct { nxt_msec_t client_write_timeout; nxt_msec_t peer_write_timeout; - uint8_t connected; /* 1 bit */ - uint8_t delayed; /* 1 bit */ + nxt_bool_t connected; + nxt_bool_t delayed; uint8_t retries; /* 8 bits */ uint8_t retain; /* 2 bits */ diff --git a/src/nxt_event_engine.h b/src/nxt_event_engine.h index 291ea749..8773acee 100644 --- a/src/nxt_event_engine.h +++ b/src/nxt_event_engine.h @@ -160,10 +160,10 @@ typedef struct { nxt_conn_io_t *io; /* True if an event facility supports file change event notifications. */ - uint8_t file_support; /* 1 bit */ + nxt_bool_t file_support; /* True if an event facility supports signal event notifications. */ - uint8_t signal_support; /* 1 bit */ + nxt_bool_t signal_support; } nxt_event_interface_t; @@ -202,7 +202,7 @@ typedef struct { nxt_uint_t mchanges; int mevents; - uint8_t error; /* 1 bit */ + nxt_bool_t error; nxt_epoll_change_t *changes; struct epoll_event *events; @@ -470,7 +470,7 @@ struct nxt_event_engine_s { /* The engine ID, the main engine has ID 0. */ uint32_t id; - uint8_t shutdown; /* 1 bit */ + nxt_bool_t shutdown; uint32_t batch; uint32_t connections; diff --git a/src/nxt_gnutls.c b/src/nxt_gnutls.c index aab4699c..c5eb6341 100644 --- a/src/nxt_gnutls.c +++ b/src/nxt_gnutls.c @@ -12,7 +12,7 @@ typedef struct { gnutls_session_t session; uint8_t times; /* 2 bits */ - uint8_t no_shutdown; /* 1 bit */ + nxt_bool_t no_shutdown; nxt_buf_mem_t buffer; } nxt_gnutls_conn_t; diff --git a/src/nxt_h1proto.h b/src/nxt_h1proto.h index f8500963..c0d37234 100644 --- a/src/nxt_h1proto.h +++ b/src/nxt_h1proto.h @@ -24,16 +24,16 @@ struct nxt_h1proto_s { uint8_t nbuffers; uint8_t header_buffer_slot; uint8_t large_buffer_slot; - uint8_t keepalive; /* 1 bit */ - uint8_t chunked; /* 1 bit */ - uint8_t websocket; /* 1 bit */ - uint8_t connection_upgrade; /* 1 bit */ - uint8_t upgrade_websocket; /* 1 bit */ - uint8_t websocket_version_ok; /* 1 bit */ + nxt_bool_t keepalive; + nxt_bool_t chunked; + nxt_bool_t websocket; + nxt_bool_t connection_upgrade; + nxt_bool_t upgrade_websocket; + nxt_bool_t websocket_version_ok; nxt_http_te_t transfer_encoding:8; /* 2 bits */ - uint8_t websocket_cont_expected; /* 1 bit */ - uint8_t websocket_closed; /* 1 bit */ + nxt_bool_t websocket_cont_expected; + nxt_bool_t websocket_closed; uint32_t header_size; diff --git a/src/nxt_http.h b/src/nxt_http.h index ffd3f601..7739d9cd 100644 --- a/src/nxt_http.h +++ b/src/nxt_http.h @@ -124,8 +124,8 @@ typedef struct { nxt_http_status_t status:16; nxt_http_protocol_t protocol:8; /* 2 bits */ - uint8_t header_received; /* 1 bit */ - uint8_t closed; /* 1 bit */ + nxt_bool_t header_received; + nxt_bool_t closed; } nxt_http_peer_t; @@ -189,17 +189,17 @@ struct nxt_http_request_s { nxt_http_status_t status:16; - uint8_t log_route; /* 1 bit */ + nxt_bool_t log_route; uint8_t pass_count; /* 8 bits */ uint8_t app_target; nxt_http_protocol_t protocol:8; /* 2 bits */ - uint8_t tls; /* 1 bit */ - uint8_t logged; /* 1 bit */ - uint8_t header_sent; /* 1 bit */ - uint8_t inconsistent; /* 1 bit */ - uint8_t error; /* 1 bit */ - uint8_t websocket_handshake; /* 1 bit */ + nxt_bool_t tls; + nxt_bool_t logged; + nxt_bool_t header_sent; + nxt_bool_t inconsistent; + nxt_bool_t error; + nxt_bool_t websocket_handshake; }; @@ -288,7 +288,7 @@ struct nxt_http_forward_s { nxt_http_forward_header_t client_ip; nxt_http_forward_header_t protocol; nxt_http_route_addr_rule_t *source; - uint8_t recursive; /* 1 bit */ + nxt_bool_t recursive; }; diff --git a/src/nxt_http_parse.h b/src/nxt_http_parse.h index 2b714464..4aa1c258 100644 --- a/src/nxt_http_parse.h +++ b/src/nxt_http_parse.h @@ -55,19 +55,19 @@ struct nxt_http_request_parse_s { uint32_t field_hash; - uint8_t skip_field; /* 1 bit */ - uint8_t discard_unsafe_fields; /* 1 bit */ + nxt_bool_t skip_field; + nxt_bool_t discard_unsafe_fields; /* target with "/." */ - uint8_t complex_target; /* 1 bit */ + nxt_bool_t complex_target; #if 0 /* target with "%" */ - uint8_t quoted_target; /* 1 bit */ + nxt_bool_t quoted_target; /* target with " " */ - uint8_t space_in_target; /* 1 bit */ + nxt_bool_t space_in_target; #endif /* Preserve encoded '/' (%2F) and '%' (%25). */ - uint8_t encoded_slashes; /* 1 bit */ + nxt_bool_t encoded_slashes; }; @@ -101,9 +101,9 @@ typedef struct { uint64_t chunk_size; uint8_t state; - uint8_t last; /* 1 bit */ - uint8_t chunk_error; /* 1 bit */ - uint8_t error; /* 1 bit */ + nxt_bool_t last; + nxt_bool_t chunk_error; + nxt_bool_t error; } nxt_http_chunk_parse_t; diff --git a/src/nxt_http_route.c b/src/nxt_http_route.c index f439c957..b2fac77c 100644 --- a/src/nxt_http_route.c +++ b/src/nxt_http_route.c @@ -70,11 +70,11 @@ typedef struct { } u; uint32_t min_length; - uint8_t case_sensitive; /* 1 bit */ - uint8_t negative; /* 1 bit */ - uint8_t any; /* 1 bit */ + nxt_bool_t case_sensitive; + nxt_bool_t negative; + nxt_bool_t any; #if (NXT_HAVE_REGEX) - uint8_t regex; /* 1 bit */ + nxt_bool_t regex; #endif } nxt_http_route_pattern_t; diff --git a/src/nxt_http_static.c b/src/nxt_http_static.c index 5e44aab4..f923f82c 100644 --- a/src/nxt_http_static.c +++ b/src/nxt_http_static.c @@ -12,7 +12,7 @@ typedef struct { #if (NXT_HAVE_OPENAT2) u_char *fname; #endif - uint8_t is_const; /* 1 bit */ + nxt_bool_t is_const; } nxt_http_static_share_t; @@ -35,7 +35,7 @@ typedef struct { nxt_str_t chroot; #endif uint32_t share_idx; - uint8_t need_body; /* 1 bit */ + nxt_bool_t need_body; } nxt_http_static_ctx_t; diff --git a/src/nxt_job.h b/src/nxt_job.h index 0495c484..a831c644 100644 --- a/src/nxt_job.h +++ b/src/nxt_job.h @@ -38,7 +38,7 @@ typedef struct { nxt_work_handler_t abort_handler; uint16_t cache_size; - uint8_t cancel; /* 1 bit */ + nxt_bool_t cancel; nxt_mp_t *mem_pool; nxt_queue_link_t link; diff --git a/src/nxt_listen_socket.h b/src/nxt_listen_socket.h index e2435b76..00dcfa59 100644 --- a/src/nxt_listen_socket.h +++ b/src/nxt_listen_socket.h @@ -21,10 +21,10 @@ typedef struct { uint32_t count; uint8_t flags; - uint8_t read_after_accept; /* 1 bit */ + nxt_bool_t read_after_accept; #if (NXT_TLS) - uint8_t tls; /* 1 bit */ + nxt_bool_t tls; #endif #if (NXT_INET6 && defined IPV6_V6ONLY) uint8_t ipv6only; /* 2 bits */ diff --git a/src/nxt_openssl.c b/src/nxt_openssl.c index f56135f3..cc5f7968 100644 --- a/src/nxt_openssl.c +++ b/src/nxt_openssl.c @@ -24,7 +24,7 @@ typedef struct { int ssl_error; uint8_t times; /* 2 bits */ - uint8_t handshake; /* 1 bit */ + nxt_bool_t handshake; nxt_tls_conf_t *conf; nxt_buf_mem_t buffer; diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c index 32a13a70..95cd500b 100644 --- a/src/nxt_php_sapi.c +++ b/src/nxt_php_sapi.c @@ -62,7 +62,7 @@ typedef struct { nxt_str_t script_dirname; nxt_unit_request_info_t *req; - uint8_t chdir; /* 1 bit */ + nxt_bool_t chdir; } nxt_php_run_ctx_t; diff --git a/src/nxt_port.h b/src/nxt_port.h index eba8d06f..deaa8acc 100644 --- a/src/nxt_port.h +++ b/src/nxt_port.h @@ -172,16 +172,16 @@ typedef struct { uint8_t type; /* Last message for this stream. */ - uint8_t last; /* 1 bit */ + nxt_bool_t last; /* Message data send using mmap, next chunk is a nxt_port_mmap_msg_t. */ - uint8_t mmap; /* 1 bit */ + nxt_bool_t mmap; /* Non-First fragment in fragmented message sequence. */ - uint8_t nf; /* 1 bit */ + nxt_bool_t nf; /* More Fragments followed. */ - uint8_t mf; /* 1 bit */ + nxt_bool_t mf; } nxt_port_msg_t; @@ -191,8 +191,8 @@ typedef struct { size_t share; nxt_fd_t fd[2]; nxt_port_msg_t port_msg; - uint8_t close_fd; /* 1 bit */ - uint8_t allocated; /* 1 bit */ + nxt_bool_t close_fd; + nxt_bool_t allocated; } nxt_port_send_msg_t; #if (NXT_HAVE_UCRED) || (NXT_HAVE_MSGHDR_CMSGCRED) diff --git a/src/nxt_process.h b/src/nxt_process.h index 16d6110c..4c00ce6c 100644 --- a/src/nxt_process.h +++ b/src/nxt_process.h @@ -93,7 +93,7 @@ typedef struct { #endif #if (NXT_HAVE_PR_SET_NO_NEW_PRIVS) - uint8_t new_privs; /* 1 bit */ + nxt_bool_t new_privs; #endif } nxt_process_isolation_t; diff --git a/src/nxt_router.c b/src/nxt_router.c index 992cc039..aa033ced 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -66,14 +66,14 @@ typedef struct { typedef struct { nxt_app_t *app; nxt_router_temp_conf_t *temp_conf; - uint8_t proto; /* 1 bit */ + nxt_bool_t proto; } nxt_app_rpc_t; typedef struct { nxt_app_joint_t *app_joint; uint32_t generation; - uint8_t proto; /* 1 bit */ + nxt_bool_t proto; } nxt_app_joint_rpc_t; diff --git a/src/nxt_router.h b/src/nxt_router.h index 64095b69..9e5fb31c 100644 --- a/src/nxt_router.h +++ b/src/nxt_router.h @@ -197,9 +197,9 @@ typedef struct { nxt_str_t body_temp_path; - uint8_t log_route; /* 1 bit */ + nxt_bool_t log_route; - uint8_t discard_unsafe_fields; /* 1 bit */ + nxt_bool_t discard_unsafe_fields; nxt_http_forward_t *forwarded; nxt_http_forward_t *client_ip; diff --git a/src/nxt_sendbuf.h b/src/nxt_sendbuf.h index fcbe1a25..4bc33e4e 100644 --- a/src/nxt_sendbuf.h +++ b/src/nxt_sendbuf.h @@ -44,10 +44,10 @@ typedef struct { size_t size; size_t limit; - uint8_t ready; /* 1 bit */ - uint8_t once; /* 1 bit */ - uint8_t sync; /* 1 bit */ - uint8_t last; /* 1 bit */ + nxt_bool_t ready; + nxt_bool_t once; + nxt_bool_t sync; + nxt_bool_t last; } nxt_sendbuf_t; @@ -57,8 +57,8 @@ typedef struct { nxt_uint_t niov; uint32_t nmax; - uint8_t sync; /* 1 bit */ - uint8_t last; /* 1 bit */ + nxt_bool_t sync; + nxt_bool_t last; uint8_t limit_reached; uint8_t nmax_reached; diff --git a/src/nxt_thread_time.h b/src/nxt_thread_time.h index 77eaea49..7c133b4b 100644 --- a/src/nxt_thread_time.h +++ b/src/nxt_thread_time.h @@ -23,8 +23,8 @@ typedef struct { const char *format; size_t size; - uint8_t timezone; /* 1 bit */ - uint8_t msec; /* 1 bit */ + nxt_bool_t timezone; + nxt_bool_t msec; } nxt_time_string_t; diff --git a/src/nxt_tls.h b/src/nxt_tls.h index 0667ade3..cf9cee87 100644 --- a/src/nxt_tls.h +++ b/src/nxt_tls.h @@ -78,7 +78,7 @@ struct nxt_tls_conf_s { size_t buffer_size; - uint8_t no_wait_shutdown; /* 1 bit */ + nxt_bool_t no_wait_shutdown; }; diff --git a/src/nxt_tstr.h b/src/nxt_tstr.h index ce8e6f3a..149ee86d 100644 --- a/src/nxt_tstr.h +++ b/src/nxt_tstr.h @@ -19,7 +19,7 @@ typedef struct { #if (NXT_HAVE_NJS) nxt_js_conf_t *jcf; #endif - uint8_t test; /* 1 bit */ + nxt_bool_t test; } nxt_tstr_state_t; diff --git a/src/nxt_unit.c b/src/nxt_unit.c index e1b1897a..9d696f5e 100644 --- a/src/nxt_unit.c +++ b/src/nxt_unit.c @@ -222,8 +222,8 @@ struct nxt_unit_recv_msg_s { nxt_pid_t pid; nxt_port_id_t reply_port; - uint8_t last; /* 1 bit */ - uint8_t mmap; /* 1 bit */ + nxt_bool_t last; + nxt_bool_t mmap; void *start; uint32_t size; @@ -319,8 +319,8 @@ struct nxt_unit_ctx_impl_s { /* of nxt_unit_read_buf_t */ nxt_queue_t free_rbuf; - uint8_t online; /* 1 bit */ - uint8_t ready; /* 1 bit */ + nxt_bool_t online; + nxt_bool_t ready; uint8_t quit_param; nxt_unit_mmap_buf_t ctx_buf[2]; -- cgit