Willy,

I did not touch the `struct pat_time` in pattern.h which appears to be
completely unused. Please check whether adjustments should be made there
as well or whether it should simply be removed. Feel free to amend my
patch if necessary.

Best regards
Tim Düsterhus

Apply with `git am --scissors` to automatically cut the commit message.

-- >8 --
Subject: [PATCH] CLEANUP: Consistently `unsigned int` for bitfields

- Non-ints are not allowed by the C standard.
- Signed bitfields of size `1` hold the values `0` and `-1`, but are
  usually assigned `1`, possibly leading to subtle bugs when the value
  is explicitely compared against `1`.
---
 include/types/fd.h       | 6 +++---
 include/types/listener.h | 6 +++---
 include/types/pattern.h  | 4 ++--
 include/types/ssl_sock.h | 8 ++++----
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/types/fd.h b/include/types/fd.h
index dae1c90c9..61af8a523 100644
--- a/include/types/fd.h
+++ b/include/types/fd.h
@@ -129,9 +129,9 @@ struct fdtab {
        void *owner;                         /* the connection or listener 
associated with this fd, NULL if closed */
        unsigned char state;                 /* FD state for read and write 
directions (2*3 bits) */
        unsigned char ev;                    /* event seen in return of poll() 
: FD_POLL_* */
-       unsigned char linger_risk:1;         /* 1 if we must kill lingering 
before closing */
-       unsigned char cloned:1;              /* 1 if a cloned socket, requires 
EPOLL_CTL_DEL on close */
-       unsigned char initialized:1;         /* 1 if init phase was done on 
this fd (e.g. set non-blocking) */
+       unsigned int linger_risk:1;          /* 1 if we must kill lingering 
before closing */
+       unsigned int cloned:1;               /* 1 if a cloned socket, requires 
EPOLL_CTL_DEL on close */
+       unsigned int initialized:1;          /* 1 if init phase was done on 
this fd (e.g. set non-blocking) */
 }
 #ifdef USE_THREAD
 /* only align on cache lines when using threads; 32-bit small archs
diff --git a/include/types/listener.h b/include/types/listener.h
index 1098b42ce..bcc57ae70 100644
--- a/include/types/listener.h
+++ b/include/types/listener.h
@@ -124,9 +124,9 @@ struct ssl_bind_conf {
        char *alpn_str;            /* ALPN protocol string */
        int alpn_len;              /* ALPN protocol string length */
 #endif
-       int verify:3;              /* verify method (set of SSL_VERIFY_* flags) 
*/
-       int no_ca_names:1;         /* do not send ca names to clients (ca_file 
related) */
-       int early_data:1;          /* early data allowed */
+       unsigned int verify:3;     /* verify method (set of SSL_VERIFY_* flags) 
*/
+       unsigned int no_ca_names:1;/* do not send ca names to clients (ca_file 
related) */
+       unsigned int early_data:1; /* early data allowed */
        char *ca_file;             /* CAfile to use on verify */
        char *crl_file;            /* CRLfile to use on verify */
        char *ciphers;             /* cipher suite to use if non-null */
diff --git a/include/types/pattern.h b/include/types/pattern.h
index a0bb08e16..a2d609ba0 100644
--- a/include/types/pattern.h
+++ b/include/types/pattern.h
@@ -150,8 +150,8 @@ struct pattern {
                int i;                          /* integer value */
                struct {
                        signed long long min, max;
-                       int min_set :1;
-                       int max_set :1;
+                       unsigned int min_set:1;
+                       unsigned int max_set:1;
                } range; /* integer range */
                struct {
                        struct in_addr addr;
diff --git a/include/types/ssl_sock.h b/include/types/ssl_sock.h
index ccc923508..172be6772 100644
--- a/include/types/ssl_sock.h
+++ b/include/types/ssl_sock.h
@@ -36,8 +36,8 @@ struct pkey_info {
 struct sni_ctx {
        SSL_CTX *ctx;             /* context associated to the certificate */
        int order;                /* load order for the certificate */
-       uint8_t neg:1;              /* reject if match */
-       uint8_t wild:1;            /* wildcard sni */
+       unsigned int neg:1;              /* reject if match */
+       unsigned int wild:1;            /* wildcard sni */
        struct pkey_info kinfo;   /* pkey info */
        struct ssl_bind_conf *conf; /* ssl "bind" conf for the certificate */
        struct list by_ckch_inst; /* chained in ckch_inst's list of sni_ctx */
@@ -109,8 +109,8 @@ struct cert_key_and_chain {
  */
 struct ckch_store {
        struct cert_key_and_chain *ckch;
-       int multi:1; /* is it a multi-cert bundle ? */
-       int filters:1; /* one of the instances is using filters, TODO:remove 
this flag once filters are supported */
+       unsigned int multi:1; /* is it a multi-cert bundle ? */
+       unsigned int filters:1; /* one of the instances is using filters, 
TODO:remove this flag once filters are supported */
        struct list ckch_inst; /* list of ckch_inst which uses this ckch_node */
        struct ebmb_node node;
        char path[0];
-- 
2.25.0


Reply via email to