Added intermediate casts to void* to prevent spurious warnings (with Clang and -Wcast...
authorThomas Pornin <pornin@bolet.org>
Sat, 19 Aug 2017 13:50:45 +0000 (15:50 +0200)
committerThomas Pornin <pornin@bolet.org>
Sat, 19 Aug 2017 13:50:45 +0000 (15:50 +0200)
14 files changed:
src/codec/pemdec.c
src/codec/pemdec.t0
src/ssl/ssl_hs_client.c
src/ssl/ssl_hs_common.t0
src/ssl/ssl_hs_server.c
src/x509/asn1.t0
src/x509/skey_decoder.c
src/x509/skey_decoder.t0
src/x509/x509_decoder.c
src/x509/x509_decoder.t0
src/x509/x509_minimal.c
src/x509/x509_minimal.t0
tools/client.c
tools/server.c

index 51e610b..db8f0e6 100644 (file)
@@ -69,7 +69,7 @@ void br_pem_decoder_run(void *t0ctx);
 
 #include "inner.h"
 
-#define CTX   ((br_pem_decoder_context *)((unsigned char *)t0ctx - offsetof(br_pem_decoder_context, cpu)))
+#define CTX   ((br_pem_decoder_context *)(void *)((unsigned char *)t0ctx - offsetof(br_pem_decoder_context, cpu)))
 
 /* see bearssl_pem.h */
 void
index ba4a9e2..d76be44 100644 (file)
@@ -24,7 +24,7 @@ preamble {
 
 #include "inner.h"
 
-#define CTX   ((br_pem_decoder_context *)((unsigned char *)t0ctx - offsetof(br_pem_decoder_context, cpu)))
+#define CTX   ((br_pem_decoder_context *)(void *)((unsigned char *)t0ctx - offsetof(br_pem_decoder_context, cpu)))
 
 /* see bearssl_pem.h */
 void
index 9d3418b..2faba6a 100644 (file)
@@ -75,7 +75,7 @@ void br_ssl_hs_client_run(void *t0ctx);
 /*
  * This macro evaluates to a pointer to the current engine context.
  */
-#define ENG  ((br_ssl_engine_context *)((unsigned char *)t0ctx - offsetof(br_ssl_engine_context, cpu)))
+#define ENG  ((br_ssl_engine_context *)(void *)((unsigned char *)t0ctx - offsetof(br_ssl_engine_context, cpu)))
 
 
 
@@ -1397,7 +1397,7 @@ br_ssl_hs_client_run(void *t0ctx)
                                /* get16 */
 
        size_t addr = (size_t)T0_POP();
-       T0_PUSH(*(uint16_t *)((unsigned char *)ENG + addr));
+       T0_PUSH(*(uint16_t *)(void *)((unsigned char *)ENG + addr));
 
                                }
                                break;
@@ -1405,7 +1405,7 @@ br_ssl_hs_client_run(void *t0ctx)
                                /* get32 */
 
        size_t addr = (size_t)T0_POP();
-       T0_PUSH(*(uint32_t *)((unsigned char *)ENG + addr));
+       T0_PUSH(*(uint32_t *)(void *)((unsigned char *)ENG + addr));
 
                                }
                                break;
@@ -1557,7 +1557,7 @@ br_ssl_hs_client_run(void *t0ctx)
                                /* set16 */
 
        size_t addr = (size_t)T0_POP();
-       *(uint16_t *)((unsigned char *)ENG + addr) = (uint16_t)T0_POP();
+       *(uint16_t *)(void *)((unsigned char *)ENG + addr) = (uint16_t)T0_POP();
 
                                }
                                break;
@@ -1565,7 +1565,7 @@ br_ssl_hs_client_run(void *t0ctx)
                                /* set32 */
 
        size_t addr = (size_t)T0_POP();
-       *(uint32_t *)((unsigned char *)ENG + addr) = (uint32_t)T0_POP();
+       *(uint32_t *)(void *)((unsigned char *)ENG + addr) = (uint32_t)T0_POP();
 
                                }
                                break;
index dc025ff..f4ad65b 100644 (file)
@@ -34,7 +34,7 @@ preamble {
 /*
  * This macro evaluates to a pointer to the current engine context.
  */
-#define ENG  ((br_ssl_engine_context *)((unsigned char *)t0ctx - offsetof(br_ssl_engine_context, cpu)))
+#define ENG  ((br_ssl_engine_context *)(void *)((unsigned char *)t0ctx - offsetof(br_ssl_engine_context, cpu)))
 
 }
 
@@ -112,13 +112,13 @@ cc: get8 ( addr -- val ) {
 \ Read a 16-bit word from the context (address is offset in context).
 cc: get16 ( addr -- val ) {
        size_t addr = (size_t)T0_POP();
-       T0_PUSH(*(uint16_t *)((unsigned char *)ENG + addr));
+       T0_PUSH(*(uint16_t *)(void *)((unsigned char *)ENG + addr));
 }
 
 \ Read a 32-bit word from the context (address is offset in context).
 cc: get32 ( addr -- val ) {
        size_t addr = (size_t)T0_POP();
-       T0_PUSH(*(uint32_t *)((unsigned char *)ENG + addr));
+       T0_PUSH(*(uint32_t *)(void *)((unsigned char *)ENG + addr));
 }
 
 \ Set a byte in the context (address is offset in context).
@@ -130,13 +130,13 @@ cc: set8 ( val addr -- ) {
 \ Set a 16-bit word in the context (address is offset in context).
 cc: set16 ( val addr -- ) {
        size_t addr = (size_t)T0_POP();
-       *(uint16_t *)((unsigned char *)ENG + addr) = (uint16_t)T0_POP();
+       *(uint16_t *)(void *)((unsigned char *)ENG + addr) = (uint16_t)T0_POP();
 }
 
 \ Set a 32-bit word in the context (address is offset in context).
 cc: set32 ( val addr -- ) {
        size_t addr = (size_t)T0_POP();
-       *(uint32_t *)((unsigned char *)ENG + addr) = (uint32_t)T0_POP();
+       *(uint32_t *)(void *)((unsigned char *)ENG + addr) = (uint32_t)T0_POP();
 }
 
 \ Define a word that evaluates as an address of a field within the
index 3970d28..5dd30a1 100644 (file)
@@ -75,7 +75,7 @@ void br_ssl_hs_server_run(void *t0ctx);
 /*
  * This macro evaluates to a pointer to the current engine context.
  */
-#define ENG  ((br_ssl_engine_context *)((unsigned char *)t0ctx - offsetof(br_ssl_engine_context, cpu)))
+#define ENG  ((br_ssl_engine_context *)(void *)((unsigned char *)t0ctx - offsetof(br_ssl_engine_context, cpu)))
 
 
 
@@ -1454,7 +1454,7 @@ br_ssl_hs_server_run(void *t0ctx)
                                /* get16 */
 
        size_t addr = (size_t)T0_POP();
-       T0_PUSH(*(uint16_t *)((unsigned char *)ENG + addr));
+       T0_PUSH(*(uint16_t *)(void *)((unsigned char *)ENG + addr));
 
                                }
                                break;
@@ -1462,7 +1462,7 @@ br_ssl_hs_server_run(void *t0ctx)
                                /* get32 */
 
        size_t addr = (size_t)T0_POP();
-       T0_PUSH(*(uint32_t *)((unsigned char *)ENG + addr));
+       T0_PUSH(*(uint32_t *)(void *)((unsigned char *)ENG + addr));
 
                                }
                                break;
@@ -1635,7 +1635,7 @@ br_ssl_hs_server_run(void *t0ctx)
                                /* set16 */
 
        size_t addr = (size_t)T0_POP();
-       *(uint16_t *)((unsigned char *)ENG + addr) = (uint16_t)T0_POP();
+       *(uint16_t *)(void *)((unsigned char *)ENG + addr) = (uint16_t)T0_POP();
 
                                }
                                break;
@@ -1643,7 +1643,7 @@ br_ssl_hs_server_run(void *t0ctx)
                                /* set32 */
 
        size_t addr = (size_t)T0_POP();
-       *(uint32_t *)((unsigned char *)ENG + addr) = (uint32_t)T0_POP();
+       *(uint32_t *)(void *)((unsigned char *)ENG + addr) = (uint32_t)T0_POP();
 
                                }
                                break;
index d6bb2e4..6732f9d 100644 (file)
@@ -198,12 +198,12 @@ cc: set8 ( val addr -- ) {
 
 cc: set16 ( val addr -- ) {
        uint32_t addr = T0_POP();
-       *(uint16_t *)((unsigned char *)CTX + addr) = T0_POP();
+       *(uint16_t *)(void *)((unsigned char *)CTX + addr) = T0_POP();
 }
 
 cc: set32 ( val addr -- ) {
        uint32_t addr = T0_POP();
-       *(uint32_t *)((unsigned char *)CTX + addr) = T0_POP();
+       *(uint32_t *)(void *)((unsigned char *)CTX + addr) = T0_POP();
 }
 
 cc: get8 ( addr -- val ) {
@@ -213,12 +213,12 @@ cc: get8 ( addr -- val ) {
 
 cc: get16 ( addr -- val ) {
        uint32_t addr = T0_POP();
-       T0_PUSH(*(uint16_t *)((unsigned char *)CTX + addr));
+       T0_PUSH(*(uint16_t *)(void *)((unsigned char *)CTX + addr));
 }
 
 cc: get32 ( addr -- val ) {
        uint32_t addr = T0_POP();
-       T0_PUSH(*(uint32_t *)((unsigned char *)CTX + addr));
+       T0_PUSH(*(uint32_t *)(void *)((unsigned char *)CTX + addr));
 }
 
 \ Read an ASN.1 tag. This function returns the "constructed" status
index 4c486d5..f4e43e7 100644 (file)
@@ -75,7 +75,7 @@ void br_skey_decoder_run(void *t0ctx);
 
 #include "inner.h"
 
-#define CTX   ((br_skey_decoder_context *)((unsigned char *)t0ctx - offsetof(br_skey_decoder_context, cpu)))
+#define CTX   ((br_skey_decoder_context *)(void *)((unsigned char *)t0ctx - offsetof(br_skey_decoder_context, cpu)))
 #define CONTEXT_NAME   br_skey_decoder_context
 
 /* see bearssl_x509.h */
index 336b932..5b59421 100644 (file)
@@ -24,7 +24,7 @@ preamble {
 
 #include "inner.h"
 
-#define CTX   ((br_skey_decoder_context *)((unsigned char *)t0ctx - offsetof(br_skey_decoder_context, cpu)))
+#define CTX   ((br_skey_decoder_context *)(void *)((unsigned char *)t0ctx - offsetof(br_skey_decoder_context, cpu)))
 #define CONTEXT_NAME   br_skey_decoder_context
 
 /* see bearssl_x509.h */
index 42620c6..8dd970f 100644 (file)
@@ -75,7 +75,7 @@ void br_x509_decoder_run(void *t0ctx);
 
 #include "inner.h"
 
-#define CTX   ((br_x509_decoder_context *)((unsigned char *)t0ctx - offsetof(br_x509_decoder_context, cpu)))
+#define CTX   ((br_x509_decoder_context *)(void *)((unsigned char *)t0ctx - offsetof(br_x509_decoder_context, cpu)))
 #define CONTEXT_NAME   br_x509_decoder_context
 
 /* see bearssl_x509.h */
@@ -743,7 +743,7 @@ br_x509_decoder_run(void *t0ctx)
                                /* set32 */
 
        uint32_t addr = T0_POP();
-       *(uint32_t *)((unsigned char *)CTX + addr) = T0_POP();
+       *(uint32_t *)(void *)((unsigned char *)CTX + addr) = T0_POP();
 
                                }
                                break;
index 1b6089b..0bf276f 100644 (file)
@@ -24,7 +24,7 @@ preamble {
 
 #include "inner.h"
 
-#define CTX   ((br_x509_decoder_context *)((unsigned char *)t0ctx - offsetof(br_x509_decoder_context, cpu)))
+#define CTX   ((br_x509_decoder_context *)(void *)((unsigned char *)t0ctx - offsetof(br_x509_decoder_context, cpu)))
 #define CONTEXT_NAME   br_x509_decoder_context
 
 /* see bearssl_x509.h */
index a8283e3..ea14ad2 100644 (file)
@@ -356,7 +356,7 @@ const br_x509_class br_x509_minimal_vtable = {
        xm_get_pkey
 };
 
-#define CTX   ((br_x509_minimal_context *)((unsigned char *)t0ctx - offsetof(br_x509_minimal_context, cpu)))
+#define CTX   ((br_x509_minimal_context *)(void *)((unsigned char *)t0ctx - offsetof(br_x509_minimal_context, cpu)))
 #define CONTEXT_NAME   br_x509_minimal_context
 
 #define DNHASH_LEN   ((CTX->dn_hash_impl->desc >> BR_HASHDESC_OUT_OFF) & BR_HASHDESC_OUT_MASK)
@@ -1444,7 +1444,7 @@ br_x509_minimal_run(void *t0ctx)
                                /* get16 */
 
        uint32_t addr = T0_POP();
-       T0_PUSH(*(uint16_t *)((unsigned char *)CTX + addr));
+       T0_PUSH(*(uint16_t *)(void *)((unsigned char *)CTX + addr));
 
                                }
                                break;
@@ -1452,7 +1452,7 @@ br_x509_minimal_run(void *t0ctx)
                                /* get32 */
 
        uint32_t addr = T0_POP();
-       T0_PUSH(*(uint32_t *)((unsigned char *)CTX + addr));
+       T0_PUSH(*(uint32_t *)(void *)((unsigned char *)CTX + addr));
 
                                }
                                break;
@@ -1606,7 +1606,7 @@ br_x509_minimal_run(void *t0ctx)
                                /* set16 */
 
        uint32_t addr = T0_POP();
-       *(uint16_t *)((unsigned char *)CTX + addr) = T0_POP();
+       *(uint16_t *)(void *)((unsigned char *)CTX + addr) = T0_POP();
 
                                }
                                break;
@@ -1614,7 +1614,7 @@ br_x509_minimal_run(void *t0ctx)
                                /* set32 */
 
        uint32_t addr = T0_POP();
-       *(uint32_t *)((unsigned char *)CTX + addr) = T0_POP();
+       *(uint32_t *)(void *)((unsigned char *)CTX + addr) = T0_POP();
 
                                }
                                break;
index 2104d2c..bce37ad 100644 (file)
@@ -305,7 +305,7 @@ const br_x509_class br_x509_minimal_vtable = {
        xm_get_pkey
 };
 
-#define CTX   ((br_x509_minimal_context *)((unsigned char *)t0ctx - offsetof(br_x509_minimal_context, cpu)))
+#define CTX   ((br_x509_minimal_context *)(void *)((unsigned char *)t0ctx - offsetof(br_x509_minimal_context, cpu)))
 #define CONTEXT_NAME   br_x509_minimal_context
 
 #define DNHASH_LEN   ((CTX->dn_hash_impl->desc >> BR_HASHDESC_OUT_OFF) & BR_HASHDESC_OUT_MASK)
index acd8512..3d13510 100644 (file)
@@ -72,9 +72,11 @@ host_connect(const char *host, const char *port, int verbose)
 
                        sa = (struct sockaddr *)p->ai_addr;
                        if (sa->sa_family == AF_INET) {
-                               addr = &((struct sockaddr_in *)sa)->sin_addr;
+                               addr = &((struct sockaddr_in *)
+                                       (void *)sa)->sin_addr;
                        } else if (sa->sa_family == AF_INET6) {
-                               addr = &((struct sockaddr_in6 *)sa)->sin6_addr;
+                               addr = &((struct sockaddr_in6 *)
+                                       (void *)sa)->sin6_addr;
                        } else {
                                addr = NULL;
                        }
index cac99c4..8fcf2eb 100644 (file)
@@ -75,7 +75,7 @@ host_bind(const char *host, const char *port, int verbose)
 
                sa = (struct sockaddr *)p->ai_addr;
                if (sa->sa_family == AF_INET) {
-                       sa4 = *(struct sockaddr_in *)sa;
+                       memcpy(&sa4, sa, sizeof sa4);
                        sa = (struct sockaddr *)&sa4;
                        sa_len = sizeof sa4;
                        addr = &sa4.sin_addr;
@@ -83,7 +83,7 @@ host_bind(const char *host, const char *port, int verbose)
                                sa4.sin_addr.s_addr = INADDR_ANY;
                        }
                } else if (sa->sa_family == AF_INET6) {
-                       sa6 = *(struct sockaddr_in6 *)sa;
+                       memcpy(&sa6, sa, sizeof sa6);
                        sa = (struct sockaddr *)&sa6;
                        sa_len = sizeof sa6;
                        addr = &sa6.sin6_addr;